Skip to content

eldoghry/FoodDeliveryApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Food Delivery App

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.


Features

  • 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 Docker and docker-compose.
  • Environment Configuration: Managed using .env files and validated with Joi.

Project documentation

Prerequisites

  • Node.js: v20.18.1 or higher
  • Docker: Installed for containerized deployment
  • PostgreSQL: Database for storing application data
  • Redis: For caching and rate limiting

Installation

  1. Clone the repository:
git clone https://github.com/your-repo/FoodDeliveryApp.git

cd FoodDeliveryApp
  1. Install dependencies:
 npm install
  1. Set up environment variables:

Copy the appropriate .env file from the env/ directory (e.g., development.env) and configure it as needed.

  1. Build the project:
npm run build
  1. Start the server:
npm run start

Development

  1. Start the development server with hot-reloading:
npm run dev
  1. Run linting and formatting:
npm run lint
npm run format
  1. Run tests:
 npm test

Docker Deployment

  1. Build and run the application using Docker Compose
docker-compose -f docker-compose.yaml -f docker-compose.dev.yaml up --build
  1. For production:
docker-compose -f docker-compose.yaml -f docker-compose.prod.yaml up --build

Logging

Logs are managed using Winston and stored in the logs/ directory. Console logs are colorized for better readability in development.

Rate Limiting

Default rate limit: 100 requests per 5 minutes per IP. Configured using express-rate-limit with Redis for persistence.

Environment Variables

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

Data Model

ERD

Database Seeder

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.

Usage

  1. Ensure your environment variables are set correctly in the env/{NODE_ENV}.env file.
  2. Run the seeder with:
npm run seed
  1. 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.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Resource and Documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages