# omwanere/car_rental_service architecture

> Architecture diagram of the GitHub repository omwanere/car_rental_service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/omwanere/car_rental_service
- Repository: https://github.com/omwanere/car_rental_service

## Overview

##### Project type and purpose
- This is a full-stack web application called “Car Rental Management System.”
- Purpose: allow users to browse cars, make bookings, process payments, and manage rentals via an admin dashboard.

##### File structure
Top-level directories:
- Backend/ – Node.js + Express.js REST API
– controllers/ – request handlers per domain (auth, booking, listing, payment, user)
– routes/ – express routers matching controllers
– models/ – Mongoose schemas (User, Listing, Booking, Payment)
– middleware/ – JWT auth, file uploads (multer)
– utils/db.js – MongoDB connection helper
– public/uploads – static folder for images
– index.js – app entry point
- Frontend/ – React.js + Vite single-page app
– src/components, src/pages – UI components and pages
– src/redux – global state management (store, state)
– public/assets – static images
– index.html, vite.config.js – build/dev config
- README.md – confirms tech stack, features, API paths

##### README for additional insights
- Features: JWT auth, car inventory, booking, admin dashboard, real-time updates, secure Razorpay payment.
- Tech Stack: React Router, Axios, Redux; Express.js, MongoDB, JWT, Razorpay API.
- API endpoints: /api/auth, /api/cars, /api/bookings, /api/users, /api/payments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        FE_Entry["Entry Point\n(main.jsx)"]:::frontend
        FE_Components["UI Components\n(src/components)"]:::frontend
        FE_Pages["Page Views & Routing\n(src/pages)"]:::frontend
        FE_Redux["Redux Store & State\n(src/redux)"]:::frontend
        FE_Assets["Static Assets\n(public/assets)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        BE_Server["Express Server\n(index.js)"]:::backend
        subgraph "Routing Layer"
            direction TB
            BE_AuthRoute["Auth Router"]:::backend
            BE_BookingRoute["Booking Router"]:::backend
            BE_ListingRoute["Listing Router"]:::backend
            BE_PaymentRoute["Payment Router"]:::backend
            BE_UserRoute["User Router"]:::backend
        end
        subgraph "Controllers"
            direction TB
            BE_AuthCtrl["Auth Controller"]:::backend
            BE_BookingCtrl["Booking Controller"]:::backend
            BE_ListingCtrl["Listing Controller"]:::backend
            BE_PaymentCtrl["Payment Controller"]:::backend
            BE_UserCtrl["User Controller"]:::backend
        end
        subgraph "Middleware"
            direction TB
            BE_AuthMW["Auth Middleware (JWT)"]:::backend
            BE_MulterMW["File Upload Middleware\n(multer)"]:::backend
        end
        subgraph "Models"
            direction TB
            BE_UserModel["User Model"]:::datastore
            BE_ListingModel["Listing Model"]:::datastore
            BE_BookingModel["Booking Model"]:::datastore
            BE_PaymentModel["Payment Model"]:::datastore
        end
        BE_DBUtil["DB Connection\n(utils/db.js)"]:::backend
        BE_Uploads["Uploads Folder\n(public/uploads)"]:::datastore
        BE_Env["Environment Config\n(.env)"]:::backend
    end

    %% Database
    subgraph "Database"
        direction TB
        MongoDB["MongoDB"]:::datastore
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Razorpay["Razorpay Gateway"]:::external
    end

    %% Frontend interactions
    FE_Entry -->|renders| FE_Components
    FE_Entry -->|routes| FE_Pages
    FE_Components -->|accesses| FE_Redux
    FE_Pages -->|dispatches| FE_Redux
    FE_Redux -->|triggers API calls| BE_Server

    FE_Entry -.->|serves assets| FE_Assets

    %% API Calls
    BE_Server -->|uses routers| BE_AuthRoute
    BE_Server -->|uses routers| BE_BookingRoute
    BE_Server -->|uses routers| BE_ListingRoute
    BE_Server -->|uses routers| BE_PaymentRoute
    BE_Server -->|uses routers| BE_UserRoute

    BE_AuthRoute -->|calls| BE_AuthCtrl
    BE_BookingRoute -->|calls| BE_BookingCtrl
    BE_ListingRoute -->|calls| BE_ListingCtrl
    BE_PaymentRoute -->|calls| BE_PaymentCtrl
    BE_UserRoute -->|calls| BE_UserCtrl

    %% Middleware flows
    BE_Server -->|JWT check| BE_AuthMW
    BE_ListingRoute -->|file upload| BE_MulterMW

    %% Controllers to Models
    BE_AuthCtrl -->|CRUD| BE_UserModel
    BE_ListingCtrl -->|CRUD| BE_ListingModel
    BE_BookingCtrl -->|CRUD| BE_BookingModel
    BE_PaymentCtrl -->|CRUD| BE_PaymentModel
    BE_UserCtrl -->|CRUD| BE_UserModel

    %% DB Connection
    BE_DBUtil -->|connects| MongoDB

    %% Models to DB
    BE_UserModel -->|queries| MongoDB
    BE_ListingModel -->|queries| MongoDB
    BE_BookingModel -->|queries| MongoDB
    BE_PaymentModel -->|queries| MongoDB

    %% Uploads
    BE_MulterMW -->|saves files| BE_Uploads
    BE_Uploads -->|served by| BE_Server

    %% Payment Flow
    BE_PaymentCtrl -->|calls SDK| Razorpay
    FE_Pages -->|renders checkout UI| Razorpay
    Razorpay -->|webhook/callback| BE_PaymentCtrl

    %% Click Events Frontend
    click FE_Entry "https://github.com/omwanere/car_rental_service/blob/main/Frontend/src/main.jsx"
    click FE_Components "https://github.com/omwanere/car_rental_service/tree/main/Frontend/src/components"
    click FE_Pages "https://github.com/omwanere/car_rental_service/tree/main/Frontend/src/pages"
    click FE_Redux "https://github.com/omwanere/car_rental_service/blob/main/Frontend/src/redux/store.jsx"
    click FE_Redux "https://github.com/omwanere/car_rental_service/blob/main/Frontend/src/redux/state.jsx"
    click FE_Assets "https://github.com/omwanere/car_rental_service/tree/main/Frontend/public/assets"

    %% Click Events Backend
    click BE_Server "https://github.com/omwanere/car_rental_service/blob/main/Backend/index.js"
    click BE_AuthRoute "https://github.com/omwanere/car_rental_service/blob/main/Backend/routes/auth.route.js"
    click BE_BookingRoute "https://github.com/omwanere/car_rental_service/blob/main/Backend/routes/booking.route.js"
    click BE_ListingRoute "https://github.com/omwanere/car_rental_service/blob/main/Backend/routes/listing.route.js"
    click BE_PaymentRoute "https://github.com/omwanere/car_rental_service/blob/main/Backend/routes/payment.route.js"
    click BE_UserRoute "https://github.com/omwanere/car_rental_service/blob/main/Backend/routes/user.route.js"
    click BE_AuthCtrl "https://github.com/omwanere/car_rental_service/blob/main/Backend/controllers/auth.js"
    click BE_BookingCtrl "https://github.com/omwanere/car_rental_service/blob/main/Backend/controllers/booking.js"
    click BE_ListingCtrl "https://github.com/omwanere/car_rental_service/blob/main/Backend/controllers/listing.js"
    click BE_PaymentCtrl "https://github.com/omwanere/car_rental_service/blob/main/Backend/controllers/payment.js"
    click BE_UserCtrl "https://github.com/omwanere/car_rental_service/blob/main/Backend/controllers/user.js"
    click BE_AuthMW "https://github.com/omwanere/car_rental_service/blob/main/Backend/middleware/Auth.js"
    click BE_MulterMW "https://github.com/omwanere/car_rental_service/blob/main/Backend/middleware/multer.js"
    click BE_UserModel "https://github.com/omwanere/car_rental_service/blob/main/Backend/models/User.Model.js"
    click BE_ListingModel "https://github.com/omwanere/car_rental_service/blob/main/Backend/models/Listing.Model.js"
    click BE_BookingModel "https://github.com/omwanere/car_rental_service/blob/main/Backend/models/Booking.Model.js"
    click BE_PaymentModel "https://github.com/omwanere/car_rental_service/blob/main/Backend/models/Payment.Model.js"
    click BE_DBUtil "https://github.com/omwanere/car_rental_service/blob/main/Backend/utils/db.js"
    click BE_Uploads "https://github.com/omwanere/car_rental_service/tree/main/Backend/public/uploads"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef datastore fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:1px
```
