Skip to content

A advanced car rental platform built with NestJS, featuring microservices architecture, real-time processing, and advanced security features.

Notifications You must be signed in to change notification settings

Moemen12/car-rental-system

Repository files navigation

πŸš— Advanced Car Rental System

A advanced car rental platform built with NestJS, featuring microservices architecture, real-time processing, and advanced security features.

🌟 Key Features

  • Microservice Architecture with API Gateway
  • Role-Based Access Control (RBAC)
  • Advanced Car Search with Algolia Integration
  • Real-time Payment Processing with Stripe
  • Automated Document Verification (Driver's License) using Tesseract.js
  • Automated Email Notifications
  • Rate Limiting and Security Features
  • Response Compression
  • Redis Caching
  • Message Queue System (RabbitMQ)
  • Comprehensive Error Tracking

πŸ› οΈ Tech Stack

  • Backend Framework: NestJS
  • Database: MongoDB
  • Caching: Redis
  • Message Broker: RabbitMQ
  • Search Engine: Algolia
  • Payment Processing: Stripe
  • File Upload: UploadThing
  • OCR Processing: Tesseract.js
  • Email Service: Gmail SMTP
  • Development: MonoRepo Architecture

πŸ“‹ API Endpoints

Authentication

Method Endpoint Description
POST /api/auth/login User authentication
POST /api/auth/register User registration

User Management

Method Endpoint Description
GET /api/users/:id/profile Get user profile
PATCH /api/users/:id/profile Update user profile
DELETE /api/users/:id Delete user account

Car Management

Method Endpoint Description
POST /api/cars Add new car
GET /api/cars/search Search cars
PATCH /api/cars/:id/status Update car status

Rental Management

Method Endpoint Description
POST /api/rentals Create rental
GET /api/rentals/payment-confirmation/:id Get payment confirmation
GET /api/rentals/active Get active rentals

πŸ—οΈ Project Structure

car-rental-system/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api-gateway/
β”‚   β”œβ”€β”€ user-service/
β”‚   β”œβ”€β”€ car-service/
β”‚   └── rental-service/
|   └── email-service/
└── libs/
    └── common/
    └── database/

πŸ“§ Automated Emails

The system sends automated emails for:

  • Welcome messages
  • Payment confirmations
  • Rental invoices
Payment Confirmation Invoice Welcome Email
Payment Confirmation Email Invoice Email Welcome Email

βš™οΈ Environment Variables

# Debug Mode
DEBUG_MODE=true  # Enable to see expected/unexpected errors in console

# Application
APP_URL=http://localhost:3000/api

# Database
MONGODB_URI=mongodb://localhost:27017/car-rental-users

# Message Queue
RABBITMQ_URL=amqp://localhost:5672
USER_EMAIL_QUEUE_NAME=user_email_queue
USER_EMAIL_QUEUE_TTL=1  # Welcome Email (in days)
RENTAL_EMAIL_QUEUE_NAME=rental_email_queue
RENTAL_EMAIL_QUEUE_TTL=60  # Payment confirmation queue (in seconds)

# Redis Cache
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_TTL=5  # Caching time in minutes

# JWT Configuration
# Generate using: openssl rand -base64 64
JWT_SECRET_KEY=your_jwt_secret_here

# Encryption
# Generate using: openssl rand -hex 32
ENCRYPTION_KEY=your_encryption_key_here

# Email Configuration
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=465
USER_EMAIL=your_email@gmail.com
EMAIL_PASSWORD=your_app_specific_password

# Rate Limiting
THROTTLER_TTL=60  # Time window in seconds
THROTTLER_LIMIT=30  # Maximum requests within TTL
THROTTLER_BLOCK_DURATION=300  # Block duration in seconds

# Third-Party Services
ALGOLIA_APP_ID=your_algolia_app_id
ALGOLIA_API_KEY=your_algolia_api_key
STRIPE_API_KEY=your_stripe_api_key
UPLOADTHING_TOKEN=your_uploadthing_token

# Microservices
USER_SERVICE_HOST=localhost
USER_SERVICE_PORT=1111
CAR_SERVICE_HOST=localhost
CAR_SERVICE_PORT=3434
RENT_SERVICE_HOST=localhost
RENT_SERVICE_PORT=3666

πŸš€ Getting Started

Prerequisites

  • Node.js
  • MongoDB
  • Redis
  • RabbitMQ
  • Gmail Account (for email notifications)

Installation and Setup

  1. Clone the repository
  2. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env
# Update the .env file with your configurations
  1. Start the development server:
npm run dev:all

πŸ” Debug Mode

When DEBUG_MODE=true, the system provides detailed error logging with color-coded console outputs:

  • πŸ”΄ Microservice Exceptions (Red)
  • πŸ”΅ RPC Exceptions (Blue)

πŸ”’ Security Features

  • JWT Authentication
  • Role-Based Access Control
  • Request Rate Limiting
  • Response Compression
  • Encrypted Sensitive Data

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A advanced car rental platform built with NestJS, featuring microservices architecture, real-time processing, and advanced security features.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published