# rbi-international/rahat architecture

> Architecture diagram of the GitHub repository rbi-international/rahat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rbi-international/rahat
- Repository: https://github.com/rbi-international/rahat

## Overview

RAHAT is a flood-response control room and classroom drill: citizens submit SOS messages, a fixed agent workflow screens and assesses them, and a duty officer approves or rejects a proposed dispatch. The map includes the documented parallel location/verification work, resource allocation, language assistance, exercise injects, and learning outcomes. Relationships are limited to README statements and SOURCE INDEX references; where excerpts do not expose runtime wiring, links are omitted rather than inferred.

Main entry points: [`src/rahat/workflow.py`](https://github.com/rbi-international/rahat/blob/main/src/rahat/workflow.py) (Fixed workflow), [`src/rahat/pipeline.py`](https://github.com/rbi-international/rahat/blob/main/src/rahat/pipeline.py) (Queue and decisions), [`src/rahat/api.py`](https://github.com/rbi-international/rahat/blob/main/src/rahat/api.py) (HTTP API), [`src/rahat/agents/specialists.py`](https://github.com/rbi-international/rahat/blob/main/src/rahat/agents/specialists.py) (Agent specialists)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Control room"]
  node_web_sos["SOS form<br/>[sos.js]"]
  node_api["HTTP API<br/>[api.py]"]
  node_pipeline["Queue and decisions<br/>[pipeline.py]"]
  node_wall["Control room wall<br/>[wall.js]"]
  node_console["Officer console<br/>[console.js]"]
end

subgraph group_assessment["SOS assessment"]
  node_workflow["Fixed workflow<br/>[workflow.py]"]
  node_guardrails["PII and policy<br/>[policy.py]"]
  node_injection["Injection screen<br/>[injection.py]"]
  node_specialists["Agent specialists<br/>[specialists.py]"]
  node_router["Tier router<br/>[router.py]"]
  node_rules["SOP triage<br/>[rules.py]"]
end

subgraph group_resources["Response resources"]
  node_geo["Place locator<br/>[geo.py]"]
  node_registry[("Unit registry<br/>[resources.py]")]
  node_gauges[("River gauges<br/>[rivers.py]")]
end

subgraph group_governance["Governance and state"]
  node_store[("Incident board<br/>[store.py]")]
  node_events["Live event bus<br/>[events.py]"]
  node_ledger[("Token ledger<br/>[ledger.py]")]
end

subgraph group_exercise["Exercise and outcomes"]
  node_drill["Exercise control<br/>[control.py]"]
  node_personas["Citizen personas<br/>[personas.py]"]
  node_scoring["Drill scoring<br/>[scoring.py]"]
  node_outcomes[("Learning outcomes<br/>[outcomes.py]")]
end

node_citizen(("Citizen"))
node_officer(("Duty officer"))
node_instructor(("Instructor"))

node_citizen -->|"submits SOS"| node_web_sos
node_web_sos -.->|"sends request"| node_api
node_officer -->|"reviews case"| node_console
node_console -.->|"requests action"| node_api
node_api -->|"queues work"| node_pipeline
node_pipeline -->|"reads incident"| node_store
node_pipeline -->|"runs workflow"| node_workflow
node_workflow -->|"screens and constrains"| node_guardrails
node_workflow -->|"checks injection"| node_injection
node_workflow -->|"runs agents"| node_specialists
node_workflow -->|"chooses model tier"| node_router
node_specialists -->|"uses fallback"| node_rules
node_workflow -->|"resolves location"| node_geo
node_workflow -->|"allocates unit"| node_registry
node_workflow -->|"reads river level"| node_gauges
node_geo -->|"supports distance lookup"| node_registry
node_pipeline -->|"awaits approval"| node_officer
node_pipeline -->|"publishes updates"| node_events
node_workflow -->|"publishes agent events"| node_events
node_specialists -.->|"charges model use"| node_ledger
node_events -.->|"feeds live view"| node_wall
node_instructor -->|"runs injects"| node_drill
node_drill -->|"creates participants"| node_personas
node_drill -->|"submits exercise cases"| node_pipeline
node_scoring -.->|"records learning results"| node_outcomes
node_api -->|"serves outcome functions"| node_outcomes

click node_web_sos "https://github.com/rbi-international/rahat/blob/main/src/rahat/web/sos.js"
click node_api "https://github.com/rbi-international/rahat/blob/main/src/rahat/api.py"
click node_pipeline "https://github.com/rbi-international/rahat/blob/main/src/rahat/pipeline.py"
click node_workflow "https://github.com/rbi-international/rahat/blob/main/src/rahat/workflow.py"
click node_guardrails "https://github.com/rbi-international/rahat/blob/main/src/rahat/guardrails/policy.py"
click node_injection "https://github.com/rbi-international/rahat/blob/main/src/rahat/guardrails/injection.py"
click node_specialists "https://github.com/rbi-international/rahat/blob/main/src/rahat/agents/specialists.py"
click node_router "https://github.com/rbi-international/rahat/blob/main/src/rahat/router.py"
click node_rules "https://github.com/rbi-international/rahat/blob/main/src/rahat/rules.py"
click node_geo "https://github.com/rbi-international/rahat/blob/main/src/rahat/tools/geo.py"
click node_registry "https://github.com/rbi-international/rahat/blob/main/src/rahat/tools/resources.py"
click node_gauges "https://github.com/rbi-international/rahat/blob/main/src/rahat/tools/rivers.py"
click node_store "https://github.com/rbi-international/rahat/blob/main/src/rahat/store.py"
click node_events "https://github.com/rbi-international/rahat/blob/main/src/rahat/events.py"
click node_ledger "https://github.com/rbi-international/rahat/blob/main/src/rahat/ledger.py"
click node_wall "https://github.com/rbi-international/rahat/blob/main/src/rahat/web/wall.js"
click node_console "https://github.com/rbi-international/rahat/blob/main/src/rahat/web/console.js"
click node_drill "https://github.com/rbi-international/rahat/blob/main/src/rahat/drill/control.py"
click node_personas "https://github.com/rbi-international/rahat/blob/main/src/rahat/drill/personas.py"
click node_scoring "https://github.com/rbi-international/rahat/blob/main/src/rahat/drill/scoring.py"
click node_outcomes "https://github.com/rbi-international/rahat/blob/main/src/rahat/outcomes.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_sos,node_api,node_pipeline,node_wall,node_console toneBlue
class node_workflow,node_guardrails,node_injection,node_specialists,node_router,node_rules toneAmber
class node_geo,node_registry,node_gauges toneMint
class node_store,node_events,node_ledger toneRose
class node_drill,node_personas,node_scoring,node_outcomes,node_citizen,node_officer,node_instructor toneIndigo
```

## Components

### Control room

- [SOS form](https://github.com/rbi-international/rahat/blob/main/src/rahat/web/sos.js): `src/rahat/web/sos.js`
- [HTTP API](https://github.com/rbi-international/rahat/blob/main/src/rahat/api.py): `src/rahat/api.py`
- [Queue and decisions](https://github.com/rbi-international/rahat/blob/main/src/rahat/pipeline.py): `src/rahat/pipeline.py`
- [Control room wall](https://github.com/rbi-international/rahat/blob/main/src/rahat/web/wall.js): `src/rahat/web/wall.js`
- [Officer console](https://github.com/rbi-international/rahat/blob/main/src/rahat/web/console.js): `src/rahat/web/console.js`

### SOS assessment

- [Fixed workflow](https://github.com/rbi-international/rahat/blob/main/src/rahat/workflow.py): `src/rahat/workflow.py`
- [PII and policy](https://github.com/rbi-international/rahat/blob/main/src/rahat/guardrails/policy.py): `src/rahat/guardrails/policy.py`
- [Injection screen](https://github.com/rbi-international/rahat/blob/main/src/rahat/guardrails/injection.py): `src/rahat/guardrails/injection.py`
- [Agent specialists](https://github.com/rbi-international/rahat/blob/main/src/rahat/agents/specialists.py): `src/rahat/agents/specialists.py`
- [Tier router](https://github.com/rbi-international/rahat/blob/main/src/rahat/router.py): `src/rahat/router.py`
- [SOP triage](https://github.com/rbi-international/rahat/blob/main/src/rahat/rules.py): `src/rahat/rules.py`

### Response resources

- [Place locator](https://github.com/rbi-international/rahat/blob/main/src/rahat/tools/geo.py): `src/rahat/tools/geo.py`
- [Unit registry](https://github.com/rbi-international/rahat/blob/main/src/rahat/tools/resources.py): `src/rahat/tools/resources.py`
- [River gauges](https://github.com/rbi-international/rahat/blob/main/src/rahat/tools/rivers.py): `src/rahat/tools/rivers.py`

### Governance and state

- [Incident board](https://github.com/rbi-international/rahat/blob/main/src/rahat/store.py): `src/rahat/store.py`
- [Live event bus](https://github.com/rbi-international/rahat/blob/main/src/rahat/events.py): `src/rahat/events.py`
- [Token ledger](https://github.com/rbi-international/rahat/blob/main/src/rahat/ledger.py): `src/rahat/ledger.py`

### Exercise and outcomes

- [Exercise control](https://github.com/rbi-international/rahat/blob/main/src/rahat/drill/control.py): `src/rahat/drill/control.py`
- [Citizen personas](https://github.com/rbi-international/rahat/blob/main/src/rahat/drill/personas.py): `src/rahat/drill/personas.py`
- [Drill scoring](https://github.com/rbi-international/rahat/blob/main/src/rahat/drill/scoring.py): `src/rahat/drill/scoring.py`
- [Learning outcomes](https://github.com/rbi-international/rahat/blob/main/src/rahat/outcomes.py): `src/rahat/outcomes.py`

### Other components

- **Citizen**
- **Duty officer**
- **Instructor**

## Connections

- Citizen → SOS form: submits SOS
- SOS form → HTTP API: sends request
- Duty officer → Officer console: reviews case
- Officer console → HTTP API: requests action
- HTTP API → Queue and decisions: queues work (evidence: `src/rahat/api.py`)
- Queue and decisions → Incident board: reads incident (evidence: `src/rahat/pipeline.py`)
- Queue and decisions → Fixed workflow: runs workflow (evidence: `src/rahat/pipeline.py`)
- Fixed workflow → PII and policy: screens and constrains (evidence: `src/rahat/workflow.py`)
- Fixed workflow → Injection screen: checks injection (evidence: `src/rahat/workflow.py`)
- Fixed workflow → Agent specialists: runs agents (evidence: `src/rahat/workflow.py`)
- Fixed workflow → Tier router: chooses model tier (evidence: `src/rahat/workflow.py`)
- Agent specialists → SOP triage: uses fallback (evidence: `src/rahat/agents/specialists.py`)
- Fixed workflow → Place locator: resolves location (evidence: `src/rahat/workflow.py`)
- Fixed workflow → Unit registry: allocates unit (evidence: `src/rahat/workflow.py`)
- Fixed workflow → River gauges: reads river level (evidence: `src/rahat/workflow.py`)
- Place locator → Unit registry: supports distance lookup (evidence: `src/rahat/tools/resources.py`)
- Queue and decisions → Duty officer: awaits approval
- Queue and decisions → Live event bus: publishes updates (evidence: `src/rahat/pipeline.py`)
- Fixed workflow → Live event bus: publishes agent events (evidence: `src/rahat/workflow.py`)
- Agent specialists → Token ledger: charges model use
- Live event bus → Control room wall: feeds live view
- Instructor → Exercise control: runs injects
- Exercise control → Citizen personas: creates participants (evidence: `src/rahat/drill/control.py`)
- Exercise control → Queue and decisions: submits exercise cases (evidence: `src/rahat/drill/control.py`)
- Drill scoring → Learning outcomes: records learning results
- HTTP API → Learning outcomes: serves outcome functions (evidence: `src/rahat/api.py`)
