- We used generative AI in this project. Artifacts and other documents where we used generative AI contain a note about the source and a link to the conversation.
- Grouping by features or routes
https://legacy.reactjs.org/docs/faq-structure.html
- A feature will have it's own folder. The folder contains the React component, child components (if any), styles, and helper functions.
- Folders: camelCase
- Components: PascalCase
- Styles:
- filenames: PascalCase
- global css: camelCase
- classnames: kebab-case
- Image names: camelCase.png/jped/...
- Clone the repository
git clone https://github.com/agrilens/agrilens-frontend.git
- Open the
agrilens-frontend
folder on your terminal on your terminal
cd agrilens-frontend
- Start the app on local computer
npm start
Runs the app in the development mode.
Open http://localhost:3000 to view it in your browser.
The page will reload when you make changes.
You may also see any lint errors in the console.
-
Create your branch based off the
main
branch- Branch naming convention:
feature-<TICKET#>
eg.feature-15
git syntax:git branch feature-15
- Branch naming convention:
-
Build your component, add, commit push
git add <PATH>
git commit -m "COMMIT MESSAGE"
git push origin feature-<TICKET#>
-
Send a Pull Request before merging your branch.
-
Upon approval, merger your branch and delete the branch from the repository.
-
- ESLint
ESLint is a tool for making code more consistent and avoiding bugs.
- ESLint
npm run lint
-
- Prettier
Prettier is a code formatter that automatically formats your code to ensure consistency and adherence to specified style rules.
- Prettier
npm run prettify
-
- Husky Husky is a tool that utilizes git hooks to ensure code consistancy before completing git actions.
-
Environment variable names should start with
REACT_APP_
Example:
REACT_APP_EXAMPLE_API_KEY=gh:4tlsm-kebasdn_fklhn4aSfLmE-df_Alfdne
-
.env
file is added to.gitignore
so that it won't be pushed to the github repo.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
Cypress is a next generation front end testing tool built for the modern web. https://docs.cypress.io/guides/overview/why-cypress
- Cypress helps you set up and start writing tests every day while you build your application locally.
- After building up a suite of tests and integrating Cypress with your CI Provider, Cypress Cloud can record your test runs.
- End-to-end
- Component
- API
- Open Cypress:
npx cypress open
ornpm run cy:open
The app doesn't use TypeScript. You can ignore theCouldn't find tsconfig.json
warnings. - For the development phase, we're doing
Component Testing
for isolated component building and testing. - Cypress testing files will be positioned as a sibling to the original component file.
navBar/
NavBar.css
NavBar.cy.jsx
NavBar.jsx
-
Run
npm install firebase
-
Initialize and configure firebase with firebaseConfig = {}
-
Save the API keys and other properties under the
.env
file. -
Install Firebase CLI run
npm install -g firebase-tools
-
Run
npm run build
to prepare build folder. -
Sign in to Google: run
firebase login
Or to login into a different accountfirebase login:use [email protected]
-
Initiate the project: run
firebase init
- ? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your
Scroll down and click the space-bar atHosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys
- What do you want to use as your public directory? (public)
type in
build
- Click enter for the subsequent default values.
- ? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your
-
To serve the app locally run:
- (First time)
firebase init emulators
and select Hosting Emulator firebase emulators:start
- (First time)
-
Deploy the web app: run
firebase deploy
-
Run
firebase init hosting:github
- ? For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository)
agrilens/agrilens-frontend
- ? Set up the workflow to run a build script before every deploy?
Yes
- ? What script should be run before every deploy?
npm ci && npm run build
- ? GitHub workflow file for PR previews exists. Overwrite? firebase-hosting-pull-request.yml
No
- ? Set up automatic deployment to your site's live channel when a PR is merged?
Yes
- ? What is the name of the GitHub branch associated with your site's live channel?
main
- ? The GitHub workflow file for deploying to the live channel already exists. Overwrite? firebase-hosting-merge.yml
No
- ? For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository)
-
Firebase CLI GitHub OAuth App:
https://github.com/settings/connections/applications/89cf50f02ac6aaed3484
-
GitHub Firebase secret:
FIREBASE_SERVICE_ACCOUNT_AGRILENS_WEB
-
Firebase GitHub Hosting admin name :
github-action-867998929
-
Create a deploy channer for a preview channel that lasts for two days with ID stage:
firebase hosting:channel:deploy stage --expires 2d
-
To delete the preview channel:
firebase hosting:channel:delete stage
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
Note: this is a one-way operation. Once you eject
, you can't go back!
If you aren't satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
Libraries Used: This project uses a variety of libraries and frameworks to streamline development and testing:
- React: Core library for building user interfaces
- Firebase: Backend and hosting platform
- Cypress: End-to-end and component testing framework
- ESLint: JavaScript linting tool
- Prettier: Code formatting tool
- Husky: Git hooks manager for enforcing code quality on commit
- Llama: Mixtral is from the Llama family. Hyperbolic - This is what hosts our LVM's
- Qwen: Qwen is an independent research org that releases state-of-the-art LVM models Hyperbolic - This is what hosts our LVM's
- Plant ID: Plant ID uses iNaturalist, which uses a closed-source model. Plant ID API Docs