# gvahck/evacuation architecture

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

- Interactive diagram: https://gitdiagram.com/gvahck/evacuation
- Repository: https://github.com/gvahck/evacuation

## Overview

This repository is a mobile-first, multi-hazard evacuation platform: users configure an evacuation, receive hazard-aware route recommendations, track live progress and reroutes, and review results. The React Native client communicates with a FastAPI backend, which coordinates authentication, session execution, routing, hazards, traffic, persistence, and live telemetry. Its spatial and decision layer combines road-graph routing with a MARL model and traffic simulation; separate research and scenario capabilities support model inspection and experimentation. Relationships are limited to README statements and SOURCE INDEX references or excerpts; unsampled internals are represented cautiously.

Main entry points: [`mobile/src/api/client.ts`](https://github.com/gvahck/evacuation/blob/main/mobile/src/api/client.ts) (API client), [`backend/app/services/evacuation_service.py`](https://github.com/gvahck/evacuation/blob/main/backend/app/services/evacuation_service.py) (Session orchestration), [`backend/app/hazards/hazard_manager.py`](https://github.com/gvahck/evacuation/blob/main/backend/app/hazards/hazard_manager.py) (Hazard coordination), [`src/environment/evacuation_env.py`](https://github.com/gvahck/evacuation/blob/main/src/environment/evacuation_env.py) (Evacuation environment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Mobile app"]
  node_mobile["Mobile experience<br/>[HomeScreen.tsx]"]
  node_evac_preview["Route preview"]
  node_map["Map renderer<br/>[MapRenderer.tsx]"]
  node_mobile_api["API client<br/>[client.ts]"]
  node_mobile_user["Mobile session store<br/>[evacuationStore.ts]"]
end

subgraph group_backend["API and sessions"]
  node_auth["Authentication API<br/>[auth.py]"]
  node_evac_api["Evacuation API<br/>[evacuation.py]"]
  node_evac_service["Session orchestration"]
  node_route_api["Route API<br/>[routes.py]"]
  node_history["Session history<br/>[history.py]"]
  node_hazard_api["Hazard API<br/>[hazards.py]"]
end

subgraph group_decision["Routing and hazards"]
  node_graph["Road graph<br/>[graph_manager.py]"]
  node_route_builder["Route construction<br/>[route_builder.py]"]
  node_model["MARL inference<br/>[model_manager.py]"]
  node_hazard_manager["Hazard coordination<br/>[hazard_manager.py]"]
  node_hazard_engines["Flood and fire spread"]
end

subgraph group_research["Research and simulation"]
  node_sumo["Traffic simulation<br/>[sumo_manager.py]"]
  node_research_api["Research endpoints<br/>[research.py]"]
  node_scenarios["Scenario endpoints<br/>[scenarios.py]"]
  node_env["Evacuation environment<br/>[evacuation_env.py]"]
  node_agents["Learning agents"]
end

subgraph group_state["Persistence and telemetry"]
  node_database[("Relational storage<br/>[session.py]")]
  node_sessions["Evacuation records"]
  node_websocket["Live telemetry<br/>[manager.py]"]
end

node_resident(("Evacuation user"))

node_resident -->|"configures evacuation"| node_mobile
node_mobile -.->|"previews routes"| node_evac_preview
node_evac_preview -->|"renders map"| node_map
node_mobile -.->|"requests services"| node_mobile_api
node_mobile_api -->|"sends HTTP"| node_evac_api
node_mobile_api -->|"authenticates"| node_auth
node_mobile_api -.->|"loads history"| node_history
node_mobile_api -.->|"requests research"| node_research_api
node_mobile_api -.->|"requests scenarios"| node_scenarios
node_auth -->|"uses database"| node_database
node_auth -.->|"authorizes requests"| node_evac_api
node_evac_api -->|"delegates sessions"| node_evac_service
node_evac_service -.->|"runs inference"| node_model
node_evac_service -.->|"reads hazards"| node_hazard_manager
node_evac_service -.->|"advances traffic"| node_sumo
node_evac_service -.->|"persists sessions"| node_database
node_evac_service -.->|"broadcasts telemetry"| node_websocket
node_route_api -->|"builds routes"| node_route_builder
node_route_api -->|"queries graph"| node_graph
node_route_api -->|"checks hazards"| node_hazard_manager
node_hazard_api -->|"configures hazards"| node_hazard_manager
node_hazard_manager -->|"uses road graph"| node_graph
node_hazard_manager -->|"coordinates engines"| node_hazard_engines
node_hazard_engines -.->|"updates edge states"| node_graph
node_history -->|"queries sessions"| node_database
node_history -->|"reads records"| node_sessions
node_websocket -->|"streams events"| node_mobile_api
node_mobile_api -.->|"updates client state"| node_mobile_user
node_research_api -.->|"exposes model data"| node_model
node_scenarios -.->|"provides scenarios"| node_env
node_env -->|"supports agent learning"| node_agents
node_env -->|"simulates hazards"| node_hazard_engines
node_env -.->|"synchronizes traffic"| node_sumo
node_model -->|"loads MARL model"| node_agents

click node_mobile "https://github.com/gvahck/evacuation/blob/main/mobile/src/screens/HomeScreen.tsx"
click node_evac_preview "https://github.com/gvahck/evacuation/blob/main/mobile/src/screens/EvacuationPreviewScreen.tsx"
click node_map "https://github.com/gvahck/evacuation/blob/main/mobile/src/components/MapRenderer.tsx"
click node_mobile_api "https://github.com/gvahck/evacuation/blob/main/mobile/src/api/client.ts"
click node_auth "https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/auth.py"
click node_evac_api "https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/evacuation.py"
click node_evac_service "https://github.com/gvahck/evacuation/blob/main/backend/app/services/evacuation_service.py"
click node_route_api "https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/routes.py"
click node_history "https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/history.py"
click node_hazard_api "https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/hazards.py"
click node_graph "https://github.com/gvahck/evacuation/blob/main/backend/app/routing/graph_manager.py"
click node_route_builder "https://github.com/gvahck/evacuation/blob/main/backend/app/routing/route_builder.py"
click node_model "https://github.com/gvahck/evacuation/blob/main/backend/app/ml/model_manager.py"
click node_hazard_manager "https://github.com/gvahck/evacuation/blob/main/backend/app/hazards/hazard_manager.py"
click node_hazard_engines "https://github.com/gvahck/evacuation/tree/main/src/hazard"
click node_sumo "https://github.com/gvahck/evacuation/blob/main/backend/app/simulation/sumo_manager.py"
click node_research_api "https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/research.py"
click node_scenarios "https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/scenarios.py"
click node_env "https://github.com/gvahck/evacuation/blob/main/src/environment/evacuation_env.py"
click node_agents "https://github.com/gvahck/evacuation/blob/main/src/agents/marl_six/offline_online_agent.py"
click node_database "https://github.com/gvahck/evacuation/blob/main/backend/app/database/session.py"
click node_sessions "https://github.com/gvahck/evacuation/blob/main/backend/app/models/evacuation_session.py"
click node_websocket "https://github.com/gvahck/evacuation/blob/main/backend/app/websocket/manager.py"
click node_mobile_user "https://github.com/gvahck/evacuation/blob/main/mobile/src/store/evacuationStore.ts"

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_mobile,node_evac_preview,node_map,node_mobile_api,node_mobile_user,node_resident toneBlue
class node_auth,node_evac_api,node_evac_service,node_route_api,node_history,node_hazard_api toneAmber
class node_graph,node_route_builder,node_model,node_hazard_manager,node_hazard_engines toneMint
class node_sumo,node_research_api,node_scenarios,node_env,node_agents toneRose
class node_database,node_sessions,node_websocket toneIndigo
```

## Components

### Mobile app

- [Mobile experience](https://github.com/gvahck/evacuation/blob/main/mobile/src/screens/HomeScreen.tsx): `mobile/src/screens/HomeScreen.tsx`
- [Route preview](https://github.com/gvahck/evacuation/blob/main/mobile/src/screens/EvacuationPreviewScreen.tsx): `mobile/src/screens/EvacuationPreviewScreen.tsx`
- [Map renderer](https://github.com/gvahck/evacuation/blob/main/mobile/src/components/MapRenderer.tsx): `mobile/src/components/MapRenderer.tsx`
- [API client](https://github.com/gvahck/evacuation/blob/main/mobile/src/api/client.ts): `mobile/src/api/client.ts`
- [Mobile session store](https://github.com/gvahck/evacuation/blob/main/mobile/src/store/evacuationStore.ts): `mobile/src/store/evacuationStore.ts`

### API and sessions

- [Authentication API](https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/auth.py): `backend/app/api/routes/auth.py`
- [Evacuation API](https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/evacuation.py): `backend/app/api/routes/evacuation.py`
- [Session orchestration](https://github.com/gvahck/evacuation/blob/main/backend/app/services/evacuation_service.py): `backend/app/services/evacuation_service.py`
- [Route API](https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/routes.py): `backend/app/api/routes/routes.py`
- [Session history](https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/history.py): `backend/app/api/routes/history.py`
- [Hazard API](https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/hazards.py): `backend/app/api/routes/hazards.py`

### Routing and hazards

- [Road graph](https://github.com/gvahck/evacuation/blob/main/backend/app/routing/graph_manager.py): `backend/app/routing/graph_manager.py`
- [Route construction](https://github.com/gvahck/evacuation/blob/main/backend/app/routing/route_builder.py): `backend/app/routing/route_builder.py`
- [MARL inference](https://github.com/gvahck/evacuation/blob/main/backend/app/ml/model_manager.py): `backend/app/ml/model_manager.py`
- [Hazard coordination](https://github.com/gvahck/evacuation/blob/main/backend/app/hazards/hazard_manager.py): `backend/app/hazards/hazard_manager.py`
- [Flood and fire spread](https://github.com/gvahck/evacuation/tree/main/src/hazard): `src/hazard`

### Research and simulation

- [Traffic simulation](https://github.com/gvahck/evacuation/blob/main/backend/app/simulation/sumo_manager.py): `backend/app/simulation/sumo_manager.py`
- [Research endpoints](https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/research.py): `backend/app/api/routes/research.py`
- [Scenario endpoints](https://github.com/gvahck/evacuation/blob/main/backend/app/api/routes/scenarios.py): `backend/app/api/routes/scenarios.py`
- [Evacuation environment](https://github.com/gvahck/evacuation/blob/main/src/environment/evacuation_env.py): `src/environment/evacuation_env.py`
- [Learning agents](https://github.com/gvahck/evacuation/blob/main/src/agents/marl_six/offline_online_agent.py): `src/agents/marl_six/offline_online_agent.py`

### Persistence and telemetry

- [Relational storage](https://github.com/gvahck/evacuation/blob/main/backend/app/database/session.py): `backend/app/database/session.py`
- [Evacuation records](https://github.com/gvahck/evacuation/blob/main/backend/app/models/evacuation_session.py): `backend/app/models/evacuation_session.py`
- [Live telemetry](https://github.com/gvahck/evacuation/blob/main/backend/app/websocket/manager.py): `backend/app/websocket/manager.py`

### Other components

- **Evacuation user**

## Connections

- Evacuation user → Mobile experience: configures evacuation
- Mobile experience → Route preview: previews routes
- Route preview → Map renderer: renders map (evidence: `mobile/src/screens/EvacuationPreviewScreen.tsx`)
- Mobile experience → API client: requests services
- API client → Evacuation API: sends HTTP
- API client → Authentication API: authenticates
- API client → Session history: loads history
- API client → Research endpoints: requests research
- API client → Scenario endpoints: requests scenarios
- Authentication API → Relational storage: uses database (evidence: `backend/app/api/routes/auth.py`)
- Authentication API → Evacuation API: authorizes requests
- Evacuation API → Session orchestration: delegates sessions (evidence: `backend/app/api/routes/evacuation.py`)
- Session orchestration → MARL inference: runs inference
- Session orchestration → Hazard coordination: reads hazards
- Session orchestration → Traffic simulation: advances traffic
- Session orchestration → Relational storage: persists sessions
- Session orchestration → Live telemetry: broadcasts telemetry
- Route API → Route construction: builds routes (evidence: `backend/app/api/routes/routes.py`)
- Route API → Road graph: queries graph (evidence: `backend/app/api/routes/routes.py`)
- Route API → Hazard coordination: checks hazards (evidence: `backend/app/api/routes/routes.py`)
- Hazard API → Hazard coordination: configures hazards (evidence: `backend/app/api/routes/hazards.py`)
- Hazard coordination → Road graph: uses road graph (evidence: `backend/app/hazards/hazard_manager.py`)
- Hazard coordination → Flood and fire spread: coordinates engines (evidence: `backend/app/hazards/hazard_manager.py`)
- Flood and fire spread → Road graph: updates edge states
- Session history → Relational storage: queries sessions (evidence: `backend/app/api/routes/history.py`)
- Session history → Evacuation records: reads records (evidence: `backend/app/api/routes/history.py`)
- Live telemetry → API client: streams events
- API client → Mobile session store: updates client state
- Research endpoints → MARL inference: exposes model data
- Scenario endpoints → Evacuation environment: provides scenarios
- Evacuation environment → Learning agents: supports agent learning
- Evacuation environment → Flood and fire spread: simulates hazards (evidence: `src/environment/evacuation_env.py`)
- Evacuation environment → Traffic simulation: synchronizes traffic
- MARL inference → Learning agents: loads MARL model (evidence: `backend/app/ml/model_manager.py`)
