# buvan45/ambulance-route-optimization-problem architecture

> Architecture diagram of the GitHub repository buvan45/ambulance-route-optimization-problem, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/buvan45/ambulance-route-optimization-problem
- Repository: https://github.com/buvan45/ambulance-route-optimization-problem

## Overview

Trailz is an ambulance dispatch and live-navigation system. A dispatcher signs in, submits a patient location and required specialty, and receives a selected ambulance and hospital; the driver gets the job, shares GPS updates, follows route guidance, and completes the mission, which is logged for history and administration. The frontend also provides fleet, hospital, and dispatch analytics. The backend and key UI interactions are excerpted; several screens are represented from the SOURCE INDEX and README, so their internal behavior and some connections are not asserted.

Main entry points: [`backend/app.py`](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/backend/app.py) (Dispatch API and Events), [`frontend/Trailz-react/src/App.jsx`](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/App.jsx) (App Routes), [`frontend/Trailz-react/src/AmbulanceDispatch.jsx`](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/AmbulanceDispatch.jsx) (Dispatch Request), [`frontend/Trailz-react/src/DriverStandby.jsx`](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/DriverStandby.jsx) (Driver Standby)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and Routing"]
  node_app_routes["App Routes<br/>[App.jsx]"]
  node_dispatcher_auth["Dispatcher Access<br/>[Dispatcher.jsx]"]
  node_login["Login<br/>[Login.jsx]"]
  node_signup["Signup<br/>[Signup.jsx]"]
  node_api_config["API Base<br/>[api.js]"]
end

subgraph group_dispatch["Dispatch Operations"]
  node_dashboard["Dispatcher Dashboard<br/>[Dashboard.jsx]"]
  node_dispatch_form["Dispatch Request"]
  node_history["Dispatch History<br/>[History.jsx]"]
end

subgraph group_driver["Driver Navigation"]
  node_driver_standby["Driver Standby<br/>[DriverStandby.jsx]"]
  node_driver_view["Live Driver View<br/>[DriverView.jsx]"]
  node_map["Live Map<br/>[LeafletMap.jsx]"]
  node_socket_client["Socket Client<br/>[socket.js]"]
end

subgraph group_admin["Administration"]
  node_admin_entry["Admin Entry<br/>[Admin.jsx]"]
  node_admin_login["Admin Login<br/>[AdminLogin.jsx]"]
  node_admin_dashboard["Admin Dashboard<br/>[AdminDashboard.jsx]"]
end

subgraph group_backend["Backend Services"]
  node_backend_app["Dispatch API and Events<br/>[app.py]"]
  node_auth_service["Authentication and Admin API<br/>[auth.py]"]
  node_db_layer[("Database Collections<br/>[db.py]")]
end

node_dispatcher(("Dispatcher"))
node_driver_actor(("Ambulance Driver"))
node_admin_actor(("Administrator"))
node_tomtom["TomTom Routing"]
node_mongo[("MongoDB")]

node_dispatcher -->|"opens app"| node_app_routes
node_app_routes -->|"defaults to"| node_dispatcher_auth
node_app_routes -->|"routes to"| node_driver_standby
node_app_routes -->|"routes to"| node_driver_view
node_app_routes -->|"routes to"| node_admin_entry
node_dispatcher_auth -->|"renders"| node_login
node_dispatcher_auth -->|"renders"| node_signup
node_dispatcher_auth -->|"renders"| node_dashboard
node_dashboard -->|"renders"| node_dispatch_form
node_dashboard -->|"renders"| node_history
node_dispatch_form -->|"requests route"| node_backend_app
node_dispatch_form -->|"joins dispatch room"| node_socket_client
node_socket_client -->|"exchanges events"| node_backend_app
node_driver_actor -->|"opens standby"| node_driver_standby
node_driver_standby -->|"joins unit room"| node_socket_client
node_driver_standby -->|"opens dispatch"| node_driver_view
node_driver_view -->|"sends GPS and actions"| node_socket_client
node_driver_view -->|"renders route"| node_map
node_dispatch_form -->|"renders tracking map"| node_map
node_admin_actor -->|"opens admin"| node_app_routes
node_admin_entry -->|"renders"| node_admin_login
node_admin_entry -->|"renders"| node_admin_dashboard
node_admin_dashboard -->|"fetches operations data"| node_backend_app
node_login -->|"uses API base"| node_api_config
node_signup -->|"uses API base"| node_api_config
node_history -->|"uses API base"| node_api_config
node_admin_dashboard -->|"uses API base"| node_api_config
node_backend_app -->|"registers blueprints"| node_auth_service
node_auth_service -->|"reads and writes"| node_db_layer
node_backend_app -->|"queries and updates"| node_db_layer
node_db_layer -->|"stores collections"| node_mongo
node_backend_app -->|"geocodes and routes"| node_tomtom
node_backend_app -->|"returns dispatch result"| node_dispatch_form
node_backend_app -->|"sends route updates"| node_driver_view
node_backend_app -->|"notifies pending job"| node_driver_standby

