{"id":23444860,"url":"https://github.com/tutortoise/backend","last_synced_at":"2025-04-09T23:28:22.198Z","repository":{"id":264375211,"uuid":"885244195","full_name":"Tutortoise/backend","owner":"Tutortoise","description":"Backend for Tutortoise","archived":false,"fork":false,"pushed_at":"2024-12-12T14:10:00.000Z","size":1287,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-15T14:53:06.873Z","etag":null,"topics":["api","expressjs"],"latest_commit_sha":null,"homepage":"https://tutortoise.github.io/backend/api/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tutortoise.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-08T08:28:32.000Z","updated_at":"2024-12-12T14:10:03.000Z","dependencies_parsed_at":"2024-12-08T09:17:31.468Z","dependency_job_id":"02bbad29-73fc-461b-8ef4-2d7d7c49b55e","html_url":"https://github.com/Tutortoise/backend","commit_stats":null,"previous_names":["tutortoise/backend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tutortoise%2Fbackend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tutortoise%2Fbackend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tutortoise%2Fbackend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tutortoise%2Fbackend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tutortoise","download_url":"https://codeload.github.com/Tutortoise/backend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248128506,"owners_count":21052422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","expressjs"],"created_at":"2024-12-23T19:19:37.145Z","updated_at":"2025-04-09T23:28:22.174Z","avatar_url":"https://github.com/Tutortoise.png","language":"TypeScript","readme":"# Tutortoise (Backend)\n\nThis project is a RESTful API built with **Express.js**, providing a platform for\nlearners and tutors to interact, manage orders, reviews, and more.\n\nYou can view the API documentation [here](https://tutortoise.github.io/backend/api/).\n\n## Tech Stack\n\n- **Express.js**: Web framework for building REST APIs.\n- **Drizzle**: An ORM (Object-Relational Mapping) tool that simplifies interactions with the PostgreSQL database.\n- **Google Cloud Storage**: Used for storing profile pictures and chat images.\n- **Firebase Realtime Database**: Real-time database for managing user interactions between learners and tutors.\n- **Vitest \u0026 SuperTest**: Testing frameworks for integration tests.\n\n## Project Structure\n\nThe project is structured in a modular way to ensure maintainability and\nscalability. Each module encapsulates specific functionality and follows the\nprinciple of separation of concerns. Below is an overview of the key\ndirectories and files:\n\n- `src/`: Contains the source code for the application.\n\n  - `common/`: Common services and utilities used across the application.\n  - `db/`: Database configuration and drizzle setup.\n  - `helpers/`: Helper functions for the application.\n  - `middleware/`: Express middlewares (Logging, Validation, etc.).\n  - `modules/`: Contains the modules for the application. Each module is a separate directory containing the following:\n\n    - `abusive-detection/`: Integrates with API for detecting abusive content.\n    - `auth/`: Handles authentication (login, signup) and authorization (role-based access control).\n    - `category/`: Category related logic (popular categories, etc.).\n    - `chat/`: Manages chat-related functionality, including messages, and media.\n    - `face-validation/`: Integrates with API for face validation\n    - `learner/`: Manages learner (user/student) profiles and interactions.\n    - `notification/`: Notification related logic.\n    - `order/`: Manages order (reservation) creation, updates, rejection, and completion.\n    - `recommendation/`: Integrates with API for generating recommendations.\n    - `review/`: Manages reviews for tutors and lessons.\n    - `tutor/`: Manages tutor (teacher) profiles and their availability.\n    - `tutories/`: Manage tutories (lesson) creation, deletion, and updates\n\n  - `routes/`: Express route definitions.\n  - `swagger/`: Swagger API documentation.\n\n## Environment Variables\n\nThe application requires the following environment variables to be set:\n\n- `DATABASE_URL`: PostgreSQL database connection URL.\n- `FIREBASE_SERVICE_ACCOUNT_KEY`: JSON string containing the Firebase service account key.\n- `FIREBASE_DATABASE_URL`: URL of the Firebase Realtime Database.\n- `GCS_BUCKET_NAME`: Google Cloud Storage bucket name for storing images.\n- `GOOGLE_OAUTH_CLIENT_ID`: Google OAuth client ID for authenticating users.\n- `JWT_SECRET`: Secret key for signing JWT tokens used for authentication.\n- `FACE_VALIDATION_URL`: URL for the [face validation API](https://github.com/Tutortoise/face-validation-service).\n- `ABUSIVE_DETECTION_URL`: URL for the [abusive detection API](https://github.com/Tutortoise/bilingual-abusive-detection-service)\n- `RECOMMENDATION_URL`: URL for the [recommendation API](https://github.com/Tutortoise/system-recommender-service).\n\nOptionally, you can set the following environment variables:\n\n- `PORT`: Port number for the Express.js server. Default is 8080.\n- `GROQ_KEY`: API key for Groq, used to generate teaching methodologies for tutors. Only necessary if you are running the seeders.\n\n# Local Development Guide\n\nThis guide covers how to set up and run the project in your local development environment.\n\n## Prerequisites\n\n- Bun (v1.1.38)\n- PostgreSQL (v16)\n- Docker (optional, for running PostgreSQL in container)\n- Firebase CLI\n- Google Cloud SDK (for storage emulator)\n\n## Environment Setup\n\n1. Clone the repository\n2. Install dependencies:\n\n   ```bash\n   bun install\n   ```\n\n3. Copy the example environment file:\n\n   ```bash\n   cp .env.example .env\n   ```\n\n4. Update the `.env` file with your configuration:\n\n   ```env\n   # Server\n   PORT=8080\n   CORS_ORIGIN=*\n\n   # Database\n   DATABASE_URL=postgres://tutortoise:tutortoise@localhost:5432/tutortoise_test\n\n   # Firebase\n   FIREBASE_DATABASE_URL=http://localhost:9000\n   FIREBASE_DATABASE_EMULATOR_HOST=localhost:9000\n   FIREBASE_SERVICE_ACCOUNT_KEY={\"type\": \"service_account\", ...} # Your Firebase service account key\n\n   # Google OAuth Client ID\n   GOOGLE_OAUTH_CLIENT_ID=your-client-id\n\n   # Google Cloud Storage\n   GCS_BUCKET_NAME=your-bucket-name\n\n   # JWT\n   JWT_SECRET=your-jwt-secret\n\n   # ML APIs\n   FACE_VALIDATION_URL=\n   ABUSIVE_DETECTION_URL=\n   RECOMMENDATION_URL=\n\n   # Optional: For AI-generated content in seeders\n   GROQ_KEY=your-groq-api-key\n   ```\n\n## Database Setup\n\n### Using Docker (Recommended)\n\n1. Start the PostgreSQL container:\n\n   ```bash\n   docker compose -f docker-compose.local.yml up -d\n   ```\n\n2. Run database migrations:\n\n   ```bash\n   bun db:migrate\n   ```\n\n3. (Optional) Seed the database:\n   ```bash\n   bun db:seed\n   ```\n\n### Using Local PostgreSQL\n\n1. Create a new database:\n\n   ```sql\n   CREATE DATABASE tutortoise_test;\n   ```\n\n2. Create a new user:\n\n   ```sql\n   CREATE USER tutortoise WITH PASSWORD 'tutortoise';\n   GRANT ALL PRIVILEGES ON DATABASE tutortoise_test TO tutortoise;\n   ```\n\n3. Run database migrations:\n   ```bash\n   bun db:migrate\n   ```\n\n## Firebase Emulators\n\n1. Install Firebase CLI if you haven't:\n\n   ```bash\n   npm install -g firebase-tools\n   ```\n\n2. Log in to Firebase:\n\n   ```bash\n   firebase login\n   ```\n\n3. Start the emulators:\n   ```bash\n   firebase emulators:start\n   ```\n\nThis will start:\n\n- Realtime Database emulator on port 9000\n- Storage emulator on port 9199\n\n## Starting the Development Server\n\n```bash\nbun dev\n```\n\nThe server will be available at `http://localhost:8080`\n\n## Common Issues\n\nSee [Common Issues](docs/common-issues.md) for solutions to common development problems.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftutortoise%2Fbackend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftutortoise%2Fbackend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftutortoise%2Fbackend/lists"}