# prakashjhax/loadconnectx78 architecture

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

- Interactive diagram: https://gitdiagram.com/prakashjhax/loadconnectx78
- Repository: https://github.com/prakashjhax/loadconnectx78

## Overview

##### Project type and purpose
- LoadConnect is a full-stack web application (capstone logistics platform) that connects vehicle owners, rural producers, and buyers for efficient load bookings and return-trip optimization.

##### File structure
- Top-level “loadconnect-frontend” contains static HTML, CSS, JS assets plus map integration files.
- “loadconnect-backend” is a modular Express.js service with subfolders:
- controllers (business logic per resource)
- routes (Express route definitions)
- middlewares (authentication, file uploads)
- utils (validation)
- gps, public, uploads (static assets & HTML endpoints)
- db.js (DB connection) and server.js (app entry point)
- Presence of JWT, Multer, Twilio, dotenv in package.json indicates authentication, file-upload, SMS OTP, environment config.

##### README for additional insights
- Frontend uses HTML/CSS/JS, Google Maps API, Leaflet.js + OSRM.
- Backend uses Node.js/Express, JWT, bcrypt, Twilio, MySQL (dev) → PostgreSQL (prod).
- Key modules: authentication, load posting, quoting, booking, tracking, document uploads.

##### Main components & interactions
a. Frontend (Web UI)
- HTML pages, JS controllers call REST endpoints
- /UI components (Google Maps, Leaflet/OSRM)
b. Backend API server
- Authentication module (JWT + Twilio OTP)
- Load & vehicle posting module
- Quotation & booking module
- Tracking & distance calculation (calls OSRM)
- File‐upload & validation middleware
- Database access (db.js → MySQL/PostgreSQL) via SQL queries
c. Database
- Relational schema (users, loads, vehicles, bookings, quotations, documents)
d. External services
- Twilio (OTP SMS)
- Google Maps API / Leaflet + OSRM (route & distance)

