# mrinal-kr/nit-rental architecture

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

- Interactive diagram: https://gitdiagram.com/mrinal-kr/nit-rental
- Repository: https://github.com/mrinal-kr/nit-rental

## Overview

##### Project Type and Purpose
- Full-stack web application (browser-based SPA for car rentals)
- Users browse cars, authenticate, book rentals, and manage bookings via a dashboard

##### File Structure
- At top level:
– index.html (SPA entry point)
– main.js (frontend logic and API calls)
– styles.css (presentation)
- No backend code present in this tree ⇒ frontend interacts with external backend services/APIs

##### README for Additional Insights
- Core features imply components beyond the static front end:
– Authentication service
– Booking management service
– Car-inventory/catalog service
– Database for users, cars, bookings
– Potential payment gateway (if “secure booking” includes payments)

##### Main Components
a. Frontend (Browser/SPA)
- index.html, main.js, styles.css loaded from a web server or CDN
- UI modules: Car catalog, filters, calendar picker, login/signup form, dashboard
b. Backend API Layer
- Authentication Service (e.g. REST endpoints: /signup, /login, token management)
- Car Inventory Service (e.g. /cars, /cars/categories, /cars/availability)
- Booking Service (e.g. /bookings, /bookings/{user})
- (Optional) Payment Gateway integration
c. Data Layer
- Relational DB (Users, Cars, Bookings tables)
- Caching layer or in-memory store (for availability lookups)
d. External Services
- Email/SMS service (booking confirmations)
- Analytics or logging service

##### Relationships and Data Flows
- Browser → Web server/CDN: GET index.html, CSS, JS, assets
- main.js (SPA) → Backend API:
– Auth calls return JWT or session cookie
– Catalog calls fetch car listings (with filters)
– Booking calls reserve a car, confirm dates
- Backend services → Database: CRUD operations on entities
- Booking service → Payment gateway (if processing payments)
- Booking service → Email/SMS service for notifications

##### Architectural Patterns and Design Principles
- Separation of Concerns:
– UI layer (frontend) vs Business Logic/API layer vs Data layer
- RESTful API design for services
- Single-Page Application (SPA) for seamless user experience
- Stateless backend services with token-based authentication
- Microservices-style decomposition (optional; can be grouped as a monolith API)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        browser["Browser / SPA"]:::frontend
        index["index.html"]:::frontend
        main["main.js"]:::frontend
        styles["styles.css"]:::frontend
        assets["assets/"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        auth["Authentication Service"]:::backend
        catalog["Car Inventory Service"]:::backend
        booking["Booking Service"]:::backend
        payment["Payment Gateway"]:::external
    end

    %% Data Layer
    subgraph "Data Layer"
        db["Relational DB"]:::datastore
        cache["Cache Store"]:::datastore
    end

    %% External Services
    subgraph "External Services"
        email["Email/SMS Service"]:::external
        analytics["Analytics/Logging Service"]:::external
    end

    %% Connections
    browser -->|loads| index
    browser -->|loads| main
    browser -->|loads| styles
    browser -->|loads| assets

    main -->|"auth calls"| auth
    main -->|"catalog calls"| catalog
    main -->|"booking calls"| booking

    auth -->|"CRUD users"| db
    catalog -->|"CRUD cars"| db
    booking -->|"CRUD bookings"| db

    catalog -->|"availability lookup"| cache
    booking -->|"availability lookup"| cache

    booking -->|"process payment"| payment
    booking -->|"send confirmation"| email

    auth -->|"logs events"| analytics
    catalog -->|"logs events"| analytics
    booking -->|"logs events"| analytics

    %% Click Events
    click index "https://github.com/mrinal-kr/nit-rental/blob/main/index.html"
    click main "https://github.com/mrinal-kr/nit-rental/blob/main/main.js"
    click styles "https://github.com/mrinal-kr/nit-rental/blob/main/styles.css"
    click assets "https://github.com/mrinal-kr/nit-rental/tree/main/assets/"

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