This project is a RESTful API built with Express.js, providing a platform for learners and tutors to interact, manage orders, reviews, and more.
You can view the API documentation here.
- Express.js: Web framework for building REST APIs.
- Drizzle: An ORM (Object-Relational Mapping) tool that simplifies interactions with the PostgreSQL database.
- Google Cloud Storage: Used for storing profile pictures and chat images.
- Firebase Realtime Database: Real-time database for managing user interactions between learners and tutors.
- Vitest & SuperTest: Testing frameworks for integration tests.
The project is structured in a modular way to ensure maintainability and scalability. Each module encapsulates specific functionality and follows the principle of separation of concerns. Below is an overview of the key directories and files:
-
src/
: Contains the source code for the application.-
common/
: Common services and utilities used across the application. -
db/
: Database configuration and drizzle setup. -
helpers/
: Helper functions for the application. -
middleware/
: Express middlewares (Logging, Validation, etc.). -
modules/
: Contains the modules for the application. Each module is a separate directory containing the following:abusive-detection/
: Integrates with API for detecting abusive content.auth/
: Handles authentication (login, signup) and authorization (role-based access control).category/
: Category related logic (popular categories, etc.).chat/
: Manages chat-related functionality, including messages, and media.face-validation/
: Integrates with API for face validationlearner/
: Manages learner (user/student) profiles and interactions.notification/
: Notification related logic.order/
: Manages order (reservation) creation, updates, rejection, and completion.recommendation/
: Integrates with API for generating recommendations.review/
: Manages reviews for tutors and lessons.tutor/
: Manages tutor (teacher) profiles and their availability.tutories/
: Manage tutories (lesson) creation, deletion, and updates
-
routes/
: Express route definitions. -
swagger/
: Swagger API documentation.
-
The application requires the following environment variables to be set:
DATABASE_URL
: PostgreSQL database connection URL.FIREBASE_SERVICE_ACCOUNT_KEY
: JSON string containing the Firebase service account key.FIREBASE_DATABASE_URL
: URL of the Firebase Realtime Database.GCS_BUCKET_NAME
: Google Cloud Storage bucket name for storing images.GOOGLE_OAUTH_CLIENT_ID
: Google OAuth client ID for authenticating users.JWT_SECRET
: Secret key for signing JWT tokens used for authentication.FACE_VALIDATION_URL
: URL for the face validation API.ABUSIVE_DETECTION_URL
: URL for the abusive detection APIRECOMMENDATION_URL
: URL for the recommendation API.
Optionally, you can set the following environment variables:
PORT
: Port number for the Express.js server. Default is 8080.GROQ_KEY
: API key for Groq, used to generate teaching methodologies for tutors. Only necessary if you are running the seeders.
This guide covers how to set up and run the project in your local development environment.
- Bun (v1.1.38)
- PostgreSQL (v16)
- Docker (optional, for running PostgreSQL in container)
- Firebase CLI
- Google Cloud SDK (for storage emulator)
-
Clone the repository
-
Install dependencies:
bun install
-
Copy the example environment file:
cp .env.example .env
-
Update the
.env
file with your configuration:# Server PORT=8080 CORS_ORIGIN=* # Database DATABASE_URL=postgres://tutortoise:tutortoise@localhost:5432/tutortoise_test # Firebase FIREBASE_DATABASE_URL=http://localhost:9000 FIREBASE_DATABASE_EMULATOR_HOST=localhost:9000 FIREBASE_SERVICE_ACCOUNT_KEY={"type": "service_account", ...} # Your Firebase service account key # Google OAuth Client ID GOOGLE_OAUTH_CLIENT_ID=your-client-id # Google Cloud Storage GCS_BUCKET_NAME=your-bucket-name # JWT JWT_SECRET=your-jwt-secret # ML APIs FACE_VALIDATION_URL= ABUSIVE_DETECTION_URL= RECOMMENDATION_URL= # Optional: For AI-generated content in seeders GROQ_KEY=your-groq-api-key
-
Start the PostgreSQL container:
docker compose -f docker-compose.local.yml up -d
-
Run database migrations:
bun db:migrate
-
(Optional) Seed the database:
bun db:seed
-
Create a new database:
CREATE DATABASE tutortoise_test;
-
Create a new user:
CREATE USER tutortoise WITH PASSWORD 'tutortoise'; GRANT ALL PRIVILEGES ON DATABASE tutortoise_test TO tutortoise;
-
Run database migrations:
bun db:migrate
-
Install Firebase CLI if you haven't:
npm install -g firebase-tools
-
Log in to Firebase:
firebase login
-
Start the emulators:
firebase emulators:start
This will start:
- Realtime Database emulator on port 9000
- Storage emulator on port 9199
bun dev
The server will be available at http://localhost:8080
See Common Issues for solutions to common development problems.