##### Architectural patterns & design principles
- Modular Express structure: separate route definitions, controllers, and middleware
- MVC-style separation: Controllers handle business logic; routes map HTTP to controllers
- Stateless RESTful API with JWT for session management
- Layered architecture: Presentation (frontend) → API layer → Data layer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Web UI" 
        direction TB
        FE["Frontend Web UI"]:::frontend
        subgraph "Authentication Pages" 
            direction TB
            LoginHTML["Login.html"]:::frontend
            RegisterHTML["register.html"]:::frontend
            ForgotHTML["forgot-password.html"]:::frontend
            LoginJS["login.js"]:::frontend
        end
        subgraph "Map/UI Components" 
            direction TB
            GPSDir["gps/"]:::frontend
            GPSHTML["gps.html"]:::frontend
            MapHTML["map.html"]:::frontend
        end
        subgraph "Customer Dashboard & Load Posting" 
            direction TB
            CustDash["customer-dashboard.html"]:::frontend
            PostLoad["post-load.html"]:::frontend
            MyBookings["my-bookings.html"]:::frontend
            MyQuotes["my-quotes.html"]:::frontend
            CustJS["customer.js"]:::frontend
            LoadPostJS["load-post.js"]:::frontend
            RecentLoadJS["recentload.js"]:::frontend
        end
        subgraph "Operator Dashboard & Quoting" 
            direction TB
            OpDash["operator-dashboard.html"]:::frontend
            OpQuotes["operator-quotes.html"]:::frontend
            OpJS["operator.js"]:::frontend
        end
        TrackPage["track.html"]:::frontend
    end

    %% Backend Layer
    subgraph "Express API Server" 
        direction TB
        Server["server.js"]:::backend
        Env[".env (config)"]:::backend
        DBConn["db.js"]:::backend
        subgraph "Authentication Module" 
            direction TB
            AuthRoutes["authRoutes.js"]:::backend
        end
        subgraph "Load & Vehicle Posting Module" 
            direction TB
            LoadRoutes["loadRoutes.js"]:::backend
        end
        subgraph "Quotation & Booking Module" 
            direction TB
            QuoteRoutes["quotationRoutes.js"]:::backend
            BookingRoutes["bookingRoutes.js"]:::backend
        end
        subgraph "Tracking & Distance Module" 
            direction TB
            TrackingRoutes["trackingRoutes.js"]:::backend
            RouteHTML["gps/route.html"]:::backend
        end
        subgraph "Middleware & Utils" 
            direction TB
            UploadsMW["uploads.js"]:::backend
            ValidateUtil["validate.js"]:::backend
        end
    end

    %% Database
    Database["Relational Database\n(Users, Loads, Vehicles, Bookings)"]:::db

    %% External Services
    Twilio["Twilio SMS OTP"]:::external
    MapsAPI["Google Maps API\nLeaflet/OSRM"]:::external

    %% Connections
    FE -->|"POST /auth, GET /auth"| AuthRoutes
    FE -->|"GET /loads, POST /loads"| LoadRoutes
    FE -->|"POST /quotes, GET /quotes"| QuoteRoutes
    FE -->|"POST /bookings, GET /bookings"| BookingRoutes
    FE -->|"GET /tracking"| TrackingRoutes

    AuthRoutes -->|uses| ValidateUtil
    AuthRoutes -->|uses| UploadsMW
    LoadRoutes -->|uses| ValidateUtil
    QuoteRoutes -->|uses| ValidateUtil
    BookingRoutes -->|uses| ValidateUtil
    TrackingRoutes -->|calls OSRM| MapsAPI
    TrackingRoutes -->|serves| RouteHTML

    Server -->|connect| DBConn
    DBConn -->|SQL queries| Database

    Server -->|sends SMS| Twilio
    Server -->|calls Maps| MapsAPI

    %% Responses
    AuthRoutes -->|"200 OK"| FE
    LoadRoutes -->|"200 OK"| FE
    QuoteRoutes -->|"200 OK"| FE
    BookingRoutes -->|"200 OK"| FE
    TrackingRoutes -->|"200 OK"| FE

    %% Click Events
    click FE "https://github.com/prakashjhax/loadconnectx78/tree/main/loadconnect-frontend/"
    click LoginHTML "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/Login.html"
    click RegisterHTML "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/register.html"
    click ForgotHTML "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/forgot-password.html"
    click LoginJS "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/login.js"
    click GPSDir "https://github.com/prakashjhax/loadconnectx78/tree/main/loadconnect-frontend/gps/"
    click GPSHTML "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/gps/gps.html"
    click MapHTML "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/gps/map.html"
    click CustDash "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/customer-dashboard.html"
    click PostLoad "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/post-load.html"
    click MyBookings "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/my-bookings.html"
    click MyQuotes "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/my-quotes.html"
    click CustJS "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/customer.js"
    click LoadPostJS "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/load-post.js"
    click RecentLoadJS "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/recentload.js"
    click OpDash "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/operator-dashboard.html"
    click OpQuotes "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/operator-quotes.html"
    click OpJS "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/operator.js"
    click TrackPage "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-frontend/track.html"
    click Server "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/server.js"
    click DBConn "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/db.js"
    click AuthRoutes "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/routes/authRoutes.js"
    click LoadRoutes "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/routes/loadRoutes.js"
    click QuoteRoutes "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/routes/quotationRoutes.js"
    click BookingRoutes "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/routes/bookingRoutes.js"
    click TrackingRoutes "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/routes/trackingRoutes.js"
    click RouteHTML "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/gps/route.html"
    click UploadsMW "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/middlewares/uploads.js"
    click ValidateUtil "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/utils/validate.js"
    click GPSPublic "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/public/gps.html"
    click MapPublic "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/public/map.html"
    click PaymentPublic "https://github.com/prakashjhax/loadconnectx78/blob/main/loadconnect-backend/public/payment.html"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:1px;
    classDef backend fill:#A9DFBF,stroke:#196F3D,stroke-width:1px;
    classDef db fill:#F5CBA7,stroke:#B9770E,stroke-width:1px;
    classDef external fill:#D2B4DE,stroke:#6C3483,stroke-width:1px;
```
