A scalable and modular backend application for a food delivery service, built with Node.js, Express, TypeScript, and TypeORM. The app includes features like user management, rate limiting, logging, and database integration.
- Express Framework: Fast and lightweight web server.
- TypeScript: Strongly typed language for better code quality.
- TypeORM: Database ORM for managing entities and migrations.
- Winston Logging: Centralized logging to console and files.
- Rate Limiting: Protects APIs from abuse using
express-rate-limit. - Redis Integration: Caching and session management.
- Helmet: Security headers for better protection.
- Docker Support: Containerized deployment with
Dockeranddocker-compose. - Environment Configuration: Managed using
.envfiles and validated withJoi.
- Node.js: v20.18.1 or higher
- Docker: Installed for containerized deployment
- PostgreSQL: Database for storing application data
- Redis: For caching and rate limiting
- Clone the repository:
git clone https://github.com/your-repo/FoodDeliveryApp.git
cd FoodDeliveryApp- Install dependencies:
npm install- Set up environment variables:
Copy the appropriate .env file from the env/ directory (e.g., development.env) and configure it as needed.
- Build the project:
npm run build- Start the server:
npm run start- Start the development server with hot-reloading:
npm run dev- Run linting and formatting:
npm run lint
npm run format- Run tests:
npm test- Build and run the application using Docker Compose
docker-compose -f docker-compose.yaml -f docker-compose.dev.yaml up --build- For production:
docker-compose -f docker-compose.yaml -f docker-compose.prod.yaml up --buildLogs are managed using Winston and stored in the logs/ directory. Console logs are colorized for better readability in development.
Default rate limit: 100 requests per 5 minutes per IP. Configured using express-rate-limit with Redis for persistence.
| Variable | Description | Default Value |
|---|---|---|
| NODE_ENV | Application environment | development |
| PORT | Server port | 4000 |
| DATABASE_HOST | Database host | localhost |
| DATABASE_PORT | Database port | 5432 |
| DATABASE_USERNAME | Database username | postgres |
| DATABASE_PASSWORD | Database password | postgres |
| DATABASE_NAME | Database name | food_delivery |
| REDIS_HOST | Redis host | localhost |
| REDIS_PORT | Redis port | 6379 |
| REDIS_DEFAULT_TTL | Redis default ttl time for caching | 3600 |
This project includes a database seeder utility located at src/database/seeders/index.ts. The seeder will clear all tables, reset sequences, and populate the database with initial data.
- Ensure your environment variables are set correctly in the
env/{NODE_ENV}.envfile. - Run the seeder with:
npm run seed- The seeder will:
- Clear all tables
- Reset all sequences
- Insert seed data from src/database/seeders/seeded-data.ts
You can further customize this section as needed for your project.
This project is licensed under the MIT License. See the LICENSE file for details.
