# sujaldhiman/real-time-bus-tracking-system architecture

> Architecture diagram of the GitHub repository sujaldhiman/real-time-bus-tracking-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sujaldhiman/real-time-bus-tracking-system
- Repository: https://github.com/sujaldhiman/real-time-bus-tracking-system

## Overview

This is a real-time bus tracking application: drivers register and log in, publish location and passenger-count updates, and riders find active buses and follow their route on a map. Backend endpoints serve bus, route, and feedback data; Socket.io carries live updates and panic alerts. The README also describes an NLP/ML chatbot, but no chatbot implementation appears in the supplied tree. Edges reflect shown route declarations, calls, or documented capabilities; unsampled relationships are omitted.

Main entry points: [`frontend/busApp/src/main.jsx`](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/main.jsx) (Application routes), [`backend/router/busRoute.js`](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/router/busRoute.js) (Bus API routes), [`frontend/busApp/src/User/TrackVechicle/TrackVechicle.jsx`](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/User/TrackVechicle/TrackVechicle.jsx) (Track bus), [`frontend/busApp/src/Driver/SendLocation/SendLocation.jsx`](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/SendLocation/SendLocation.jsx) (Send location)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_rider["Rider experience"]
  node_app_routes["Application routes<br/>[main.jsx]"]
  node_user_choice["Choose user type<br/>[TypeOfUser.jsx]"]
  node_bus_lookup["Find active buses<br/>[LookupVehicles.jsx]"]
  node_tracking["Track bus<br/>[TrackVechicle.jsx]"]
  node_feedback["Submit feedback<br/>[Feedback.jsx]"]
  node_chatbot["NLP chatbot"]
end

subgraph group_driver["Driver operations"]
  node_driver_register["Register driver<br/>[RegisterDriver.jsx]"]
  node_driver_login["Driver login<br/>[LoginDriver.jsx]"]
  node_driver_dashboard["Bus dashboard<br/>[BusDashboard.jsx]"]
  node_bus_status["Set bus status<br/>[BusStatus.jsx]"]
  node_location_sender["Send location<br/>[SendLocation.jsx]"]
  node_page_context["Page state<br/>[PageContext.jsx]"]
  node_assets["Shared UI assets<br/>[Assets.jsx]"]
end

subgraph group_backend["Backend services"]
  node_api_routes["Bus API routes<br/>[busRoute.js]"]
  node_bus_controller["Bus and feedback logic<br/>[busController.js]"]
  node_models[("Bus route station feedback models")]
  node_http_server["HTTP and socket server<br/>[app.js]"]
  node_database_connection[("Database connection<br/>[db.js]")]
end

subgraph group_state["State and integrations"]
  node_socket_context["Socket client context<br/>[SocketContext.jsx]"]
  node_cache[("Location cache<br/>[cache.js]")]
  node_cloud_storage["Image storage<br/>[cloudStorage.js]"]
  node_google_maps["Google Maps"]
  node_sos_service["SOS mail service"]
  node_config["API and map config<br/>[config.js]"]
end

node_rider(("Rider"))
node_driver_actor(("Bus driver"))

node_rider -->|"opens"| node_app_routes
node_driver_actor -->|"opens"| node_app_routes
node_app_routes -->|"routes to"| node_user_choice
node_app_routes -->|"routes to"| node_driver_register
node_app_routes -->|"routes to"| node_driver_login
node_app_routes -->|"routes to"| node_driver_dashboard
node_app_routes -->|"routes to"| node_bus_status
node_app_routes -->|"routes to"| node_location_sender
node_app_routes -->|"routes to"| node_bus_lookup
node_app_routes -->|"routes to"| node_tracking
node_app_routes -->|"routes to"| node_feedback
node_bus_lookup -.->|"requests buses"| node_api_routes
node_tracking -->|"fetches bus details"| node_api_routes
node_tracking -->|"subscribes updates"| node_socket_context
node_tracking -->|"renders route"| node_google_maps
node_tracking -->|"sends SOS"| node_sos_service
node_feedback -.->|"submits feedback"| node_api_routes
node_driver_register -.->|"registers driver"| node_api_routes
node_driver_login -.->|"authenticates"| node_api_routes
node_location_sender -->|"fetches route"| node_api_routes
node_location_sender -->|"emits location"| node_socket_context
node_location_sender -->|"uses directions"| node_google_maps
node_driver_register -->|"uploads image"| node_cloud_storage
node_api_routes -->|"dispatches handlers"| node_bus_controller
node_bus_controller -->|"reads and writes"| node_models
node_bus_controller -->|"reads progress"| node_cache
node_bus_controller -->|"uploads image"| node_cloud_storage
node_http_server -->|"mounts routes"| node_api_routes
node_http_server -->|"stores locations"| node_cache
node_database_connection -->|"connects before serving"| node_http_server
node_socket_context -->|"connects to server"| node_config
node_chatbot -.->|"answers queries"| node_rider

