# hasnainarefin/project-2-1-ambulance-management-system architecture

> Architecture diagram of the GitHub repository hasnainarefin/project-2-1-ambulance-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hasnainarefin/project-2-1-ambulance-management-system
- Repository: https://github.com/hasnainarefin/project-2-1-ambulance-management-system

## Overview

This is a terminal-based Khulna ambulance dispatch system. Users register or select a patient and request service; dispatch assigns an ambulance, routes it to the patient, selects a hospital, and records the completed trip. Administrators manage fleet, hospitals, accounts, and city analytics. The graph, queues, and record collections are in-memory; main.cpp loads and saves records as plain-text files. Relationships are limited to calls and data use visible in excerpts or explicitly documented by source comments; unsampled menu and storage details are not inferred.

Main entry points: [`app_menu.cpp`](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/app_menu.cpp) (Application menus), [`dispatch.cpp`](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/dispatch.cpp) (Trip dispatch), [`fleet_hospitals.cpp`](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/fleet_hospitals.cpp) (Ambulance fleet), [`main.cpp`](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/main.cpp) (Saved records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_app["Application menus<br/>[app_menu.cpp]"]
end

subgraph group_dispatch["Dispatch operations"]
  node_dispatch_run["Trip dispatch<br/>[dispatch.cpp]"]
  node_requests["Request queues<br/>[requests.cpp]"]
end

subgraph group_city["City and routing"]
  node_road_graph["Road network<br/>[city_graph.cpp]"]
  node_routing["Distance ranking and search<br/>[sort_search.cpp]"]
  node_traversal["BFS, DFS, zones<br/>[traversal.cpp]"]
  node_map["Map and animation<br/>[map_view.cpp]"]
end

subgraph group_records["Records and persistence"]
  node_fleet["Ambulance fleet"]
  node_hospitals["Hospital records"]
  node_patients_accounts["Patients and accounts<br/>[hash_tables.cpp]"]
  node_trip_history["Trip and action history<br/>[trip_history.cpp]"]
  node_flat_files[("Saved records<br/>[main.cpp]")]
  node_shared["Shared records and utilities<br/>[common.cpp]"]
end

node_user(("User"))
node_admin(("Administrator"))

node_user -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"starts dispatch"| node_dispatch_run
node_app -->|"manages requests"| node_requests
node_app -->|"manages accounts"| node_patients_accounts
node_dispatch_run -->|"assigns ambulance"| node_fleet
node_dispatch_run -->|"selects hospital"| node_hospitals
node_dispatch_run -->|"animates route"| node_map
node_dispatch_run -->|"logs completed trip"| node_trip_history
node_dispatch_run -->|"computes routes"| node_road_graph
node_fleet -->|"ranks by distance"| node_road_graph
node_fleet -->|"sorts distances"| node_routing
node_fleet -->|"checks reachability"| node_traversal
node_map -->|"renders roads"| node_road_graph
node_road_graph -->|"uses shared definitions"| node_shared
node_patients_accounts -->|"uses shared records"| node_shared
node_requests -->|"uses shared utilities"| node_shared
node_trip_history -->|"sorts trip report"| node_routing
node_app -->|"offers city analytics"| node_traversal
node_app -->|"shows city map"| node_map
node_app -->|"searches locations"| node_routing
node_flat_files -->|"loads and saves"| node_fleet
node_flat_files -->|"loads and saves"| node_hospitals
node_flat_files -->|"loads and saves"| node_patients_accounts
node_flat_files -->|"loads and saves"| node_trip_history
node_app -->|"manages fleet"| node_fleet
node_app -->|"manages hospitals"| node_hospitals

click node_app "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/app_menu.cpp"
click node_dispatch_run "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/dispatch.cpp"
click node_requests "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/requests.cpp"
click node_fleet "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/fleet_hospitals.cpp"
click node_hospitals "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/fleet_hospitals.cpp"
click node_patients_accounts "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/hash_tables.cpp"
click node_trip_history "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/trip_history.cpp"
click node_flat_files "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/main.cpp"
click node_road_graph "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/city_graph.cpp"
click node_routing "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/sort_search.cpp"
click node_traversal "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/traversal.cpp"
click node_map "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/map_view.cpp"
click node_shared "https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/common.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_app,node_user toneBlue
class node_dispatch_run,node_requests toneAmber
class node_road_graph,node_routing,node_traversal,node_map toneMint
class node_fleet,node_hospitals,node_patients_accounts,node_trip_history,node_flat_files,node_shared toneRose
class node_admin toneIndigo
```

## Components

### User interaction

- [Application menus](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/app_menu.cpp): `app_menu.cpp`

### Dispatch operations

- [Trip dispatch](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/dispatch.cpp): `dispatch.cpp`
- [Request queues](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/requests.cpp): `requests.cpp`

### City and routing

- [Road network](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/city_graph.cpp): `city_graph.cpp`
- [Distance ranking and search](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/sort_search.cpp): `sort_search.cpp`
- [BFS, DFS, zones](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/traversal.cpp): `traversal.cpp`
- [Map and animation](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/map_view.cpp): `map_view.cpp`

### Records and persistence

- [Ambulance fleet](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/fleet_hospitals.cpp): `fleet_hospitals.cpp`
- [Hospital records](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/fleet_hospitals.cpp): `fleet_hospitals.cpp`
- [Patients and accounts](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/hash_tables.cpp): `hash_tables.cpp`
- [Trip and action history](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/trip_history.cpp): `trip_history.cpp`
- [Saved records](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/main.cpp): `main.cpp`
- [Shared records and utilities](https://github.com/hasnainarefin/project-2-1-ambulance-management-system/blob/main/common.cpp): `common.cpp`

### Other components

- **User**
- **Administrator**

## Connections

- User → Application menus: uses
- Administrator → Application menus: uses
- Application menus → Trip dispatch: starts dispatch (evidence: `app_menu.cpp`)
- Application menus → Request queues: manages requests (evidence: `app_menu.cpp`)
- Application menus → Patients and accounts: manages accounts (evidence: `app_menu.cpp`)
- Trip dispatch → Ambulance fleet: assigns ambulance (evidence: `dispatch.cpp`)
- Trip dispatch → Hospital records: selects hospital (evidence: `dispatch.cpp`)
- Trip dispatch → Map and animation: animates route (evidence: `dispatch.cpp`)
- Trip dispatch → Trip and action history: logs completed trip (evidence: `dispatch.cpp`)
- Trip dispatch → Road network: computes routes (evidence: `dispatch.cpp`)
- Ambulance fleet → Road network: ranks by distance (evidence: `fleet_hospitals.cpp`)
- Ambulance fleet → Distance ranking and search: sorts distances (evidence: `fleet_hospitals.cpp`)
- Ambulance fleet → BFS, DFS, zones: checks reachability (evidence: `fleet_hospitals.cpp`)
- Map and animation → Road network: renders roads (evidence: `map_view.cpp`)
- Road network → Shared records and utilities: uses shared definitions (evidence: `city_graph.cpp`)
- Patients and accounts → Shared records and utilities: uses shared records (evidence: `hash_tables.cpp`)
- Request queues → Shared records and utilities: uses shared utilities (evidence: `requests.cpp`)
- Trip and action history → Distance ranking and search: sorts trip report (evidence: `trip_history.cpp`)
- Application menus → BFS, DFS, zones: offers city analytics (evidence: `app_menu.cpp`)
- Application menus → Map and animation: shows city map (evidence: `app_menu.cpp`)
- Application menus → Distance ranking and search: searches locations (evidence: `app_menu.cpp`)
- Saved records → Ambulance fleet: loads and saves (evidence: `main.cpp`)
- Saved records → Hospital records: loads and saves (evidence: `main.cpp`)
- Saved records → Patients and accounts: loads and saves (evidence: `main.cpp`)
- Saved records → Trip and action history: loads and saves (evidence: `main.cpp`)
- Application menus → Ambulance fleet: manages fleet (evidence: `app_menu.cpp`)
- Application menus → Hospital records: manages hospitals (evidence: `app_menu.cpp`)
