# patel-prince-246/vehicle_rental_marketplace architecture

> Architecture diagram of the GitHub repository patel-prince-246/vehicle_rental_marketplace, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/patel-prince-246/vehicle_rental_marketplace
- Repository: https://github.com/patel-prince-246/vehicle_rental_marketplace

## Overview

This is a MERN vehicle-rental marketplace for customers, individual owners, agencies, and platform administrators. The main customer journey is browse vehicles, inspect a listing, book it, complete payment and handover/return, then review the rental. Separate owner, agency, and admin dashboards support listing and verification workflows. The backend exposes role-protected REST routes, coordinates domain operations, and persists marketplace records in MongoDB. The graph combines sampled calls and imports with README-documented capabilities; some unsampled route and page internals are represented only at subsystem level.

Main entry points: [`frontend/src/App.jsx`](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/App.jsx) (Route application), [`backend/routes`](https://github.com/patel-prince-246/vehicle_rental_marketplace/tree/main/backend/routes) (REST route groups), [`backend/controllers/bookingController.js`](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/bookingController.js) (Booking lifecycle), [`backend/controllers/adminController.js`](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/adminController.js) (Administration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Marketplace frontend"]
  node_app["Route application<br/>[App.jsx]"]
  node_discovery["Vehicle discovery<br/>[Vehicles.jsx]"]
  node_vehicle_detail["Vehicle details<br/>[VehicleDetails.jsx]"]
  node_booking_ui["Booking flow<br/>[Booking.jsx]"]
  node_auth_ui["Login and registration<br/>[Login.jsx]"]
  node_auth_context["Session context<br/>[AuthContext.jsx]"]
  node_customer_dashboard["Customer dashboard"]
  node_host_dashboard["Host dashboards<br/>[OwnerDashboard.jsx]"]
  node_agency_dashboard["Agency dashboard"]
  node_admin_dashboard["Admin dashboard<br/>[AdminDashboard.jsx]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_domain["Rental operations"]
  node_routes["REST route groups"]
  node_users["Identity and roles<br/>[userController.js]"]
  node_vehicles["Vehicle listings"]
  node_bookings["Booking lifecycle"]
  node_payments["Payments and refunds"]
  node_reviews["Reviews and ratings"]
  node_admin_ops["Administration<br/>[adminController.js]"]
end

subgraph group_platform["Platform services"]
  node_notifications["Notifications"]
  node_email["Email delivery<br/>[emailService.js]"]
  node_auth_middleware["JWT and role checks<br/>[authMiddleware.js]"]
  node_server["API server<br/>[server.js]"]
end

subgraph group_data["Marketplace data"]
  node_mongo[("MongoDB<br/>[db.js]")]
  node_user_model[("User records<br/>[User.js]")]
  node_vehicle_model[("Vehicle records<br/>[Vehicle.js]")]
  node_booking_model[("Booking records<br/>[Booking.js]")]
  node_payment_model[("Payment records<br/>[Payment.js]")]
  node_review_model[("Review records<br/>[Review.js]")]
  node_host_models[("Owner and agency records<br/>[Owner.js]")]
end

node_customer(("Customer"))
node_host(("Owner or agency"))
node_admin(("Administrator"))

node_customer -->|"uses"| node_app
node_host -.->|"uses"| node_app
node_admin -.->|"uses"| node_app
node_app -->|"routes to"| node_discovery
node_app -->|"routes to"| node_vehicle_detail
node_app -->|"routes to"| node_booking_ui
node_app -->|"routes to"| node_auth_ui
node_app -->|"routes to"| node_customer_dashboard
node_app -->|"routes to"| node_host_dashboard
node_app -->|"routes to"| node_agency_dashboard
node_app -->|"routes to"| node_admin_dashboard
node_auth_ui -.->|"uses"| node_auth_context
node_auth_context -->|"calls"| node_api
node_agency_dashboard -->|"calls"| node_api
node_admin_dashboard -->|"calls"| node_api
node_discovery -.->|"requests listings"| node_api
node_booking_ui -.->|"submits booking"| node_api
node_api -.->|"HTTP requests"| node_server
node_server -->|"connects"| node_mongo
node_server -->|"mounts"| node_routes
node_routes -->|"protects routes"| node_auth_middleware
node_routes -->|"dispatches"| node_users
node_routes -->|"dispatches"| node_vehicles
node_routes -->|"dispatches"| node_bookings
node_routes -->|"dispatches"| node_payments
node_routes -->|"dispatches"| node_reviews
node_routes -->|"dispatches"| node_admin_ops
node_users -->|"reads and writes"| node_user_model
node_vehicles -->|"reads and writes"| node_vehicle_model
node_bookings -->|"reads and writes"| node_booking_model
node_bookings -->|"checks availability"| node_vehicle_model
node_bookings -->|"reads"| node_user_model
node_bookings -->|"resolves host"| node_host_models
node_bookings -->|"updates refunds"| node_payment_model
node_payments -->|"reads and writes"| node_payment_model
node_reviews -->|"reads and writes"| node_review_model
node_reviews -->|"checks completion"| node_booking_model
node_reviews -->|"checks vehicle"| node_vehicle_model
node_admin_ops -->|"manages users"| node_user_model
node_admin_ops -->|"verifies listings"| node_vehicle_model
node_admin_ops -->|"manages bookings"| node_booking_model
node_admin_ops -->|"manages payments"| node_payment_model
node_admin_ops -->|"manages reviews"| node_review_model
node_admin_ops -->|"verifies hosts"| node_host_models
node_bookings -->|"sends booking mail"| node_email
node_bookings -->|"notifies users"| node_notifications
node_reviews -->|"notifies on review"| node_notifications
node_admin_ops -->|"sends notices"| node_notifications

click node_app "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/App.jsx"
click node_discovery "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/Vehicles.jsx"
click node_vehicle_detail "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/VehicleDetails.jsx"
click node_booking_ui "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/Booking.jsx"
click node_auth_ui "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/Login.jsx"
click node_auth_context "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/context/AuthContext.jsx"
click node_customer_dashboard "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/CustomerDashboard.jsx"
click node_host_dashboard "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/OwnerDashboard.jsx"
click node_agency_dashboard "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/AgencyDashboard.jsx"
click node_admin_dashboard "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/AdminDashboard.jsx"
click node_api "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/services/api.js"
click node_routes "https://github.com/patel-prince-246/vehicle_rental_marketplace/tree/main/backend/routes"
click node_users "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/userController.js"
click node_vehicles "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/vehicleController.js"
click node_bookings "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/bookingController.js"
click node_payments "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/paymentController.js"
click node_reviews "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/reviewController.js"
click node_admin_ops "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/adminController.js"
click node_notifications "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/utils/notificationService.js"
click node_email "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/services/emailService.js"
click node_auth_middleware "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/middleware/authMiddleware.js"
click node_server "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/server.js"
click node_mongo "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/config/db.js"
click node_user_model "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/User.js"
click node_vehicle_model "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/Vehicle.js"
click node_booking_model "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/Booking.js"
click node_payment_model "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/Payment.js"
click node_review_model "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/Review.js"
click node_host_models "https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/Owner.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_app,node_discovery,node_vehicle_detail,node_booking_ui,node_auth_ui,node_auth_context,node_customer_dashboard,node_host_dashboard,node_agency_dashboard,node_admin_dashboard,node_api toneBlue
class node_routes,node_users,node_vehicles,node_bookings,node_payments,node_reviews,node_admin_ops toneAmber
class node_notifications,node_email,node_auth_middleware,node_server toneMint
class node_mongo,node_user_model,node_vehicle_model,node_booking_model,node_payment_model,node_review_model,node_host_models toneRose
class node_customer,node_host,node_admin toneIndigo
```

## Components

### Marketplace frontend

- [Route application](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Vehicle discovery](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/Vehicles.jsx): `frontend/src/pages/Vehicles.jsx`
- [Vehicle details](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/VehicleDetails.jsx): `frontend/src/pages/VehicleDetails.jsx`
- [Booking flow](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/Booking.jsx): `frontend/src/pages/Booking.jsx`
- [Login and registration](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Session context](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Customer dashboard](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/CustomerDashboard.jsx): `frontend/src/pages/CustomerDashboard.jsx`
- [Host dashboards](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/OwnerDashboard.jsx): `frontend/src/pages/OwnerDashboard.jsx`
- [Agency dashboard](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/AgencyDashboard.jsx): `frontend/src/pages/AgencyDashboard.jsx`
- [Admin dashboard](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/pages/AdminDashboard.jsx): `frontend/src/pages/AdminDashboard.jsx`
- [API client](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Rental operations

- [REST route groups](https://github.com/patel-prince-246/vehicle_rental_marketplace/tree/main/backend/routes): `backend/routes`
- [Identity and roles](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/userController.js): `backend/controllers/userController.js`
- [Vehicle listings](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/vehicleController.js): `backend/controllers/vehicleController.js`
- [Booking lifecycle](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/bookingController.js): `backend/controllers/bookingController.js`
- [Payments and refunds](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/paymentController.js): `backend/controllers/paymentController.js`
- [Reviews and ratings](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/reviewController.js): `backend/controllers/reviewController.js`
- [Administration](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/controllers/adminController.js): `backend/controllers/adminController.js`

### Platform services

- [Notifications](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/utils/notificationService.js): `backend/utils/notificationService.js`
- [Email delivery](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/services/emailService.js): `backend/services/emailService.js`
- [JWT and role checks](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`
- [API server](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/server.js): `backend/server.js`

### Marketplace data

- [MongoDB](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/config/db.js): `backend/config/db.js`
- [User records](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/User.js): `backend/models/User.js`
- [Vehicle records](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/Vehicle.js): `backend/models/Vehicle.js`
- [Booking records](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/Booking.js): `backend/models/Booking.js`
- [Payment records](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/Payment.js): `backend/models/Payment.js`
- [Review records](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/Review.js): `backend/models/Review.js`
- [Owner and agency records](https://github.com/patel-prince-246/vehicle_rental_marketplace/blob/main/backend/models/Owner.js): `backend/models/Owner.js`

### Other components

- **Customer**
- **Owner or agency**
- **Administrator**

## Connections

- Customer → Route application: uses (evidence: `frontend/src/App.jsx`)
- Owner or agency → Route application: uses
- Administrator → Route application: uses
- Route application → Vehicle discovery: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Vehicle details: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Booking flow: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Login and registration: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Customer dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Host dashboards: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Agency dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Admin dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Login and registration → Session context: uses
- Session context → API client: calls (evidence: `frontend/src/context/AuthContext.jsx`)
- Agency dashboard → API client: calls (evidence: `frontend/src/pages/AgencyDashboard.jsx`)
- Admin dashboard → API client: calls (evidence: `frontend/src/pages/AdminDashboard.jsx`)
- Vehicle discovery → API client: requests listings
- Booking flow → API client: submits booking
- API client → API server: HTTP requests
- API server → MongoDB: connects (evidence: `backend/server.js`)
- API server → REST route groups: mounts (evidence: `backend/server.js`)
- REST route groups → JWT and role checks: protects routes (evidence: `backend/routes/bookingRoutes.js`)
- REST route groups → Identity and roles: dispatches (evidence: `backend/routes/userRoutes.js`)
- REST route groups → Vehicle listings: dispatches (evidence: `backend/routes/vehicleRoutes.js`)
- REST route groups → Booking lifecycle: dispatches (evidence: `backend/routes/bookingRoutes.js`)
- REST route groups → Payments and refunds: dispatches (evidence: `backend/routes/paymentRoutes.js`)
- REST route groups → Reviews and ratings: dispatches (evidence: `backend/routes/reviewRoutes.js`)
- REST route groups → Administration: dispatches (evidence: `backend/routes/adminRoutes.js`)
- Identity and roles → User records: reads and writes (evidence: `backend/controllers/userController.js`)
- Vehicle listings → Vehicle records: reads and writes (evidence: `backend/controllers/vehicleController.js`)
- Booking lifecycle → Booking records: reads and writes (evidence: `backend/controllers/bookingController.js`)
- Booking lifecycle → Vehicle records: checks availability (evidence: `backend/controllers/bookingController.js`)
- Booking lifecycle → User records: reads (evidence: `backend/controllers/bookingController.js`)
- Booking lifecycle → Owner and agency records: resolves host (evidence: `backend/controllers/bookingController.js`)
- Booking lifecycle → Payment records: updates refunds (evidence: `backend/controllers/bookingController.js`)
- Payments and refunds → Payment records: reads and writes (evidence: `backend/controllers/paymentController.js`)
- Reviews and ratings → Review records: reads and writes (evidence: `backend/controllers/reviewController.js`)
- Reviews and ratings → Booking records: checks completion (evidence: `backend/controllers/reviewController.js`)
- Reviews and ratings → Vehicle records: checks vehicle (evidence: `backend/controllers/reviewController.js`)
- Administration → User records: manages users (evidence: `backend/controllers/adminController.js`)
- Administration → Vehicle records: verifies listings (evidence: `backend/controllers/adminController.js`)
- Administration → Booking records: manages bookings (evidence: `backend/controllers/adminController.js`)
- Administration → Payment records: manages payments (evidence: `backend/controllers/adminController.js`)
- Administration → Review records: manages reviews (evidence: `backend/controllers/adminController.js`)
- Administration → Owner and agency records: verifies hosts (evidence: `backend/controllers/adminController.js`)
- Booking lifecycle → Email delivery: sends booking mail (evidence: `backend/controllers/bookingController.js`)
- Booking lifecycle → Notifications: notifies users (evidence: `backend/controllers/bookingController.js`)
- Reviews and ratings → Notifications: notifies on review (evidence: `backend/controllers/reviewController.js`)
- Administration → Notifications: sends notices (evidence: `backend/controllers/adminController.js`)
