# apsdeveloper461/uet_routes_managenment_backend architecture

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

- Interactive diagram: https://gitdiagram.com/apsdeveloper461/uet_routes_managenment_backend
- Repository: https://github.com/apsdeveloper461/uet_routes_managenment_backend

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Services Layer:
- Authentication Service (handling both Admin and User authentication)
- Route Management Service
- Driver Management Service
- Stop Management Service
- Complaint Management Service
- Chat Service (indicated by chatHandler.js and pusher.js)

b) Data Layer:
- Database (MongoDB, based on the models structure)
- Models:
- User
- Admin
- Driver
- Route
- Stop
- Complaint
- Chat/Messages

c) API Layer:
- Admin API endpoints
- User API endpoints
- Driver API endpoints

**[Client Applications] (External)**
- ↕
**[API Gateway Layer]**
- ↕
**[Service Layer]**
- ↕
**[Data Layer]**

##### Specific Component Details

a) API Gateway Layer:
- Admin APIs (purple)
- User APIs (blue)
- Driver APIs (green)

- Authentication Service
- JWT Token Handler
- Email Verification
- Route Management Service
- Driver Management Service
- Stop Management Service
- Complaint Management Service
- Real-time Chat Service

- MongoDB Collections
- Relationships between models using connecting lines

##### Flow Representations

- → Synchronous operations
- ⇢ Asynchronous operations
- ⇄ Two-way communication (for real-time features)

##### Additional Elements

Supporting components:
- Email Service (indicated by send-email.js)
- Pusher Service (for real-time features)
- JWT Token Handler
- Database Connection Pool

##### Key Interactions to Highlight

- Authentication flows (login/register)
- Route management workflows
- Complaint handling process
- Real-time chat system
- Email verification process

##### Specific Implementation Notes

- Token-based authentication flow
- Email verification process
- CRUD operations for routes, stops, and drivers
- Complaint management workflow
- Real-time chat implementation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CA[Client Applications]
    end

    subgraph API_Gateway
        AA["Admin API"]:::api
        UA["User API"]:::api
        DA["Driver API"]:::api
    end

    subgraph Services
        AS["Authentication Service"]:::service
        RMS["Route Management"]:::service
        DMS["Driver Management"]:::service
        SMS["Stop Management"]:::service
        CMS["Complaint Management"]:::service
        CS["Chat Service"]:::service
        ES["Email Service"]:::service
        JH["JWT Handler"]:::service
        PS["Pusher Service"]:::service
    end

    subgraph Database
        DB[(MongoDB)]:::db
        subgraph Models
            UM[("User Model")]:::model
            AM[("Admin Model")]:::model
            DM[("Driver Model")]:::model
            RM[("Route Model")]:::model
            SM[("Stop Model")]:::model
            CM[("Complaint Model")]:::model
            CHM[("Chat Model")]:::model
            MM[("Message Model")]:::model
        end
    end

    %% Client to API connections
    CA --> AA & UA & DA

    %% API to Service connections
    AA --> AS & RMS & DMS & SMS & CMS
    UA --> AS & CMS & CS
    DA --> AS & RMS

    %% Service interconnections
    AS --> JH
    AS --> ES
    CS --> PS
    
    %% Service to Database connections
    AS --> UM & AM & DM
    RMS --> RM
    DMS --> DM
    SMS --> SM
    CMS --> CM
    CS --> CHM & MM

    %% Click events for component mapping
    click AA "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/api/admin_api.js"
    click UA "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/api/user_api.js"
    click DA "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/api/driver_api.js"
    click JH "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/controller/jwt-token.js"
    click RMS "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/controller/admin/routes_handler.js"
    click DMS "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/controller/admin/driver_handler.js"
    click SMS "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/controller/admin/stops_handler.js"
    click CMS "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/controller/admin/complaint_handler.js"
    click CS "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/chatHandler.js"
    click PS "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/pusher.js"
    click ES "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/controller/send-email.js"
    click UM "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/models/User.js"
    click AM "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/models/Admin.js"
    click DM "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/models/Driver.js"
    click RM "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/models/Route.js"
    click SM "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/models/Stop.js"
    click CM "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/models/Complaint.js"
    click CHM "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/models/Chat.js"
    click MM "https://github.com/apsdeveloper461/UET_ROUTES_MANAGENMENT_BACKEND/blob/main/models/Messages.js"

    classDef api fill:#6b63ff,stroke:#333,stroke-width:2px
    classDef service fill:#40c463,stroke:#333,stroke-width:2px
    classDef db fill:#8957e5,stroke:#333,stroke-width:2px
    classDef model fill:#d2a8ff,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["API Gateway"]:::api
        L2["Services"]:::service
        L3[("Database")]:::db
        L4[("Models")]:::model
    end
```
