Introduction
The goal of this website is to provide comprehensive documentation and examples of how OneToGo is developed and how it works.
Installation
Clone the repository and run npm install
in the root folder.
Then, inside the root folder create a .env.local
file and add the following variables:
# Firebase
NEXT_PUBLIC_FIREBASE_API_KEY=
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
NEXT_PUBLIC_FIREBASE_PROJECT_ID=
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=
NEXT_PUBLIC_FIREBASE_APP_ID=
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=
# Firebase Admin
FIREBASE_SERVICE_ACCOUNT_KEY='JSON file content without line breaks'
# Stripe
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
STRIPE_SECRET_KEY=
# OpenAI
OPENAI_API_KEY=
# Email service
RESEND_API_KEY=
SENDER_EMAIL=
RECEIVER_EMAIL=
To run the application, run npm run dev
in the root folder.
Develpment
While developing OneToGo, I followed the SOLID programming principles and the Clean Architecture. The goal was to create a scalable and maintainable application that is easy to extend and test.
The application is split into three layers:
Presentation Layer
Formed by the /app
, and /components
folders. This layer contains the UI components and the logic for rendering them.
Logic Layer
Formed by the custom hooks in the /hooks
folder. This layer contains the logic for handling the data and the business logic.
Data Layer
Formed by the /services
folder. This layer contains the logic for fetching and sending data to the backend.
Learn more about how services work here..
Technologies
- Next.js 13 (opens in a new tab)
- Firebase (opens in a new tab)
- Stripe (opens in a new tab)
- OpenAI API (opens in a new tab)
- Tailwind CSS (opens in a new tab)
- TypeScript (opens in a new tab)
Testing
NPM Commands
A list of most important NPM commands declared in the package.json
file.
Development Commands
npm run dev
- Runs the application in development mode.
Testing
npm run test
- Runs the Jest unit tests.npm run cy:test
- Runsnext dev
in test mode, setting the following env variables:FIRESTORE_EMULATOR_HOST='127.0.0.1:8080' NEXT_PUBLIC_NODE_ENV='test' NODE_ENV=test
npm run cypress
- Runs the command above and opens the Cypress test runner in parallel.npm run emulators
- Runs the Firebase emulators for Firestore and Authentication.npm run emulators:export
- Overwrites a snapshot of the Firebase emulators data, to make it persistent between runs.
Deployment Commands
npm run deploy:rules
- Deploys the Firestore security rules to the Firebase project.