# nahiyanasir/vehicle-rental-system architecture

> Architecture diagram of the GitHub repository nahiyanasir/vehicle-rental-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nahiyanasir/vehicle-rental-system
- Repository: https://github.com/nahiyanasir/vehicle-rental-system

## Overview

This is an Express/PostgreSQL vehicle-rental API. Customers register or log in, browse vehicles, create bookings, and view or cancel their bookings; administrators manage vehicles, users, bookings, and roles. Controllers coordinate domain services, which query PostgreSQL; booking services also calculate rental totals and update vehicle availability. Route wiring and the database-pool implementation were not sampled, so those internal links are omitted where their ownership cannot be verified.

Main entry points: [`src/server.ts`](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/server.ts) (Express server), [`src/config/Db.ts`](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/config/Db.ts) (Database pool), [`src/modules/auth/authService.ts`](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/auth/authService.ts) (Auth service), [`src/modules/Bookings/bookingController.ts`](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Bookings/bookingController.ts) (Booking controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_server["Express server<br/>[server.ts]"]
  node_config["Configuration<br/>[index.ts]"]
  node_db_config["Database pool<br/>[Db.ts]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_identity["Identity and users"]
  node_auth_routes["Auth routes<br/>[authRoute.ts]"]
  node_auth_controller["Auth controller<br/>[authController.ts]"]
  node_auth_service["Auth service<br/>[authService.ts]"]
  node_auth_middleware["Role auth<br/>[auth.ts]"]
  node_user_routes["User routes<br/>[userRoute.ts]"]
  node_user_controller["User controller<br/>[userController.ts]"]
  node_user_service["User service<br/>[userService.ts]"]
  node_bcrypt["bcryptjs"]
  node_jwt["JWT"]
end

subgraph group_fleet["Fleet management"]
  node_vehicle_routes["Vehicle routes<br/>[vehicleRoute.ts]"]
  node_vehicle_controller["Vehicle controller"]
  node_vehicle_service["Vehicle service<br/>[vehicleService.ts]"]
end

subgraph group_rentals["Rental management"]
  node_booking_routes["Booking routes<br/>[bookingRoute.ts]"]
  node_booking_controller["Booking controller"]
  node_booking_service["Booking service<br/>[bookingService.ts]"]
  node_admin_service["Admin booking service<br/>[adminService.ts]"]
end

node_customer(("Customer"))
node_admin(("Administrator"))

node_customer -->|"sends requests"| node_server
node_admin -->|"sends requests"| node_server
node_server -->|"loads settings"| node_config
node_server -->|"mounts API"| node_auth_routes
node_server -->|"mounts API"| node_user_routes
node_server -->|"mounts API"| node_vehicle_routes
node_server -->|"mounts API"| node_booking_routes
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"hashes passwords"| node_bcrypt
node_auth_service -->|"signs tokens"| node_jwt
node_auth_middleware -->|"verifies tokens"| node_jwt
node_user_controller -->|"calls"| node_user_service
node_vehicle_controller -->|"calls"| node_vehicle_service
node_booking_controller -->|"calls"| node_booking_service
node_booking_controller -->|"loads admin bookings"| node_admin_service
node_auth_service -->|"queries users"| node_db_config
node_user_service -->|"queries users"| node_db_config
node_vehicle_service -->|"queries vehicles"| node_db_config
node_booking_service -->|"queries bookings, vehicles"| node_db_config
node_admin_service -->|"queries bookings"| node_db_config
node_db_config -->|"connects"| node_postgres

click node_server "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/server.ts"
click node_auth_routes "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/auth/authRoute.ts"
click node_auth_controller "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/auth/authController.ts"
click node_auth_service "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/auth/authService.ts"
click node_auth_middleware "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/middleware/auth.ts"
click node_user_routes "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/user/userRoute.ts"
click node_user_controller "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/user/userController.ts"
click node_user_service "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/user/userService.ts"
click node_vehicle_routes "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Vehicle/vehicleRoute.ts"
click node_vehicle_controller "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Vehicle/vehicleController.ts"
click node_vehicle_service "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Vehicle/vehicleService.ts"
click node_booking_routes "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Bookings/bookingRoute.ts"
click node_booking_controller "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Bookings/bookingController.ts"
click node_booking_service "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Bookings/bookingService.ts"
click node_admin_service "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/Admin/adminService.ts"
click node_config "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/config/index.ts"
click node_db_config "https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/config/Db.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_config,node_db_config,node_postgres toneBlue
class node_auth_routes,node_auth_controller,node_auth_service,node_auth_middleware,node_user_routes,node_user_controller,node_user_service,node_bcrypt,node_jwt toneAmber
class node_vehicle_routes,node_vehicle_controller,node_vehicle_service toneMint
class node_booking_routes,node_booking_controller,node_booking_service,node_admin_service toneRose
class node_customer,node_admin toneIndigo
```

## Components

### API entry

- [Express server](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/server.ts): `src/server.ts`
- [Configuration](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/config/index.ts): `src/config/index.ts`
- [Database pool](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/config/Db.ts): `src/config/Db.ts`
- **PostgreSQL**

### Identity and users

- [Auth routes](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/auth/authRoute.ts): `src/modules/auth/authRoute.ts`
- [Auth controller](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/auth/authController.ts): `src/modules/auth/authController.ts`
- [Auth service](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/auth/authService.ts): `src/modules/auth/authService.ts`
- [Role auth](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/middleware/auth.ts): `src/middleware/auth.ts`
- [User routes](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/user/userRoute.ts): `src/modules/user/userRoute.ts`
- [User controller](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/user/userController.ts): `src/modules/user/userController.ts`
- [User service](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/user/userService.ts): `src/modules/user/userService.ts`
- **bcryptjs**
- **JWT**

### Fleet management

- [Vehicle routes](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Vehicle/vehicleRoute.ts): `src/modules/Vehicle/vehicleRoute.ts`
- [Vehicle controller](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Vehicle/vehicleController.ts): `src/modules/Vehicle/vehicleController.ts`
- [Vehicle service](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Vehicle/vehicleService.ts): `src/modules/Vehicle/vehicleService.ts`

### Rental management

- [Booking routes](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Bookings/bookingRoute.ts): `src/modules/Bookings/bookingRoute.ts`
- [Booking controller](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Bookings/bookingController.ts): `src/modules/Bookings/bookingController.ts`
- [Booking service](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/modules/Bookings/bookingService.ts): `src/modules/Bookings/bookingService.ts`
- [Admin booking service](https://github.com/nahiyanasir/vehicle-rental-system/blob/main/src/Admin/adminService.ts): `src/Admin/adminService.ts`

### Other components

- **Customer**
- **Administrator**

## Connections

- Customer → Express server: sends requests
- Administrator → Express server: sends requests
- Express server → Configuration: loads settings
- Express server → Auth routes: mounts API
- Express server → User routes: mounts API
- Express server → Vehicle routes: mounts API
- Express server → Booking routes: mounts API
- Auth controller → Auth service: calls
- Auth service → bcryptjs: hashes passwords
- Auth service → JWT: signs tokens
- Role auth → JWT: verifies tokens
- User controller → User service: calls
- Vehicle controller → Vehicle service: calls
- Booking controller → Booking service: calls
- Booking controller → Admin booking service: loads admin bookings
- Auth service → Database pool: queries users
- User service → Database pool: queries users
- Vehicle service → Database pool: queries vehicles
- Booking service → Database pool: queries bookings, vehicles
- Admin booking service → Database pool: queries bookings
- Database pool → PostgreSQL: connects
