# subrata-2002/vehicle-rental-system architecture

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

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

## Overview

1. **Repository shape**
   - This is a classic two-tier vehicle rental application with a **React client** in `ClientSide/` and an **Express/MongoDB backend** in `ServerSide/`.
   - The main domain objects are **users, admins, cars, bookings/orders, and payments**.

2. **Client application boundary**
   - The client is a single-page app built from `src/index.js` and `src/App.js`, with route composition in `src/AppRouter.js`.
   - `public/index.html` and `manifest.json` indicate a standard browser SPA deployment model rather than server-side rendering.

3. **User-facing flow**
   - The user experience is organized around browsing cars, filtering results, making bookings, and handling order/payment steps.
   - Relevant modules include `src/Components/Home.js`, `Header.js`, `Navigation.js`, `Cards.js`, `FilterHeader.js`, `Map.js`, and booking-related pages under `src/Booking/` such as `OrderPage.js`, `Page3.js`, and `ExistBookings.js`.

4. **Authentication and role split on the client**
   - The UI has separate entry points for **user** and **admin** authentication:
     - `src/User/UserLogin.js`, `UserSign.js`
     - `src/Admin/AdminLogin.js`, `AdminSign.js`
   - This suggests role-specific routing and access control in the frontend, with different post-login experiences for each role.

5. **Admin management flow**
   - Administrative car management lives under `src/Components/AdminpageAllDetail/`.
   - The core admin screens are `AdminPage.js`, `AddCarDetails.js`, `EditCarDetails.js`, and `FormStructure.js`, with admin navigation in `AdminpageNav.js`.
   - This part of the UI likely drives CRUD operations over the vehicle inventory and related metadata.

6. **Payments and booking state**
   - Payment-related client code is grouped under `src/Components/Payent/` with `Payment.js`, `PaymentCard.js`, and `EditPaymentDetails.js`.
   - Booking state appears to be shared across pages via `src/Context/CarContext.js`, which likely carries selected car, filters, and booking details across the multi-step flow.
   - The client also contains utility wrappers in `src/Utils/ApiUtilAdmin.js`, `ApiUtilUser.js`, and `ApiUtils.js`, indicating a separate API abstraction layer for role-specific calls.

7. **Backend API surface**
   - The server is an Express app rooted at `src/app.js`, with routes split by domain:
     - `router/UserRouts.js`
     - `router/AdminRouter.js`
     - `router/CarRouts.js`
     - `router/OrderRouter.js`
     - `router/Newbooking.js`
     - `router/booking.js`
     - `router/MapRoute.js`
   - Controllers mirror those routes in `src/Controllers/`, which keeps request handling separated by business area.

8. **Data model layer**
   - MongoDB persistence is modeled through Mongoose schemas in `src/model/`:
     - `UserSchema.js`
     - `AdminSchema.js`
     - `CarSchema.js`
     - `PlacedOrdersSchema.js`
   - This makes the main persisted entities explicit: authenticated principals, inventory records, and booking/order records.

9. **Authentication and request validation**
   - `GernerateToken.js` suggests token-based authentication for login/session handling.
   - `ValidateID.js` indicates custom ID validation, likely used to protect update/delete/order operations against invalid or malformed resource references.
   - The presence of distinct admin/user schemas implies authorization is role-aware, not just generic login.

10. **Database and infrastructure**
    - `src/db/connection.js` is the database integration point, and the rest of the server depends on it for persistence.
    - The app structure strongly suggests MongoDB as the primary datastore, with the backend acting as the API layer between the SPA and the database.

11. **External/auxiliary services**
    - `src/Components/Map.js` and `src/router/MapRoute.js` imply a mapping/location feature; the exact provider is not shown, but map rendering is a distinct subsystem from booking/payment.
    - No other third-party infrastructure is obvious from the tree, so the main architectural dependencies appear to be the browser, the Node/Express API, and the database.

12. **End-to-end data flow**
    - The typical flow is: **React UI → role-specific API utility → Express route → controller → Mongoose model → MongoDB**, then responses return to the UI for rendering and state updates.
    - Booking and payment are multi-step flows on the client, while inventory/admin operations are CRUD-style flows backed by the same API and schema layer.

