# ramtejch07-sudo/aro architecture

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

- Interactive diagram: https://gitdiagram.com/ramtejch07-sudo/aro
- Repository: https://github.com/ramtejch07-sudo/aro

## Overview

Ambulance Route Optimization is a dispatch simulator with a command-line demo and a browser-based REST application. The main workflow records a patient, finds a shortest road-network route, selects an available ambulance by route distance, and records dispatch state. The web API also exposes location, road, fleet, hospital, patient, route, and dispatch-log operations. The sampled API implements dispatch directly over stored JSON data; the separate C++ DispatchManager is used by the console workflow. Some frontend/API links are based on README documentation.

Main entry points: [`src/main.cpp`](https://github.com/ramtejch07-sudo/aro/blob/main/src/main.cpp) (CLI demo), [`server/ApiServer.cpp`](https://github.com/ramtejch07-sudo/aro/blob/main/server/ApiServer.cpp) (API routes), [`src/DispatchManager.cpp`](https://github.com/ramtejch07-sudo/aro/blob/main/src/DispatchManager.cpp) (Dispatch manager), [`src/Graph.cpp`](https://github.com/ramtejch07-sudo/aro/blob/main/src/Graph.cpp) (Road graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_browser["Browser console<br/>[app.js]"]
end

subgraph group_api["REST API"]
  node_api_server["API routes<br/>[ApiServer.cpp]"]
  node_database[("JSON persistence<br/>[Database.cpp]")]
end

subgraph group_domain["Dispatch domain"]
  node_road_graph["Road graph<br/>[Graph.cpp]"]
  node_location["Map locations<br/>[Location.cpp]"]
  node_route_optimizer["Route optimizer<br/>[RouteOptimizer.cpp]"]
  node_dispatch_manager["Dispatch manager"]
  node_patient["Patient<br/>[Patient.cpp]"]
  node_ambulance["Ambulance<br/>[Ambulance.cpp]"]
  node_vehicle["Vehicle base<br/>[Vehicle.cpp]"]
  node_hospital["Hospital<br/>[Hospital.cpp]"]
end

subgraph group_console["Console demo"]
  node_console_demo["CLI demo<br/>[main.cpp]"]
end

node_operator(("Operator"))
node_json_disk[("JSON file")]

node_operator -->|"uses"| node_browser
node_browser -->|"requests data"| node_api_server
node_api_server -->|"reads and writes"| node_database
node_database -->|"loads and saves"| node_json_disk
node_api_server -->|"rebuilds graph"| node_road_graph
node_api_server -->|"looks up routes"| node_route_optimizer
node_route_optimizer -->|"queries neighbors"| node_road_graph
node_road_graph -->|"stores locations"| node_location
node_console_demo -->|"builds network"| node_road_graph
node_console_demo -->|"checks route"| node_route_optimizer
node_console_demo -->|"requests dispatch"| node_dispatch_manager
node_console_demo -->|"creates patient"| node_patient
node_console_demo -->|"sets up hospital"| node_hospital
node_console_demo -->|"sets up fleet"| node_ambulance
node_dispatch_manager -->|"reads location"| node_patient
node_dispatch_manager -->|"compares routes"| node_route_optimizer
node_dispatch_manager -->|"selects and dispatches"| node_ambulance
node_ambulance -->|"inherits behavior"| node_vehicle
node_vehicle -->|"tracks position"| node_location

click node_browser "https://github.com/ramtejch07-sudo/aro/blob/main/web/app.js"
click node_api_server "https://github.com/ramtejch07-sudo/aro/blob/main/server/ApiServer.cpp"
click node_database "https://github.com/ramtejch07-sudo/aro/blob/main/server/Database.cpp"
click node_road_graph "https://github.com/ramtejch07-sudo/aro/blob/main/src/Graph.cpp"
click node_location "https://github.com/ramtejch07-sudo/aro/blob/main/src/Location.cpp"
click node_route_optimizer "https://github.com/ramtejch07-sudo/aro/blob/main/src/RouteOptimizer.cpp"
click node_dispatch_manager "https://github.com/ramtejch07-sudo/aro/blob/main/src/DispatchManager.cpp"
click node_patient "https://github.com/ramtejch07-sudo/aro/blob/main/src/Patient.cpp"
click node_ambulance "https://github.com/ramtejch07-sudo/aro/blob/main/src/Ambulance.cpp"
click node_vehicle "https://github.com/ramtejch07-sudo/aro/blob/main/src/Vehicle.cpp"
click node_hospital "https://github.com/ramtejch07-sudo/aro/blob/main/src/Hospital.cpp"
click node_console_demo "https://github.com/ramtejch07-sudo/aro/blob/main/src/main.cpp"

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_browser toneBlue
class node_api_server,node_database,node_json_disk toneAmber
class node_road_graph,node_location,node_route_optimizer,node_dispatch_manager,node_patient,node_ambulance,node_vehicle,node_hospital toneMint
class node_console_demo toneRose
class node_operator toneIndigo
```

## Components

### Web application

- [Browser console](https://github.com/ramtejch07-sudo/aro/blob/main/web/app.js): `web/app.js`

### REST API

- [API routes](https://github.com/ramtejch07-sudo/aro/blob/main/server/ApiServer.cpp): `server/ApiServer.cpp`
- [JSON persistence](https://github.com/ramtejch07-sudo/aro/blob/main/server/Database.cpp): `server/Database.cpp`

### Dispatch domain

- [Road graph](https://github.com/ramtejch07-sudo/aro/blob/main/src/Graph.cpp): `src/Graph.cpp`
- [Map locations](https://github.com/ramtejch07-sudo/aro/blob/main/src/Location.cpp): `src/Location.cpp`
- [Route optimizer](https://github.com/ramtejch07-sudo/aro/blob/main/src/RouteOptimizer.cpp): `src/RouteOptimizer.cpp`
- [Dispatch manager](https://github.com/ramtejch07-sudo/aro/blob/main/src/DispatchManager.cpp): `src/DispatchManager.cpp`
- [Patient](https://github.com/ramtejch07-sudo/aro/blob/main/src/Patient.cpp): `src/Patient.cpp`
- [Ambulance](https://github.com/ramtejch07-sudo/aro/blob/main/src/Ambulance.cpp): `src/Ambulance.cpp`
- [Vehicle base](https://github.com/ramtejch07-sudo/aro/blob/main/src/Vehicle.cpp): `src/Vehicle.cpp`
- [Hospital](https://github.com/ramtejch07-sudo/aro/blob/main/src/Hospital.cpp): `src/Hospital.cpp`

### Console demo

- [CLI demo](https://github.com/ramtejch07-sudo/aro/blob/main/src/main.cpp): `src/main.cpp`

### Other components

- **Operator**
- **JSON file**

## Connections

- Operator → Browser console: uses (evidence: `README.md`)
- Browser console → API routes: requests data (evidence: `README.md`)
- API routes → JSON persistence: reads and writes (evidence: `server/ApiServer.cpp`)
- JSON persistence → JSON file: loads and saves (evidence: `server/Database.cpp`)
- API routes → Road graph: rebuilds graph (evidence: `server/ApiServer.cpp`)
- API routes → Route optimizer: looks up routes (evidence: `server/ApiServer.cpp`)
- Route optimizer → Road graph: queries neighbors (evidence: `README.md`)
- Road graph → Map locations: stores locations
- CLI demo → Road graph: builds network (evidence: `src/main.cpp`)
- CLI demo → Route optimizer: checks route (evidence: `src/main.cpp`)
- CLI demo → Dispatch manager: requests dispatch (evidence: `src/main.cpp`)
- CLI demo → Patient: creates patient (evidence: `src/main.cpp`)
- CLI demo → Hospital: sets up hospital (evidence: `src/main.cpp`)
- CLI demo → Ambulance: sets up fleet (evidence: `src/main.cpp`)
- Dispatch manager → Patient: reads location (evidence: `src/DispatchManager.cpp`)
- Dispatch manager → Route optimizer: compares routes (evidence: `src/DispatchManager.cpp`)
- Dispatch manager → Ambulance: selects and dispatches (evidence: `src/DispatchManager.cpp`)
- Ambulance → Vehicle base: inherits behavior
- Vehicle base → Map locations: tracks position