click node_app_routes "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/App.jsx"
click node_dispatcher_auth "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/Dispatcher.jsx"
click node_login "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/Login.jsx"
click node_signup "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/Signup.jsx"
click node_api_config "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/api.js"
click node_dashboard "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/Dashboard.jsx"
click node_dispatch_form "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/AmbulanceDispatch.jsx"
click node_history "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/History.jsx"
click node_driver_standby "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/DriverStandby.jsx"
click node_driver_view "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/DriverView.jsx"
click node_map "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/LeafletMap.jsx"
click node_socket_client "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/socket.js"
click node_admin_entry "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/Admin.jsx"
click node_admin_login "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/AdminLogin.jsx"
click node_admin_dashboard "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/AdminDashboard.jsx"
click node_backend_app "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/backend/app.py"
click node_auth_service "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/backend/auth.py"
click node_db_layer "https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/backend/db.py"

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_dispatcher_auth,node_login,node_signup,node_api_config toneBlue
class node_dashboard,node_dispatch_form,node_history,node_mongo toneAmber
class node_driver_standby,node_driver_view,node_map,node_socket_client toneMint
class node_admin_entry,node_admin_login,node_admin_dashboard toneRose
class node_backend_app,node_auth_service,node_db_layer,node_dispatcher,node_driver_actor,node_admin_actor,node_tomtom toneIndigo
```

## Components

### Access and Routing

- [App Routes](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/App.jsx): `frontend/Trailz-react/src/App.jsx`
- [Dispatcher Access](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/Dispatcher.jsx): `frontend/Trailz-react/src/Dispatcher.jsx`
- [Login](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/Login.jsx): `frontend/Trailz-react/src/Login.jsx`
- [Signup](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/Signup.jsx): `frontend/Trailz-react/src/Signup.jsx`
- [API Base](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/api.js): `frontend/Trailz-react/src/api.js`

### Dispatch Operations

- [Dispatcher Dashboard](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/Dashboard.jsx): `frontend/Trailz-react/src/Dashboard.jsx`
- [Dispatch Request](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/AmbulanceDispatch.jsx): `frontend/Trailz-react/src/AmbulanceDispatch.jsx`
- [Dispatch History](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/History.jsx): `frontend/Trailz-react/src/History.jsx`

### Driver Navigation

- [Driver Standby](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/DriverStandby.jsx): `frontend/Trailz-react/src/DriverStandby.jsx`
- [Live Driver View](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/DriverView.jsx): `frontend/Trailz-react/src/DriverView.jsx`
- [Live Map](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/LeafletMap.jsx): `frontend/Trailz-react/src/LeafletMap.jsx`
- [Socket Client](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/socket.js): `frontend/Trailz-react/src/socket.js`

### Administration

- [Admin Entry](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/Admin.jsx): `frontend/Trailz-react/src/Admin.jsx`
- [Admin Login](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/AdminLogin.jsx): `frontend/Trailz-react/src/AdminLogin.jsx`
- [Admin Dashboard](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/frontend/Trailz-react/src/AdminDashboard.jsx): `frontend/Trailz-react/src/AdminDashboard.jsx`

### Backend Services

- [Dispatch API and Events](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/backend/app.py): `backend/app.py`
- [Authentication and Admin API](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/backend/auth.py): `backend/auth.py`
- [Database Collections](https://github.com/buvan45/ambulance-route-optimization-problem/blob/main/backend/db.py): `backend/db.py`

### Other components

- **Dispatcher**
- **Ambulance Driver**
- **Administrator**
- **TomTom Routing**
- **MongoDB**

## Connections

- Dispatcher → App Routes: opens app (evidence: `README.md`)
- App Routes → Dispatcher Access: defaults to (evidence: `frontend/Trailz-react/src/App.jsx`)
- App Routes → Driver Standby: routes to (evidence: `frontend/Trailz-react/src/App.jsx`)
- App Routes → Live Driver View: routes to (evidence: `frontend/Trailz-react/src/App.jsx`)
- App Routes → Admin Entry: routes to (evidence: `frontend/Trailz-react/src/App.jsx`)
- Dispatcher Access → Login: renders (evidence: `frontend/Trailz-react/src/Dispatcher.jsx`)
- Dispatcher Access → Signup: renders (evidence: `frontend/Trailz-react/src/Dispatcher.jsx`)
- Dispatcher Access → Dispatcher Dashboard: renders (evidence: `frontend/Trailz-react/src/Dispatcher.jsx`)
- Dispatcher Dashboard → Dispatch Request: renders (evidence: `frontend/Trailz-react/src/Dashboard.jsx`)
- Dispatcher Dashboard → Dispatch History: renders (evidence: `frontend/Trailz-react/src/Dashboard.jsx`)
- Dispatch Request → Dispatch API and Events: requests route (evidence: `frontend/Trailz-react/src/AmbulanceDispatch.jsx`)
- Dispatch Request → Socket Client: joins dispatch room (evidence: `frontend/Trailz-react/src/AmbulanceDispatch.jsx`)
- Socket Client → Dispatch API and Events: exchanges events (evidence: `backend/app.py`)
- Ambulance Driver → Driver Standby: opens standby (evidence: `README.md`)
- Driver Standby → Socket Client: joins unit room (evidence: `frontend/Trailz-react/src/DriverStandby.jsx`)
- Driver Standby → Live Driver View: opens dispatch (evidence: `frontend/Trailz-react/src/DriverStandby.jsx`)
- Live Driver View → Socket Client: sends GPS and actions (evidence: `frontend/Trailz-react/src/DriverView.jsx`)
- Live Driver View → Live Map: renders route (evidence: `frontend/Trailz-react/src/DriverView.jsx`)
- Dispatch Request → Live Map: renders tracking map (evidence: `frontend/Trailz-react/src/AmbulanceDispatch.jsx`)
- Administrator → App Routes: opens admin (evidence: `README.md`)
- Admin Entry → Admin Login: renders (evidence: `frontend/Trailz-react/src/Admin.jsx`)
- Admin Entry → Admin Dashboard: renders (evidence: `frontend/Trailz-react/src/Admin.jsx`)
- Admin Dashboard → Dispatch API and Events: fetches operations data (evidence: `frontend/Trailz-react/src/AdminDashboard.jsx`)
- Login → API Base: uses API base (evidence: `frontend/Trailz-react/src/Login.jsx`)
- Signup → API Base: uses API base (evidence: `frontend/Trailz-react/src/Signup.jsx`)
- Dispatch History → API Base: uses API base (evidence: `frontend/Trailz-react/src/History.jsx`)
- Admin Dashboard → API Base: uses API base (evidence: `frontend/Trailz-react/src/AdminDashboard.jsx`)
- Dispatch API and Events → Authentication and Admin API: registers blueprints (evidence: `backend/app.py`)
- Authentication and Admin API → Database Collections: reads and writes (evidence: `backend/auth.py`)
- Dispatch API and Events → Database Collections: queries and updates (evidence: `backend/app.py`)
- Database Collections → MongoDB: stores collections (evidence: `backend/db.py`)
- Dispatch API and Events → TomTom Routing: geocodes and routes (evidence: `backend/app.py`)
- Dispatch API and Events → Dispatch Request: returns dispatch result (evidence: `frontend/Trailz-react/src/AmbulanceDispatch.jsx`)
- Dispatch API and Events → Live Driver View: sends route updates (evidence: `backend/app.py`)
- Dispatch API and Events → Driver Standby: notifies pending job (evidence: `backend/app.py`)
