diff --git a/.env.example b/.env.example
new file mode 100644
index 0000000..e9ecc48
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,2 @@
+VITE_CHROME_EXTENSION_ID=
+VITE_SUMMARIZATION_API_URL=
diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..cfe8413
--- /dev/null
+++ b/.github/CODE_OF_CONDUCT.md
@@ -0,0 +1,76 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to make participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, sex characteristics, gender identity and expression,
+level of experience, education, socio-economic status, nationality, personal
+appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+- Using welcoming and inclusive language
+- Being respectful of differing viewpoints and experiences
+- Gracefully accepting constructive criticism
+- Focusing on what is best for the community
+- Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+- The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+- Trolling, insulting/derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+- Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies within all project spaces, and it also applies when
+an individual is representing the project or its community in public spaces.
+Examples of representing a project or community include using an official
+project e-mail address, posting via an official social media account, or acting
+as an appointed representative at an online or offline event. Representation of
+a project may be further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting the project team at tec.henriquedepaula@gmail.com. All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an incident.
+Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
+available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
+
+[homepage]: https://www.contributor-covenant.org
+
+For answers to common questions about this code of conduct, see
+https://www.contributor-covenant.org/faq
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
new file mode 100644
index 0000000..39fc155
--- /dev/null
+++ b/.github/CONTRIBUTING.md
@@ -0,0 +1,56 @@
+# Introduction to Contributing
+
+Contribution is the heart of open-source projects. This project welcomes contributions from everyone. This document will guide you through the process of contributing to this project. To do that, we have some guidelines and a [Code of Conduct](./CODE_OF_CONDUCT.md) that we ask you to follow.
+
+## Recommended Communication Style
+
+1. Always leave screenshots or code snippets to help explain your point.
+2. Always leave a detailed description in the pull request. Forget ambiguity.
+3. Always review your code before submitting a pull request. Run locally and test it before requesting a review.
+4. Always communicate in the GitHub Repository. Whether in the issue or the pull request, keeping the lines of communication open and visible to everyone on the team helps everyone stay on the same page.
+
+## Issues
+
+* If you wish to work on an open issue, please ask for it to be assigned to you.
+* If you find a bug, or have a feature request, please open an issue. You can also open a discussion if you have any questions or suggestions.
+* If you contribute to the project for the first time, you can search for issues with `good first issue` or `bug` labels in the repository.
+>[!NOTE]
+> **Please only self-assign a good first issue one time**.
+> Maintainers may remove you from the assignees and not accept your pull request if you choose to proceed.
+
+## Commits
+
+* Always use the present tense ("Add feature" not "Added feature", or "Adding feature").
+* Always use the imperative mood ("Move cursor to..." not "Moves cursor to...").
+* We recommend using the [Conventional Commits][commitsGuidelinesLink] pattern to make it easier to understand the changes made in the project. (e.g. `feat: add new feature`, `fix: correct a bug`, `docs: update README.md`).
+
+ >[!NOTE]
+ > We will add [husky][huskyReference] and [commitlint][commitlintReference] to the project in the future to enforce this pattern.
+ > We will add a changelog generator in the future.
+
+[commitlintReference]: https://commitlint.js.org/
+[huskyReference]: https://typicode.github.io/husky/
+[commitsGuidelinesLink]: https://www.conventionalcommits.org/en/v1.0.0/
+
+* Always reference the issue number in the commit message. (e.g. `feat: add new feature #123`). (If there is no issue, create one first).
+* Always keep the commits as small as possible. If you have a large commit, try to split it into smaller commits.
+
+## Pull Requests
+
+We actively welcome your pull requests. However, you must ensure that you are assigned to an existing issue before working on changes, and you need to link your work to the issue in your PR form.
+
+---
+1. Fork the repository, then clone it to your local machine.
+2. Creating a new branch is a must. Before working on your changes, create a new branch from the default branch. Name your branch with something descriptive of your work, i.e., `feat-sidePanel` or `fix/broken-links`.
+3. The code must be tested locally before submitting a pull request. If you are adding a new feature, make sure to add tests for it. (We will add a test suite in the future).
+4. If you make visual changes, include screenshots or gifs in your pull request.
+5. If you improve the existing code, make sure to run the tests and ensure that the code is working as expected and talk about the improvements in the pull request description.
+6. We use a **template for the pull request**. Please fill out the template with the necessary information.
+
+## Code Review
+
+The pull request will be reviewed by the maintainers. We will provide feedback on your code and suggest changes if necessary. We may ask you to make changes to your code before merging it. We will also provide feedback on the design, coding style, and testing.
+
+## License
+
+By contributing to the Foca AI project, you agree that your contributions will be licensed under the [MIT License](../LICENSE).
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index a547bf3..18d8b35 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
+.env
node_modules
dist
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..0c663f3
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,8 @@
+{
+ "semi": true,
+ "singleQuote": true,
+ "tabWidth": 2,
+ "trailingComma": "es5",
+ "useTabs": false,
+ "printWidth": 75
+}
diff --git a/.prettierrc.js b/.prettierrc.js
deleted file mode 100644
index 0738bb5..0000000
--- a/.prettierrc.js
+++ /dev/null
@@ -1,8 +0,0 @@
-module.exports = {
- semi: true,
- singleQuote: true,
- tabWidth: 2,
- trailingComma: 'es5',
- useTabs: false,
- printWidth: 75,
-};
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..9e34e3e
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,11 @@
+{
+ "recommendations": [
+ "bradlc.vscode-tailwindcss",
+ "streetsidesoftware.code-spell-checker",
+ "hediet.vscode-drawio",
+ "editorconfig.editorconfig",
+ "dbaeumer.vscode-eslint",
+ "dsznajder.es7-react-js-snippets",
+ "yzhang.markdown-all-in-one"
+ ]
+}
diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz
new file mode 100644
index 0000000..e2c40ea
Binary files /dev/null and b/.yarn/install-state.gz differ
diff --git a/.yarnrc.yml b/.yarnrc.yml
new file mode 100644
index 0000000..3186f3f
--- /dev/null
+++ b/.yarnrc.yml
@@ -0,0 +1 @@
+nodeLinker: node-modules
diff --git a/README.md b/README.md
index b4e41a3..2e51322 100644
--- a/README.md
+++ b/README.md
@@ -1,99 +1,195 @@
# Foca AI
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Foca AI is a Chrome extension that helps you focus on your tasks while browsing the web. With this extension, you can create tasks, assign tags to categorize them, and focus on specific topics. Manage one task at a time and stay on track with our visual aid that encourages you to maintain focus.
## Table of contents
- [Foca AI](#foca-ai)
- [Table of contents](#table-of-contents)
- - [About this project](#about-this-project)
- [Running Locally](#running-locally)
+ - [Setting up environment variables](#setting-up-environment-variables)
+ - [Environment purposes](#environment-purposes)
+ - [Using environment variables in the manifest file](#using-environment-variables-in-the-manifest-file)
+ - [Building and running the project](#building-and-running-the-project)
+ - [Registering the extension](#registering-the-extension)
- [Contributing](#contributing)
- [Contribution Guidelines and Code of Conduct](#contribution-guidelines-and-code-of-conduct)
- - [Development Contributions](#development-contributions)
- [Tech Stack](#tech-stack)
- - [Language](#language)
+ - [Languages](#languages)
- [Frameworks](#frameworks)
- [Project structure](#project-structure)
- [Chrome Manifest](#chrome-manifest)
- [Extension Entries](#extension-entries)
- [Content scripts](#content-scripts)
-
-
-## About this project
-
-This is a solution for your productivity issues while navigating in the web.
-We use the built-in chrome-AI to make your day-by-day more productive.
-By using our extension, you can create tasks to be done, and use tags
-to decide what topics you want to focus. One task at time, you can change
-your focus and see our figure telling helping you to stay focused.
+ - [Available commands](#available-commands)
+ - [License](#license)
## Running Locally
If you want to run this project locally, you will need [git](https://git-scm.com/downloads) and [Node.js](https://nodejs.org/en).
-Them, you can clone this repository by running the following commands in your terminal:
+
+Then, you can clone this repository by running the following commands in your terminal:
```zsh
git clone git@github.com:FocaAI/FocaAI-chrome-extension.git
cd FocaAi-chrome-extension
```
->[!TIP]
+
+### Setting up environment variables
+
+This project uses vite to handle the environment variables.
+
+To setup the project you should create `.env` file in the root directory following the `.env.example` format.
+
+#### Environment purposes
+
+Here you can see the purpose of each environment variable.
+
+- `VITE_SUMMARIZATION_API_URL`: Provides the token to summarization access into the manifest `trial_tokens` following [this guide from chrome documentation](https://googlechrome.github.io/OriginTrials/developer-guide.html)
+- `VITE_CHROME_EXTENSION_ID`: Your chrome extension ID, used to register the token for the [summarization API](https://chromestatus.com/feature/5193953788559360).
+
+> [!NOTE]
+> If any of them is missing, please create an issue following the [contribution guidelines](./.github.CONTRIBUTION.md).
+
+### Using environment variables in the manifest file
+
+To do that in the manifest builder, we had to configure the vite config in a different way.
+
+The `vite.config.ts` file loads the environment variables in the config definition. Parsing them to the `getManifest` handler.
+> [!IMPORTANT]
+> To effectively use a new environment variable in the getManifest, you should provide it in the `vite.config.ts`.
+>
+> ```ts
+> //...imports and configurations
+> defineConfig(({ mode }) => {
+> const env = loadEnv(mode, process.cwd());
+> return {
+> plugin: [React(), webExtension({ manifest: getManifest(env) })],
+> // others configurations
+> define: {
+> 'process.env': {
+> VITE_YOUR_ENV_FOR_MANIFEST: JSON.stringify(
+> env.VITE_YOUR_ENV_FOR_MANIFEST
+> ),
+> },
+> },
+> };
+> });
+> ```
+
+### Building and running the project
+Before registering the extension in you favorite browser, you should build the project.
+> [!TIP]
+>
> #### Running with npm:
+>
> ```zsh
> npm install
> npm run watch
> ```
+>
> #### Running with yarn:
+>
> ```zsh
> yarn install
> yarn watch
> ```
-> ### Others commands
-> Here is a list of each command that you can run
-> - `dev`: run the vite application normally.
-> - `build`: Build the application into the `/dist` directory.
-> - `watch`: **Hot Module Resolution** to update dist folder on each change.
-> - `serve:chrome`: serve files into the `/dist` on chrome extensions.
-> - `serve:firefox`: same as the previous command but on the firefox application.
+>
+
+>[!NOTE]
+> You can see all the available commands in the [Available commands](#available-commands) section.
+
+### Registering the extension
+
+After building the project, you can register the extension in your browser.
+
+To do that, you should follow the steps below:
+
+1. Open the Extension Management page by navigating to `chrome://extensions`.
+ - The Extension Management page can also be opened by clicking on the Chrome menu, hovering over `More Tools` then select `Extensions`.
+2. Enable Developer Mode by clicking the toggle switch next to Developer Mode.
+3. Click the `Load unpacked` button and select the extension directory.
+4. The extension will be loaded into your browser.
+5. You can see the extension in the toolbar.
+>[!TIP]
+> You can see more information about how to load an unpacked extension in the [Chrome Getting started tutorial](https://developer.chrome.com/docs/extensions/get-started/tutorial/hello-world).
## Contributing
-To contribute to this project you can create a issue report, and help us to
-find bugs, suggest features and create discussions about this extension. We are always looking for improvements to the project and contributions from open-source developers are greatly appreciated.
+To contribute to this project you can create an issue report, and help us to
+find bugs, suggest features, and create discussions about this extension. We are always looking for improvements to the project and contributions from open-source developers are greatly appreciated.
+
### Contribution Guidelines and Code of Conduct
-Remember to follow our [Contribution guidelines](#foca-ai)
-for information on how to do so. Also, make sure you read our [Code of Conduct](#foca-ai) to foster an encouraging sense of community.
-### Development Contributions
-Here you can find useful information about development tips and more.
+Remember to follow our [Contribution guidelines](./.github/CONTRIBUTING.md)
+for information on how to do so. Also, make sure you read our [Code of Conduct](./.github/CODE_OF_CONDUCT.md) to foster an encouraging sense of community.
## Tech Stack
Here is a brief overview about the stack that we use to develop this extension.
-### Language
+### Languages
+
+We use [**TypeScript**](https://www.typescriptlang.org/docs/) to build our web application, enabling autocomplete and type-checking to enhance the development experience.
-We use [**TypeScript**](https://www.typescriptlang.org/docs/) to build our web application, enabling autocomplete and type-checking to enhance the development experience.
### Frameworks
**To build our application**, we use [**vite**](https://vite.dev/guide/) to build our extension, enabling **hmr** into our development cycle thanks to [**@samrum/vite-plugin-web-extension**](https://github.com/samrum/vite-plugin-web-extension) plugin.
**To create simple and intuitive UI**, we use [**TailwindCSS**](https://tailwindcss.com/docs/installation), and [**Shadcn/ui**](https://ui.shadcn.com/docs) to speed up our development.
-
### Project structure
+
Here you can see more important information about the project structure.
+
#### Chrome Manifest
- The extension manifest is defined in src/manifest.js and used by @samrum/vite-plugin-web-extension in the vite config.
+
+The extension manifest is defined in src/manifest.js and used by @samrum/vite-plugin-web-extension in the vite config.
+
#### Extension Entries
+
Background, content scripts, options, and popup entry points exist in the **src/entries** directory.
->[!TIP]
->You can find information about how those files are used into in the [Developer chrome documentation](https://developer.chrome.com/docs/extensions/get-started?hl=pt-br).
+> [!TIP]
+> You can find information about how those files are used in the [Developer chrome documentation](https://developer.chrome.com/docs/extensions/get-started?hl=pt-br).
##### Content scripts
- Rendered by **src/entries/contentScript/renderContent.ts** which renders content within a **ShadowRoot** and handles **style injection** for **HMR** and build modes.
+
+Rendered by **src/entries/contentScript/renderContent.ts** which renders content within a **ShadowRoot** and handles **style injection** for **HMR** and build modes.
Otherwise, the project functions just like a regular Vite project.
->[!CAUTION]
->HMR during development in Manifest V3 requires Chromium version >= 110.0.5480.0.
+
+> [!CAUTION]
+> HMR during development in Manifest V3 requires Chromium version >= 110.0.5480.0.
+
+ ### Available commands
+
+ Here is a list of each command that you can run
+
+ - `dev`: run the vite application normally.
+ - `build`: Build the application into the `/dist` directory.
+ - `watch`: **Hot Module Resolution** to update the dist folder on each change.
+ - `serve:chrome`: serve files into the `/dist` on Chrome extensions.
+ - `serve:firefox`: same as the previous command but on the Firefox application.
+
+## License
+
+This project is licensed under the terms of the [MIT license](./LICENSE).
diff --git a/docs/use-case-flow.drawio.svg b/docs/use-case-flow.drawio.svg
new file mode 100644
index 0000000..abc510a
--- /dev/null
+++ b/docs/use-case-flow.drawio.svg
@@ -0,0 +1,365 @@
+
\ No newline at end of file
diff --git a/eslint.config.js b/eslint.config.mjs
similarity index 70%
rename from eslint.config.js
rename to eslint.config.mjs
index 092408a..82c2e20 100644
--- a/eslint.config.js
+++ b/eslint.config.mjs
@@ -1,8 +1,8 @@
-import js from '@eslint/js'
-import globals from 'globals'
-import reactHooks from 'eslint-plugin-react-hooks'
-import reactRefresh from 'eslint-plugin-react-refresh'
-import tseslint from 'typescript-eslint'
+import js from '@eslint/js';
+import globals from 'globals';
+import reactHooks from 'eslint-plugin-react-hooks';
+import reactRefresh from 'eslint-plugin-react-refresh';
+import tseslint from 'typescript-eslint';
export default tseslint.config(
{ ignores: ['dist'] },
@@ -24,5 +24,5 @@ export default tseslint.config(
{ allowConstantExport: true },
],
},
- },
-)
+ }
+);
diff --git a/index.html b/index.html
index e4b78ea..07b7606 100644
--- a/index.html
+++ b/index.html
@@ -3,7 +3,10 @@