click node_app_routes "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/main.jsx"
click node_user_choice "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/TypeOfUser.jsx"
click node_bus_lookup "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/User/LookupVehicles/LookupVehicles.jsx"
click node_tracking "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/User/TrackVechicle/TrackVechicle.jsx"
click node_feedback "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Feedback/Feedback.jsx"
click node_driver_register "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/RegisterDriver/RegisterDriver.jsx"
click node_driver_login "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/LoginDriver/LoginDriver.jsx"
click node_driver_dashboard "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/BusDashboard/BusDashboard.jsx"
click node_bus_status "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/BusStatus/BusStatus.jsx"
click node_location_sender "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/SendLocation/SendLocation.jsx"
click node_page_context "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Context/PageContext.jsx"
click node_assets "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Context/Assets.jsx"
click node_api_routes "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/router/busRoute.js"
click node_bus_controller "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/controllers/busController.js"
click node_models "https://github.com/sujaldhiman/real-time-bus-tracking-system/tree/main/backend/model"
click node_http_server "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/app.js"
click node_database_connection "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/Database/db.js"
click node_socket_context "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Context/SocketContext.jsx"
click node_cache "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/Cache/cache.js"
click node_cloud_storage "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/cloudStorage.js"
click node_config "https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Constants/config.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_routes,node_user_choice,node_bus_lookup,node_tracking,node_feedback,node_chatbot toneBlue
class node_driver_register,node_driver_login,node_driver_dashboard,node_bus_status,node_location_sender,node_page_context,node_assets toneAmber
class node_api_routes,node_bus_controller,node_models,node_http_server,node_database_connection toneMint
class node_socket_context,node_cache,node_cloud_storage,node_google_maps,node_sos_service,node_config toneRose
class node_rider,node_driver_actor toneIndigo
```

## Components

### Rider experience

- [Application routes](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/main.jsx): `frontend/busApp/src/main.jsx`
- [Choose user type](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/TypeOfUser.jsx): `frontend/busApp/src/TypeOfUser.jsx`
- [Find active buses](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/User/LookupVehicles/LookupVehicles.jsx): `frontend/busApp/src/User/LookupVehicles/LookupVehicles.jsx`
- [Track bus](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/User/TrackVechicle/TrackVechicle.jsx): `frontend/busApp/src/User/TrackVechicle/TrackVechicle.jsx`
- [Submit feedback](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Feedback/Feedback.jsx): `frontend/busApp/src/Feedback/Feedback.jsx`
- **NLP chatbot**

### Driver operations

- [Register driver](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/RegisterDriver/RegisterDriver.jsx): `frontend/busApp/src/Driver/RegisterDriver/RegisterDriver.jsx`
- [Driver login](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/LoginDriver/LoginDriver.jsx): `frontend/busApp/src/Driver/LoginDriver/LoginDriver.jsx`
- [Bus dashboard](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/BusDashboard/BusDashboard.jsx): `frontend/busApp/src/Driver/BusDashboard/BusDashboard.jsx`
- [Set bus status](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/BusStatus/BusStatus.jsx): `frontend/busApp/src/Driver/BusStatus/BusStatus.jsx`
- [Send location](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Driver/SendLocation/SendLocation.jsx): `frontend/busApp/src/Driver/SendLocation/SendLocation.jsx`
- [Page state](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Context/PageContext.jsx): `frontend/busApp/src/Context/PageContext.jsx`
- [Shared UI assets](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Context/Assets.jsx): `frontend/busApp/src/Context/Assets.jsx`

### Backend services

- [Bus API routes](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/router/busRoute.js): `backend/router/busRoute.js`
- [Bus and feedback logic](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/controllers/busController.js): `backend/controllers/busController.js`
- [Bus route station feedback models](https://github.com/sujaldhiman/real-time-bus-tracking-system/tree/main/backend/model): `backend/model`
- [HTTP and socket server](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/app.js): `backend/app.js`
- [Database connection](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/Database/db.js): `backend/Database/db.js`

### State and integrations

- [Socket client context](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Context/SocketContext.jsx): `frontend/busApp/src/Context/SocketContext.jsx`
- [Location cache](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/Cache/cache.js): `backend/Cache/cache.js`
- [Image storage](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/backend/cloudStorage.js): `backend/cloudStorage.js`
- **Google Maps**
- **SOS mail service**
- [API and map config](https://github.com/sujaldhiman/real-time-bus-tracking-system/blob/main/frontend/busApp/src/Constants/config.js): `frontend/busApp/src/Constants/config.js`

### Other components

- **Rider**
- **Bus driver**

## Connections

- Rider → Application routes: opens (evidence: `frontend/busApp/src/main.jsx`)
- Bus driver → Application routes: opens (evidence: `frontend/busApp/src/main.jsx`)
- Application routes → Choose user type: routes to (evidence: `frontend/busApp/src/main.jsx`)
- Application routes → Register driver: routes to (evidence: `frontend/busApp/src/main.jsx`)
- Application routes → Driver login: routes to (evidence: `frontend/busApp/src/main.jsx`)
- Application routes → Bus dashboard: routes to (evidence: `frontend/busApp/src/main.jsx`)
- Application routes → Set bus status: routes to (evidence: `frontend/busApp/src/main.jsx`)
- Application routes → Send location: routes to (evidence: `frontend/busApp/src/main.jsx`)
- Application routes → Find active buses: routes to (evidence: `frontend/busApp/src/main.jsx`)
- Application routes → Track bus: routes to (evidence: `frontend/busApp/src/main.jsx`)
- Application routes → Submit feedback: routes to (evidence: `frontend/busApp/src/main.jsx`)
- Find active buses → Bus API routes: requests buses
- Track bus → Bus API routes: fetches bus details (evidence: `frontend/busApp/src/User/TrackVechicle/TrackVechicle.jsx`)
- Track bus → Socket client context: subscribes updates (evidence: `frontend/busApp/src/User/TrackVechicle/TrackVechicle.jsx`)
- Track bus → Google Maps: renders route (evidence: `README.md`)
- Track bus → SOS mail service: sends SOS (evidence: `frontend/busApp/src/User/TrackVechicle/TrackVechicle.jsx`)
- Submit feedback → Bus API routes: submits feedback
- Register driver → Bus API routes: registers driver
- Driver login → Bus API routes: authenticates
- Send location → Bus API routes: fetches route (evidence: `frontend/busApp/src/Driver/SendLocation/SendLocation.jsx`)
- Send location → Socket client context: emits location (evidence: `frontend/busApp/src/Driver/SendLocation/SendLocation.jsx`)
- Send location → Google Maps: uses directions (evidence: `frontend/busApp/src/Driver/SendLocation/SendLocation.jsx`)
- Register driver → Image storage: uploads image
- Bus API routes → Bus and feedback logic: dispatches handlers (evidence: `backend/router/busRoute.js`)
- Bus and feedback logic → Bus route station feedback models: reads and writes (evidence: `backend/controllers/busController.js`)
- Bus and feedback logic → Location cache: reads progress (evidence: `backend/controllers/busController.js`)
- Bus and feedback logic → Image storage: uploads image (evidence: `backend/controllers/busController.js`)
- HTTP and socket server → Bus API routes: mounts routes (evidence: `backend/app.js`)
- HTTP and socket server → Location cache: stores locations (evidence: `backend/app.js`)
- Database connection → HTTP and socket server: connects before serving (evidence: `backend/server.js`)
- Socket client context → API and map config: connects to server (evidence: `frontend/busApp/src/Context/SocketContext.jsx`)
- NLP chatbot → Rider: answers queries (evidence: `README.md`)
