# ishant21-ap/vehicle-rental-system architecture

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

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

## Overview

##### Main Components
- Frontend: Represented by the “vehicle-management-frontend” directory. It includes React components (e.g., CarCard, Navbar, Login, OTPVerification, etc.), pages (e.g., LandingPage.jsx, ShopKeeperLandingPage.jsx), and state management (Redux store). This component handles user interaction and displays dashboards for both users and shopkeepers.
- Backend: Shown under the “vehicle-management-backend” directory. It is layered into:
- Controllers (REST endpoints for Booking, User, and Vehicle operations)
- Services (Business logic, including BookingService, UserService, and VehicleService implementations, as well as OTP and Email Services)
- Repositories (data access for Booking, User, and Vehicle entities)
- Security & Configuration (JWT authentication filter, security configuration, and application configuration classes)
- Exception Handling (global exception handling and custom exceptions)
- Database: MySQL (as indicated in the README) storing user/shopkeeper details, vehicle records, and booking histories.
- External Services:
- Email Service for sending OTP verification and notifications.
- JWT Security for authentication and authorization.

##### Relationships and Data Flow
- Backend Components:
- Controllers receive RESTful requests from the Frontend.
- Controllers pass data to the Service layer which implements business logic.
- The Service layer interacts with the Repository layer for CRUD operations on the MySQL database.
- The Security components (JWT Authentication Filter, Security Config) protect endpoints and manage access control.
- The Email and OTP services are called from within the service layer to handle user verifications and notifications.
- Database ↔ Backend: The Repository components use Hibernate/JPA to persist and retrieve data from the MySQL database.

##### Architectural Patterns and Key Technologies
- Layered (n-tier) architecture in the backend:
- Presentation Layer: REST Controllers.
- Service Layer: Business logic.
- Data Access Layer: Repositories interfacing with MySQL via Hibernate/JPA.
- Security: JWT-based authentication and role-based access control using Spring Security.
- Frontend Architecture: Component-based design in React with state management via Redux.
- Other design principles include Separation of Concerns, modularity, and clear API boundaries.

##### Putting It All Together
- Next, illustrate the Backend layer containing:
- REST Controllers (e.g., BookingController, UserController, VehicleController)
- Service Layer components (BookingService, UserService, VehicleService, etc.)
- Security components (JWTAuthenticationFilter, SecurityConfig) ensuring secure communications.
- Data Access (Repository layers connecting to the MySQL database).
- Finally, include an Email Service component that interacts with the backend for actions like OTP verification and notifications.

##### Final Advice
- Avoid over-complicating details, but ensure that key interactions (data flow between UI, business logic, and data storage) are clearly visible and logically presented.
- That any specific technologies (e.g., Spring Boot, React, MySQL, JWT, Redux, Hibernate) are highlighted near their respective components.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Subgraph
    subgraph "Frontend"
        FE1["React Components"]:::frontend
        FE2["Frontend Pages"]:::frontend
        FE3["Redux Store"]:::frontend
    end

    %% Backend Core Subgraph
    subgraph "Backend Core"
        BE1["Backend Main"]:::backend
        BE2["REST Controllers"]:::backend
        BE3["Service Layer"]:::backend
        BE4["Repositories"]:::backend
        BE5["MySQL Database"]:::database
    end

    %% Backend Supporting Components
    subgraph "Backend Supporting"
        BS1["Security Components"]:::backend
        BS2["Application Configuration"]:::backend
        BS3["Exception Handling"]:::backend
    end

    %% External Services
    subgraph "External Services"
        EXT1["Email Service"]:::external
    end

    %% Data Flow Connections
    FE1 -->|"calls"| BE2
    BE1 -->|"initializes"| BE2
    BE2 -->|"delegates"| BE3
    BE3 -->|"persists via"| BE4
    BE4 -->|"CRUD operations"| BE5
    BE3 -->|"triggers"| EXT1

    %% Supporting Component Connections
    BS1 -->|"secures"| BE2
    BS2 -->|"configures"| BE1
    BS3 -->|"handles"| BE2

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;

    %% Click Events
    click FE1 "https://github.com/ishant21-ap/vehicle-rental-system/tree/main/vehicle-management-frontend/src/components"
    click FE2 "https://github.com/ishant21-ap/vehicle-rental-system/tree/main/vehicle-management-frontend/src/pages"
    click FE3 "https://github.com/ishant21-ap/vehicle-rental-system/tree/main/vehicle-management-frontend/src/store"
    click BE1 "https://github.com/ishant21-ap/vehicle-rental-system/blob/main/vehicle-management-backend/src/main/java/com/example/vehicle_management_system/backend/VehicleManagementSystemBackendApplication.java"
    click BE2 "https://github.com/ishant21-ap/vehicle-rental-system/tree/main/vehicle-management-backend/src/main/java/com/example/vehicle_management_system/backend/controller"
    click BE3 "https://github.com/ishant21-ap/vehicle-rental-system/tree/main/vehicle-management-backend/src/main/java/com/example/vehicle_management_system/backend/service"
    click BE4 "https://github.com/ishant21-ap/vehicle-rental-system/tree/main/vehicle-management-backend/src/main/java/com/example/vehicle_management_system/backend/repository"
    click BS1 "https://github.com/ishant21-ap/vehicle-rental-system/tree/main/vehicle-management-backend/src/main/java/com/example/vehicle_management_system/backend/security"
    click BS2 "https://github.com/ishant21-ap/vehicle-rental-system/blob/main/vehicle-management-backend/src/main/java/com/example/vehicle_management_system/backend/config/AppConfig.java"
    click BS3 "https://github.com/ishant21-ap/vehicle-rental-system/tree/main/vehicle-management-backend/src/main/java/com/example/vehicle_management_system/backend/exception"
    click BE5 "https://github.com/ishant21-ap/vehicle-rental-system/blob/main/vehicle-management-backend/src/main/resources/application.properties"
```