Main entry points: [`ClientSide/src/AppRouter.js`](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/AppRouter.js) (Routes), [`ServerSide/src/app.js`](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/app.js) (Express app), [`ServerSide/src/db/connection.js`](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/db/connection.js) (Database link), [`ServerSide/src/Controllers/UserController.js`](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/Controllers/UserController.js) (User controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client SPA"]
  node_client_entry["App shell<br/>react-entry<br/>[index.js]"]
  node_client_router["Routes<br/>react-router<br/>[AppRouter.js]"]
  node_client_home["Home UI<br/>screen<br/>[Home.js]"]
  node_client_booking["Booking flow<br/>[OrderPage.js]"]
  node_client_payment["Payments<br/>flow<br/>[Payment.js]"]
  node_client_auth_user["User auth<br/>auth-ui<br/>[UserLogin.js]"]
  node_client_auth_admin["Admin auth<br/>auth-ui<br/>[AdminLogin.js]"]
  node_client_admin_panel["Admin panel<br/>admin-ui<br/>[AdminPage.js]"]
  node_client_search["Browse and filter<br/>catalog-ui<br/>[Cards.js]"]
  node_client_context(("Shared state<br/>react-context<br/>[CarContext.js]"))
  node_client_api_user["User API<br/>api-client<br/>[ApiUtilUser.js]"]
  node_client_api_admin["Admin API<br/>api-client<br/>[ApiUtilAdmin.js]"]
end

subgraph group_server["Server API"]
  node_server_app["Express app<br/>server-entry<br/>[app.js]"]
  node_server_user_routes["User routes<br/>router<br/>[UserRouts.js]"]
  node_server_admin_routes["Admin routes<br/>router<br/>[AdminRouter.js]"]
  node_server_car_routes["Car routes<br/>router<br/>[CarRouts.js]"]
  node_server_order_routes["Order routes<br/>router<br/>[OrderRouter.js]"]
  node_server_user_ctrl["User controller<br/>[UserController.js]"]
  node_server_admin_ctrl["Admin controller<br/>[AdminController.js]"]
  node_server_car_ctrl["Car controller<br/>[CarController.js]"]
  node_server_order_ctrl["Order controller<br/>[OrderController.js]"]
  node_server_auth{{"Token auth<br/>auth-helper<br/>[GernerateToken.js]"}}
  node_server_validate{{"ID validation<br/>[ValidateID.js]"}}
end

subgraph group_data["Persistence"]
  node_server_db[("Database link<br/>db-connection<br/>[connection.js]")]
  node_model_user[("Users<br/>mongoose-model<br/>[UserSchema.js]")]
  node_model_admin[("Admins<br/>mongoose-model<br/>[AdminSchema.js]")]
  node_model_car[("Cars<br/>mongoose-model<br/>[CarSchema.js]")]
  node_model_orders[("Orders<br/>mongoose-model")]
end

node_client_entry -->|"mounts"| node_client_router
node_client_router -->|"routes to"| node_client_home
node_client_router -->|"routes to"| node_client_booking
node_client_router -->|"routes to"| node_client_payment
node_client_router -->|"routes to"| node_client_auth_user
node_client_router -->|"routes to"| node_client_auth_admin
node_client_router -->|"routes to"| node_client_admin_panel
node_client_home -->|"uses"| node_client_search
node_client_booking -->|"reads/writes"| node_client_context
node_client_payment -->|"reads/writes"| node_client_context
node_client_auth_user -->|"calls"| node_client_api_user
node_client_auth_admin -->|"calls"| node_client_api_admin
node_client_admin_panel -->|"calls"| node_client_api_admin
node_client_search -->|"calls"| node_client_api_user
node_client_api_user -->|"HTTP"| node_server_app
node_client_api_admin -->|"HTTP"| node_server_app
node_server_app -->|"mounts"| node_server_user_routes
node_server_app -->|"mounts"| node_server_admin_routes
node_server_app -->|"mounts"| node_server_car_routes
node_server_app -->|"mounts"| node_server_order_routes
node_server_user_routes -->|"delegates"| node_server_user_ctrl
node_server_admin_routes -->|"delegates"| node_server_admin_ctrl
node_server_car_routes -->|"delegates"| node_server_car_ctrl
node_server_order_routes -->|"delegates"| node_server_order_ctrl
node_server_user_ctrl -->|"uses"| node_server_auth
node_server_admin_ctrl -->|"uses"| node_server_auth
node_server_car_ctrl -->|"uses"| node_server_validate
node_server_order_ctrl -->|"uses"| node_server_validate
node_server_user_ctrl -->|"reads/writes"| node_model_user
node_server_admin_ctrl -->|"reads/writes"| node_model_admin
node_server_car_ctrl -->|"reads/writes"| node_model_car
node_server_order_ctrl -->|"reads/writes"| node_model_orders
node_model_user -->|"uses"| node_server_db
node_model_admin -->|"uses"| node_server_db
node_model_car -->|"uses"| node_server_db
node_model_orders -->|"uses"| node_server_db

click node_client_entry "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/index.js"
click node_client_router "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/AppRouter.js"
click node_client_home "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Components/Home.js"
click node_client_booking "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Booking/OrderPage.js"
click node_client_payment "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Components/Payent/Payment.js"
click node_client_auth_user "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/User/UserLogin.js"
click node_client_auth_admin "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Admin/AdminLogin.js"
click node_client_admin_panel "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Components/AdminpageAllDetail/AdminPage.js"
click node_client_search "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Booking/Cards.js"
click node_client_context "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Context/CarContext.js"
click node_client_api_user "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Utils/ApiUtilUser.js"
click node_client_api_admin "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Utils/ApiUtilAdmin.js"
click node_server_app "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/app.js"
click node_server_user_routes "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/router/UserRouts.js"
click node_server_admin_routes "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/router/AdminRouter.js"
click node_server_car_routes "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/router/CarRouts.js"
click node_server_order_routes "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/router/OrderRouter.js"
click node_server_user_ctrl "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/Controllers/UserController.js"
click node_server_admin_ctrl "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/Controllers/AdminController.js"
click node_server_car_ctrl "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/Controllers/CarController.js"
click node_server_order_ctrl "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/Controllers/OrderController.js"
click node_server_auth "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/GernerateToken.js"
click node_server_validate "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/ValidateID.js"
click node_server_db "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/db/connection.js"
click node_model_user "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/model/UserSchema.js"
click node_model_admin "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/model/AdminSchema.js"
click node_model_car "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/model/CarSchema.js"
click node_model_orders "https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/model/PlacedOrdersSchema.js"

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_client_entry,node_client_router,node_client_home,node_client_booking,node_client_payment,node_client_auth_user,node_client_auth_admin,node_client_admin_panel,node_client_search,node_client_context,node_client_api_user,node_client_api_admin toneBlue
class node_server_app,node_server_user_routes,node_server_admin_routes,node_server_car_routes,node_server_order_routes,node_server_user_ctrl,node_server_admin_ctrl,node_server_car_ctrl,node_server_order_ctrl,node_server_auth,node_server_validate toneAmber
class node_server_db,node_model_user,node_model_admin,node_model_car,node_model_orders toneMint
```

## Components

### Client SPA

React single-page application for user and admin flows

- [App shell](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/index.js): react-entry · SPA bootstrap and root composition · `ClientSide/src/index.js`
- [Routes](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/AppRouter.js): react-router · Top-level client route composition · `ClientSide/src/AppRouter.js`
- [Home UI](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Components/Home.js): screen · Main browsing experience and landing flow · `ClientSide/src/Components/Home.js`
- [Booking flow](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Booking/OrderPage.js): flow · Multi-step booking and order screens · `ClientSide/src/Booking/OrderPage.js`
- [Payments](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Components/Payent/Payment.js): flow · Payment entry and edit screens · `ClientSide/src/Components/Payent/Payment.js`
- [User auth](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/User/UserLogin.js): auth-ui · User login and signup entry points · `ClientSide/src/User/UserLogin.js`
- [Admin auth](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Admin/AdminLogin.js): auth-ui · Admin login and signup entry points · `ClientSide/src/Admin/AdminLogin.js`
- [Admin panel](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Components/AdminpageAllDetail/AdminPage.js): admin-ui · Inventory management screens for admins · `ClientSide/src/Components/AdminpageAllDetail/AdminPage.js`
- [Browse and filter](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Booking/Cards.js): catalog-ui · Cards, filters, and map-based discovery · `ClientSide/src/Booking/Cards.js`
- [Shared state](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Context/CarContext.js): react-context · Cross-page booking and selection state · `ClientSide/src/Context/CarContext.js`
- [User API](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Utils/ApiUtilUser.js): api-client · Client-side wrapper for user-facing backend calls · `ClientSide/src/Utils/ApiUtilUser.js`
- [Admin API](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ClientSide/src/Utils/ApiUtilAdmin.js): api-client · Client-side wrapper for admin/backend management calls · `ClientSide/src/Utils/ApiUtilAdmin.js`

### Server API

Express backend with routes, controllers, auth, and persistence

- [Express app](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/app.js): server-entry · Backend application bootstrap · `ServerSide/src/app.js`
- [User routes](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/router/UserRouts.js): router · User authentication and user-facing endpoints · `ServerSide/src/router/UserRouts.js`
- [Admin routes](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/router/AdminRouter.js): router · Admin authentication and admin management endpoints · `ServerSide/src/router/AdminRouter.js`
- [Car routes](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/router/CarRouts.js): router · Vehicle inventory endpoints · `ServerSide/src/router/CarRouts.js`
- [Order routes](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/router/OrderRouter.js): router · Booking and order endpoints · `ServerSide/src/router/OrderRouter.js`
- [User controller](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/Controllers/UserController.js): controller · User account and auth request handling · `ServerSide/src/Controllers/UserController.js`
- [Admin controller](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/Controllers/AdminController.js): controller · Admin account and inventory management handling · `ServerSide/src/Controllers/AdminController.js`
- [Car controller](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/Controllers/CarController.js): controller · Vehicle lookup and CRUD request handling · `ServerSide/src/Controllers/CarController.js`
- [Order controller](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/Controllers/OrderController.js): controller · Booking, order, and payment related handling · `ServerSide/src/Controllers/OrderController.js`
- [Token auth](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/GernerateToken.js): auth-helper · Token generation and validation support · `ServerSide/src/GernerateToken.js`
- [ID validation](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/ValidateID.js): validation · Resource ID checking for protected operations · `ServerSide/src/ValidateID.js`

### Persistence

MongoDB models and database connection

- [Database link](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/db/connection.js): db-connection · MongoDB connection setup · `ServerSide/src/db/connection.js`
- [Users](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/model/UserSchema.js): mongoose-model · Persisted user accounts · `ServerSide/src/model/UserSchema.js`
- [Admins](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/model/AdminSchema.js): mongoose-model · Persisted admin accounts · `ServerSide/src/model/AdminSchema.js`
- [Cars](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/model/CarSchema.js): mongoose-model · Persisted vehicle inventory · `ServerSide/src/model/CarSchema.js`
- [Orders](https://github.com/subrata-2002/vehicle-rental-system/blob/main/ServerSide/src/model/PlacedOrdersSchema.js): mongoose-model · Persisted bookings and placed orders · `ServerSide/src/model/PlacedOrdersSchema.js`

## Connections

- App shell → Routes: mounts · Bootstraps the SPA and hands off to routing
- Routes → Home UI: routes to · Composes the browsing and landing experience
- Routes → Booking flow: routes to · Composes booking and order screens
- Routes → Payments: routes to · Composes payment screens
- Routes → User auth: routes to · Exposes user auth entry points
- Routes → Admin auth: routes to · Exposes admin auth entry points
- Routes → Admin panel: routes to · Exposes admin inventory management
- Home UI → Browse and filter: uses · Home assembles browse/filter/map components
- Booking flow → Shared state: reads/writes · Shares selected car and booking state across steps
- Payments → Shared state: reads/writes · Shares payment and booking state across steps
- User auth → User API: calls · Uses user-facing API wrapper
- Admin auth → Admin API: calls · Uses admin-facing API wrapper
- Admin panel → Admin API: calls · Performs admin CRUD operations through API wrapper
- Browse and filter → User API: calls · Fetches inventory and booking data
- User API → Express app: HTTP · User client talks to backend API
- Admin API → Express app: HTTP · Admin client talks to backend API
- Express app → User routes: mounts · Registers user-related routes
- Express app → Admin routes: mounts · Registers admin-related routes
- Express app → Car routes: mounts · Registers vehicle routes
- Express app → Order routes: mounts · Registers booking and order routes
- User routes → User controller: delegates · Route handlers forward to user controller
- Admin routes → Admin controller: delegates · Route handlers forward to admin controller
- Car routes → Car controller: delegates · Route handlers forward to car controller
- Order routes → Order controller: delegates · Route handlers forward to order controller
- User controller → Token auth: uses · Auth helper supports login/session flows
- Admin controller → Token auth: uses · Auth helper supports role-aware login/session flows
- Car controller → ID validation: uses · Validates resource identifiers on CRUD operations
- Order controller → ID validation: uses · Validates order and booking identifiers
- User controller → Users: reads/writes · Persists user accounts
- Admin controller → Admins: reads/writes · Persists admin accounts
- Car controller → Cars: reads/writes · Persists vehicle inventory
- Order controller → Orders: reads/writes · Persists bookings and placed orders
- Users → Database link: uses · Mongoose models depend on the database connection
- Admins → Database link: uses · Mongoose models depend on the database connection
- Cars → Database link: uses · Mongoose models depend on the database connection
- Orders → Database link: uses · Mongoose models depend on the database connection
