# keshalahapuarachchi/transport-management architecture

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

- Interactive diagram: https://gitdiagram.com/keshalahapuarachchi/transport-management
- Repository: https://github.com/keshalahapuarachchi/transport-management

## Overview

##### Main Components
- Frontend: A React-based user interface (located under the “frontend” directory). This is where users and admins interact with the system.
- Backend: A Node.js/Express server (found in the “BACKEND” directory) that manages API routes, controllers, and the business logic for vehicle data management.
- Database: Although not explicitly shown in the file tree, the MERN stack implies the use of MongoDB for storing transport data.
- External Services: You may include a PDF generation service/component (used to generate reports), and possibly third-party mapping services for displaying delivery maps.

##### Relationships and Interactions
- The Frontend communicates with the Backend via RESTful API calls. The React components handle data requests and display responses from the server.
- The Backend’s controllers, models, and routes work together to fetch, update, and delete data in the MongoDB database.
- Data—from vehicle information to user/admin interactions—flows from the client to the API and then persists or retrieves data from MongoDB.
- Special functionalities, such as PDF report generation and image uploads, are integrated within the Backend, with direct influence on the UI in React.

##### Architectural Patterns and Design Principles
- MVC Pattern on the backend: Controllers (e.g., deliverVehicles.js in “controllers”), models (e.g., deliverVehicles.js in “models”), and routes (e.g., deliverVehicles.js in “routes”) clearly indicate a separation of concerns.
- Component-based design on the frontend: The React application organizes UI elements into clearly separated components (for vehicle display, navigation bars, update forms, lists, etc.).
- Separation of concerns: Distinct directories for “frontend” and “BACKEND” help in isolating client-side and server-side functionalities.

##### Technologies and Frameworks
- MongoDB: For the database layer (store transport system data).
- Express.js and Node.js: For handling API routes, server logic, and middleware.
- React: For building the interactive UI that displays vehicle information and supports admin functionalities.
- Additional libraries may include PDF generation modules and possibly image-upload middleware.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Client
    Browser["Client (Browser/User)"]:::client

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["React Application"]:::frontend
        NavBar["Navigation Bar"]:::frontend
        Lorry["Lorry Screen"]:::frontend
        Truck["Truck Screen"]:::frontend
        Van["Van Screen"]:::frontend
        Update["Update Screen"]:::frontend
        ListPage["List Page Component"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["API Server (Node.js/Express)"]:::backend
        subgraph "MVC Components"
            Routes["API Routes"]:::backend
            Controllers["Controllers"]:::backend
            Models["Models"]:::backend
        end
        PDF["PDF Report Service"]:::external
        Mapping["Mapping API Service"]:::external
    end

    %% Database
    DB[(MongoDB Database)]:::database

    %% Interactions - Data flow
    Browser -->|"REST-API-calls"| FE
    FE -->|"Fetch/Update Data"| BE
    BE -->|"Delegates-to"| Routes
    Routes -->|"Calls"| Controllers
    Controllers -->|"Uses"| Models
    Models -->|"Persists-to"| DB
    BE -->|"Generates-PDF"| PDF
    BE -->|"Fetches-MapData"| Mapping

    %% Click Events for Components
    click FE "https://github.com/keshalahapuarachchi/transport-management/tree/main/frontend/"
    click NavBar "https://github.com/keshalahapuarachchi/transport-management/blob/main/frontend/src/component/Common/NavBar.jsx"
    click Lorry "https://github.com/keshalahapuarachchi/transport-management/blob/main/frontend/src/component/Screens/Lorry.jsx"
    click Truck "https://github.com/keshalahapuarachchi/transport-management/blob/main/frontend/src/component/Screens/Truck.jsx"
    click Van "https://github.com/keshalahapuarachchi/transport-management/blob/main/frontend/src/component/Screens/Van.jsx"
    click Update "https://github.com/keshalahapuarachchi/transport-management/blob/main/frontend/src/component/Screens/Update/Update.jsx"
    click ListPage "https://github.com/keshalahapuarachchi/transport-management/blob/main/frontend/src/component/listpage/list.jsx"
    click BE "https://github.com/keshalahapuarachchi/transport-management/blob/main/BACKEND/server.js"
    click Routes "https://github.com/keshalahapuarachchi/transport-management/blob/main/BACKEND/routes/deliverVehicles.js"
    click Controllers "https://github.com/keshalahapuarachchi/transport-management/blob/main/BACKEND/controllers/deliverVehicles.js"
    click Models "https://github.com/keshalahapuarachchi/transport-management/blob/main/BACKEND/models/deliverVehicles.js"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef database fill:#ffe082,stroke:#f9a825,stroke-width:2px;
    classDef client fill:#ffccbc,stroke:#bf360c,stroke-width:2px;
    classDef external fill:#d1c4e9,stroke:#7e57c2,stroke-width:2px;
```
