Skip to content

Mirian97/car-reservation-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

258 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Car Reservation System

A full-stack car reservation system built with NestJS (backend) and Angular (frontend), featuring user authentication, car management, and reservation functionality.

πŸš€ Features

Backend (NestJS)

  • Authentication & Authorization: JWT-based authentication with role-based access control
  • User Management: User registration, login, and profile management
  • Car Management: CRUD operations for car inventory with filtering capabilities
  • Reservation System: Car reservation and release functionality
  • Database: MongoDB with Mongoose ODM
  • Security: Password hashing with bcrypt, CORS enabled
  • Validation: Class-validator for request validation

Frontend (Angular)

  • Modern UI: Built with Angular 18 and Tailwind CSS
  • Responsive Design: Mobile-first approach with modern UX
  • Authentication: Login and registration forms with guards
  • Car Browsing: Search and filter cars by various criteria
  • Reservation Management: View and manage car reservations
  • Admin Panel: Administrative interface for car management
  • SSR Support: Server-side rendering capabilities

πŸ› οΈ Tech Stack

Backend

  • Framework: NestJS 11.x
  • Database: MongoDB with Mongoose
  • Authentication: JWT with Passport
  • Validation: class-validator, class-transformer
  • Security: bcrypt for password hashing
  • Runtime: Node.js 24 (Alpine)

Frontend

  • Framework: Angular 18.x
  • Styling: Tailwind CSS 4.x
  • HTTP Client: Angular HttpClient with interceptors
  • State Management: Angular services
  • Build Tool: Angular CLI
  • SSR: Angular Universal

Development Tools

  • Package Manager: pnpm
  • Linting: ESLint with Prettier
  • Containerization: Docker & Docker Compose

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • pnpm (recommended) or npm
  • MongoDB (local or cloud)
  • Docker & Docker Compose (optional)

Environment Setup

  1. Clone the repository

    git clone https://github.com/Mirian97/car-reservation-system.git
    cd car-reservation-system
  2. Backend Setup

    cd server
    pnpm install
  3. Frontend Setup

    cd ../web
    pnpm install
  4. Environment Variables

    Create a .env file in the server directory:

    # If you are running on Docker Compose, use:
    MONGODB_URI=mongodb://mongodb:27017/car-reservation
    
    # If you are running locally (without Docker), use:
    # MONGODB_URI=mongodb://localhost:27017/car-reservation
    
    JWT_SECRET=your-jwt-secret-key
    JWT_EXPIRES=7d
    PORT=3000

Running the Application

Option 1: Docker Compose (Recommended)

# From the project root
cd server
docker-compose up -d

This will start:

  • MongoDB on port 27017
  • NestJS API on port 3005

Option 2: Manual Setup

Backend:

cd server
pnpm run start:dev

Frontend:

cd web
pnpm start

Database: Make sure MongoDB is running locally or update the MONGODB_URI in your environment variables.

Accessing the Application

πŸ“š API Documentation

Authentication Endpoints

  • POST /auth/login - User login
  • POST /auth/register - User registration
  • PUT /auth/edit/:id - Update user profile

Car Management

  • GET /cars - Get all available cars
  • POST /cars - Create new car (Admin only)
  • PUT /cars/:id - Update car (Admin only)
  • DELETE /cars/:id - Delete car (Admin only)

Reservations

  • GET /reservations - Get all reservations
  • GET /reservations/user/:userId - Get user's reservations
  • POST /reservations - Create new reservation
  • PUT /reservations/:id - Update reservation
  • DELETE /reservations/:id - Cancel reservation

🎯 Key Features Explained

User Roles

  • User: Can browse cars, make reservations, view their profile
  • Admin: Full access to car management and all reservations

Car Filtering

Cars can be filtered by:

  • Name (text search)
  • Type (Sedan, SUV, CoupΓ©, etc.)
  • Engine size
  • Vehicle size (passenger capacity)

Reservation Logic

  • Users can only have one active reservation at a time
  • Cars can only be reserved by one user at a time
  • Reservations can be cancelled, which releases the car

Security Features

  • JWT tokens for authentication
  • Password hashing with bcrypt
  • Role-based access control
  • Input validation and sanitization
  • CORS protection

πŸš€ Deployment

Production Build

Backend:

cd server
pnpm run build
pnpm run start:prod

Frontend:

cd web
pnpm run build

πŸ“ Sample Data

The project includes sample car data in assets/carros.json with various car types including:

  • Sedans (Compact, Medium, Large)
  • SUVs and Crossovers
  • Pickup trucks
  • Utility vehicles
  • Sports cars (CoupΓ©)

Built with ❀️ using NestJS and Angular

About

A full-stack Car Reservation Platform πŸš— πŸš™ built with Nest.js (backend) and Angular (frontend). It provides user authentication, car management, and a complete reservation workflow with role-based access control.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors