# zamdam2026/er-triage-simulator architecture

> Architecture diagram of the GitHub repository zamdam2026/er-triage-simulator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zamdam2026/er-triage-simulator
- Repository: https://github.com/zamdam2026/er-triage-simulator

## Overview

ER Triage Simulator models a batch of patients, runs the same scenario under three scheduling policies, and compares waiting-time, turnaround, and fairness metrics. Users can start this workflow from either the Streamlit interface or terminal CLI. Patient records carry the scenario and simulation state; scheduler implementations apply the distinct triage-priority, round-robin, and lottery strategies. The README describes a hospital-administration and disaster-response positioning, but the available source shows simulation and comparison rather than integrations with hospital systems. The map follows the supplied source excerpts.

Main entry points: [`app.py`](https://github.com/zamdam2026/er-triage-simulator/blob/main/app.py) (Streamlit interface), [`cli.py`](https://github.com/zamdam2026/er-triage-simulator/blob/main/cli.py) (Terminal interface), [`simulator.py`](https://github.com/zamdam2026/er-triage-simulator/blob/main/simulator.py) (Policy runner), [`stats.py`](https://github.com/zamdam2026/er-triage-simulator/blob/main/stats.py) (Metric comparison)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["User Interfaces"]
  node_web_app["Streamlit interface<br/>[app.py]"]
  node_terminal_cli["Terminal interface<br/>[cli.py]"]
end

subgraph group_simulation["Simulation"]
  node_generator["Patient generation<br/>[simulator.py]"]
  node_patient["Patient record<br/>[patient.py]"]
  node_orchestrator["Policy runner<br/>[simulator.py]"]
  node_priority["Triage priority<br/>[schedulers.py]"]
  node_round_robin["Doctor rounds<br/>[schedulers.py]"]
  node_lottery["Quick consults<br/>[schedulers.py]"]
end

subgraph group_analysis["Outcome Analysis"]
  node_comparison["Metric comparison<br/>[stats.py]"]
  node_summary["Wait and fairness metrics<br/>[stats.py]"]
  node_best_policy["Equity selection<br/>[stats.py]"]
end

node_web_user(("Web user"))
node_terminal_user(("Terminal user"))

node_web_user -->|"sets scenario"| node_web_app
node_terminal_user -->|"enters scenario"| node_terminal_cli
node_web_app -->|"generates patients"| node_generator
node_terminal_cli -->|"generates patients"| node_generator
node_generator -->|"creates records"| node_patient
node_web_app -->|"runs policies"| node_orchestrator
node_terminal_cli -->|"runs policies"| node_orchestrator
node_orchestrator -->|"dispatches"| node_priority
node_orchestrator -->|"dispatches"| node_round_robin
node_orchestrator -->|"dispatches"| node_lottery
node_web_app -->|"compares outcomes"| node_comparison
node_terminal_cli -->|"compares outcomes"| node_comparison
node_comparison -->|"summarizes"| node_summary
node_web_app -->|"selects by equity"| node_best_policy
node_terminal_cli -->|"selects by equity"| node_best_policy
node_web_app -->|"shows results"| node_web_user
node_terminal_cli -->|"prints results"| node_terminal_user

click node_web_app "https://github.com/zamdam2026/er-triage-simulator/blob/main/app.py"
click node_terminal_cli "https://github.com/zamdam2026/er-triage-simulator/blob/main/cli.py"
click node_generator "https://github.com/zamdam2026/er-triage-simulator/blob/main/simulator.py"
click node_patient "https://github.com/zamdam2026/er-triage-simulator/blob/main/patient.py"
click node_orchestrator "https://github.com/zamdam2026/er-triage-simulator/blob/main/simulator.py"
click node_priority "https://github.com/zamdam2026/er-triage-simulator/blob/main/schedulers.py"
click node_round_robin "https://github.com/zamdam2026/er-triage-simulator/blob/main/schedulers.py"
click node_lottery "https://github.com/zamdam2026/er-triage-simulator/blob/main/schedulers.py"
click node_comparison "https://github.com/zamdam2026/er-triage-simulator/blob/main/stats.py"
click node_summary "https://github.com/zamdam2026/er-triage-simulator/blob/main/stats.py"
click node_best_policy "https://github.com/zamdam2026/er-triage-simulator/blob/main/stats.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_web_app,node_terminal_cli,node_web_user,node_terminal_user toneBlue
class node_generator,node_patient,node_orchestrator,node_priority,node_round_robin,node_lottery toneAmber
class node_comparison,node_summary,node_best_policy toneMint
```

## Components

### User Interfaces

- [Streamlit interface](https://github.com/zamdam2026/er-triage-simulator/blob/main/app.py): `app.py`
- [Terminal interface](https://github.com/zamdam2026/er-triage-simulator/blob/main/cli.py): `cli.py`

### Simulation

- [Patient generation](https://github.com/zamdam2026/er-triage-simulator/blob/main/simulator.py): `simulator.py`
- [Patient record](https://github.com/zamdam2026/er-triage-simulator/blob/main/patient.py): `patient.py`
- [Policy runner](https://github.com/zamdam2026/er-triage-simulator/blob/main/simulator.py): `simulator.py`
- [Triage priority](https://github.com/zamdam2026/er-triage-simulator/blob/main/schedulers.py): `schedulers.py`
- [Doctor rounds](https://github.com/zamdam2026/er-triage-simulator/blob/main/schedulers.py): `schedulers.py`
- [Quick consults](https://github.com/zamdam2026/er-triage-simulator/blob/main/schedulers.py): `schedulers.py`

### Outcome Analysis

- [Metric comparison](https://github.com/zamdam2026/er-triage-simulator/blob/main/stats.py): `stats.py`
- [Wait and fairness metrics](https://github.com/zamdam2026/er-triage-simulator/blob/main/stats.py): `stats.py`
- [Equity selection](https://github.com/zamdam2026/er-triage-simulator/blob/main/stats.py): `stats.py`

### Other components

- **Web user**
- **Terminal user**

## Connections

- Web user → Streamlit interface: sets scenario
- Terminal user → Terminal interface: enters scenario
- Streamlit interface → Patient generation: generates patients
- Terminal interface → Patient generation: generates patients
- Patient generation → Patient record: creates records
- Streamlit interface → Policy runner: runs policies
- Terminal interface → Policy runner: runs policies
- Policy runner → Triage priority: dispatches
- Policy runner → Doctor rounds: dispatches
- Policy runner → Quick consults: dispatches
- Streamlit interface → Metric comparison: compares outcomes
- Terminal interface → Metric comparison: compares outcomes
- Metric comparison → Wait and fairness metrics: summarizes
- Streamlit interface → Equity selection: selects by equity
- Terminal interface → Equity selection: selects by equity
- Streamlit interface → Web user: shows results
- Terminal interface → Terminal user: prints results
