# rohit00112/car-rental architecture

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

- Interactive diagram: https://gitdiagram.com/rohit00112/car-rental
- Repository: https://github.com/rohit00112/car-rental

## Overview

##### Main Components
- Frontend (Presentation Layer): Represented by the Next.js pages in the src/app directory. This includes segregated areas like admin pages, car details, home, and rent pages.
- Business/Service Layer: Located in src/Services, this layer encapsulates the business logic and interactions (e.g., services for car management, authentication, rental rent, customer handling, damage bills, notifications). They operate as helpers for data processing and interfacing with backend endpoints.
- API Layer: There are API route handlers (e.g., in src/app/api) and components in src/Components/api that interact with your endpoints and handle HTTP errors.

##### Architectural Patterns and Design Principles
- Component-Based Architecture: Emphasize how the UI is built using modular React components.
- Separation of Concerns: Clearly delineate the presentation (pages and UI components), business logic (services), and the integration/API layer.
- Domain Separation: Notice that services are grouped by domain (car, customer, damage, rent, staff, etc.), which indicates a domain-driven design approach.
- Use of Next.js routing and file-based API integration ensures that both client and server code are maintained within a single repository.

##### Details
- Use clear and distinct labels. For example:
- “Frontend – Next.js Pages (src/app)”
- “UI Components (src/Components)”
- “Business Services (src/Services)”
- “API Endpoints and Helpers”
- From UI (pages/components) → Services (to show business logic invocation).
- From Services → API layer (for data requests/operations).
- Optionally, from API endpoints → External systems (if any external database or service exists).
- Rectangles for pages and components.
- Notes identifying that the system is built on Next.js (leveraging file-based routing and route handlers) and that the business logic is decoupled into modular service files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Next.js Frontend (src/app)"
        FE1["Next.js Pages"]:::front
        FE2["Admin Pages"]:::front
        FE3["Car Pages"]:::front
        FE4["Car Details ([id])"]:::front
        FE5["Rent Pages"]:::front
    end

    subgraph "UI Components (src/Components)"
        UI1["Cards Component"]:::ui
        UI2["Navigation Components"]:::ui
        UI3["Icon Components"]:::ui
        UI4["Modals Components"]:::ui
        UI5["API Helpers (UI)"]:::ui
    end

    subgraph "Business Services (src/Services)"
        BS1["Car Management"]:::serv
        BS2["Rental Processing"]:::serv
        BS3["Authentication"]:::serv
        BS4["Customer Handling"]:::serv
        BS5["Damage Requests"]:::serv
        BS6["Damage Bills"]:::serv
        BS7["Staff Management"]:::serv
        BS8["Notifications"]:::serv
        BS9["Rental Returns"]:::serv
        BS10["Offers"]:::serv
        BS11["Monthly Sales"]:::serv
    end

    subgraph "API Endpoints and Helpers"
        API1["API Endpoint (Route Handler)"]:::api
    end

    subgraph "Types/Contracts"
        T1["Types/Contracts"]:::types
    end

    %% Relationships
    FE1 -->|"uses"| UI1
    FE1 -->|"uses"| UI2
    FE1 -->|"triggers"| BS1
    FE1 -->|"triggers"| BS2
    FE1 -->|"triggers"| BS3
    FE1 -->|"triggers"| BS4
    FE1 -->|"triggers"| BS5
    FE1 -->|"triggers"| BS6
    FE1 -->|"triggers"| BS7
    FE1 -->|"triggers"| BS8
    FE1 -->|"triggers"| BS9
    FE1 -->|"triggers"| BS10
    FE1 -->|"triggers"| BS11

    UI4 -->|"activates"| BS3

    BS1 -->|"calls"| API1
    BS2 -->|"calls"| API1
    BS3 -->|"calls"| API1
    BS4 -->|"calls"| API1
    BS5 -->|"calls"| API1
    BS6 -->|"calls"| API1
    BS7 -->|"calls"| API1
    BS8 -->|"calls"| API1
    BS9 -->|"calls"| API1
    BS10 -->|"calls"| API1
    BS11 -->|"calls"| API1

    API1 -->|"responds"| FE1

    %% Click Events
    click FE1 "https://github.com/rohit00112/car-rental/tree/main/src/app"
    click FE2 "https://github.com/rohit00112/car-rental/tree/main/src/app/admin"
    click FE3 "https://github.com/rohit00112/car-rental/tree/main/src/app/cars"
    click FE4 "https://github.com/rohit00112/car-rental/tree/main/src/app/home/[id]"
    click FE5 "https://github.com/rohit00112/car-rental/tree/main/src/app/rent"
    
    click UI1 "https://github.com/rohit00112/car-rental/blob/main/src/Components/Cards/Cards.tsx"
    click UI2 "https://github.com/rohit00112/car-rental/tree/main/src/Components/CustomNav"
    click UI3 "https://github.com/rohit00112/car-rental/tree/main/src/Components/Icons"
    click UI4 "https://github.com/rohit00112/car-rental/tree/main/src/Components/Modals"
    click UI5 "https://github.com/rohit00112/car-rental/tree/main/src/Components/api"
    
    click BS1 "https://github.com/rohit00112/car-rental/tree/main/src/Services/car"
    click BS2 "https://github.com/rohit00112/car-rental/tree/main/src/Services/rent"
    click BS3 "https://github.com/rohit00112/car-rental/tree/main/src/Services/auth"
    click BS4 "https://github.com/rohit00112/car-rental/tree/main/src/Services/customer"
    click BS5 "https://github.com/rohit00112/car-rental/tree/main/src/Services/Damage"
    click BS6 "https://github.com/rohit00112/car-rental/tree/main/src/Services/damagebill"
    click BS7 "https://github.com/rohit00112/car-rental/tree/main/src/Services/staff"
    click BS8 "https://github.com/rohit00112/car-rental/tree/main/src/Services/Notification"
    click BS9 "https://github.com/rohit00112/car-rental/tree/main/src/Services/RentalReturn"
    click BS10 "https://github.com/rohit00112/car-rental/tree/main/src/Services/offer"
    click BS11 "https://github.com/rohit00112/car-rental/tree/main/src/Services/MonthlySales"
    
    click API1 "https://github.com/rohit00112/car-rental/blob/main/src/app/api/hello/route.ts"
    
    click T1 "https://github.com/rohit00112/car-rental/tree/main/src/types"
    
    %% Styles
    classDef front fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef ui fill:#aed6f1,stroke:#1f618d,stroke-width:2px;
    classDef serv fill:#abebc6,stroke:#1e8449,stroke-width:2px;
    classDef api fill:#f5cba7,stroke:#d35400,stroke-width:2px;
    classDef types fill:#d2b4de,stroke:#6c3483,stroke-width:2px;
```
