# hakeemkhan1/fleetfriend architecture

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

- Interactive diagram: https://gitdiagram.com/hakeemkhan1/fleetfriend
- Repository: https://github.com/hakeemkhan1/fleetfriend

## Overview

##### Project type and purpose
- From the README ("Fleet Management tool") and the file tree, we can see this is a full‑stack web application (“FleetFriend”) composed of:
- A Node.js/Express backend (inside `BackEnd/`) that manages vehicles and bookings.
- A static JavaScript frontend (inside `FrontEnd/`) that renders the UI and calls backend APIs.

##### File structure
- Top‑level folders:
- `BackEnd/`: contains an Express app with subfolders for `controllers/`, `models/`, `routes/`, `config/`, and `logs/`.
- `FrontEnd/`: contains `index.html`, a CSS file, and JS modules (`api.js`, `app.js`, page‑specific scripts).
- Patterns & conventions:
- MVC‑style on the server: `models/` (data schemas), `controllers/` (business logic), `routes/` (HTTP endpoints).
- A logger module (`config/logger.js`) and log files under `logs/`, implying a dedicated logging service.
- A `.env` file for environment variables.
- Deployment/build: no complex build scripts – it’s a plain Node/Express app plus static files.

##### README for additional insights
- Minimal README, but it confirms the tool’s domain (fleet management) and its core entities (vehicles, bookings).

##### Elements
- Labels: “Browser”, “Static Web Assets”, “Express API Server”, “Logger Service”, “Database”.
- Browser → Static Web Server (GET index.html, CSS, JS)
- JS client → Express API (REST calls)
- Express API → Database (CRUD operations)
- Express API → Logger (write logs)
- Section off configuration (`.env` loaded by config module) and node_modules as non‑functional support.

- Sub‑components drawn inside:
- Config loader (`config/logger.js`)
- Router layer (`routes/*.js`)
- Controller layer (`controllers/*.js`)
- Model layer (`models/*.js`)
- Logger writing to `logs/`

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Browser"]:::client
        subgraph "Static Web Assets" 
            Index["index.html"]:::client
            APIJS["api.js"]:::client
            OtherJS["JS Modules"]:::client
            Styles["styles.css"]:::client
        end
    end
    Browser -->|loads| Index
    Browser -->|loads| APIJS
    Browser -->|loads| OtherJS
    Browser -->|loads| Styles

    click Index "https://github.com/hakeemkhan1/fleetfriend/blob/main/FrontEnd/index.html"
    click APIJS "https://github.com/hakeemkhan1/fleetfriend/blob/main/FrontEnd/js/api.js"
    click OtherJS "https://github.com/hakeemkhan1/fleetfriend/tree/main/FrontEnd/js/"
    click Styles "https://github.com/hakeemkhan1/fleetfriend/blob/main/FrontEnd/styles.css"

    %% Server Layer
    subgraph "Server Layer"
        API["Express API Server"]:::server
        subgraph "Configuration & Logging"
            Env[".env"]:::config
            Config["config/logger.js"]:::config
            Logger["Logger Service"]:::server
        end
        subgraph "API Routes"
            VR["vehicleRoutes.js"]:::server
            BR["bookingRoutes.js"]:::server
        end
        subgraph "Controllers"
            VC["vehicleController.js"]:::server
            BC["bookingController.js"]:::server
        end
        subgraph "Models"
            VM["Vehicle.js"]:::server
            BM["Booking.js"]:::server
        end
    end

    click API "https://github.com/hakeemkhan1/fleetfriend/blob/main/BackEnd/server.js"
    click Env "https://github.com/hakeemkhan1/fleetfriend/blob/main/BackEnd/.env"
    click Config "https://github.com/hakeemkhan1/fleetfriend/blob/main/BackEnd/config/logger.js"
    click VR "https://github.com/hakeemkhan1/fleetfriend/blob/main/BackEnd/routes/vehicleRoutes.js"
    click BR "https://github.com/hakeemkhan1/fleetfriend/blob/main/BackEnd/routes/bookingRoutes.js"
    click VC "https://github.com/hakeemkhan1/fleetfriend/blob/main/BackEnd/controllers/vehicleController.js"
    click BC "https://github.com/hakeemkhan1/fleetfriend/blob/main/BackEnd/controllers/bookingController.js"
    click VM "https://github.com/hakeemkhan1/fleetfriend/blob/main/BackEnd/models/Vehicle.js"
    click BM "https://github.com/hakeemkhan1/fleetfriend/blob/main/BackEnd/models/Booking.js"

    %% Server interactions
    API -->|loads| Env
    API -->|init| Config
    API -->|uses| Logger
    Browser -->|REST calls| API
    API -->|routes requests| VR
    API -->|routes requests| BR
    VR -->|calls| VC
    BR -->|calls| BC
    VC -->|queries| VM
    VC -->|queries| BM
    BC -->|queries| BM
    BC -->|queries| VM
    VC -->|logs| Logger
    BC -->|logs| Logger

    %% Data Layer
    subgraph "Data Layer"
        DB["Database"]:::data
        subgraph "Log Files"
            AL["access.log"]:::data
            CL["combined.log"]:::data
            DL["debug.log"]:::data
            EL["error.log"]:::data
            XL["exceptions.log"]:::data
            RL["rejections.log"]:::data
        end
    end

    %% Data interactions
    VM -->|CRUD| DB
    BM -->|CRUD| DB
    Logger -->|writes| AL
    Logger -->|writes| CL
    Logger -->|writes| DL
    Logger -->|writes| EL
    Logger -->|writes| XL
    Logger -->|writes| RL

    classDef client fill:#ccffcc,stroke:#33aa33,color:#003300;
    classDef server fill:#cce0ff,stroke:#3366cc,color:#003399;
    classDef data fill:#ffe0b3,stroke:#ff9900,color:#994d00;
    classDef config fill:#e5ccff,stroke:#9933cc,color:#4d004d;
```
