Data, scripts and how to regenerate them
All generated data is in backend/app/data/ and is committed, so a fresh checkout runs without rebuilding it. Everything derives from OpenStreetMap, plus LLM profiling and optimisation; nothing is hand-placed.
Data files
| File | Contents | Built by |
|---|---|---|
chennai_gis.json | From the Geofabrik South India OSM extract, inside the Chennai bbox (12.88–13.23 N, 80.08–80.32 E): 828 hospitals (name, name:ta, beds, emergency, speciality, operator), 96 police stations, 9 fire stations, 656 localities (suburb / neighbourhood / quarter, the offline gazetteer and demand points), 1,857 landmarks (stations, bus stands, bridges / flyovers, junctions, temples, churches, mosques, markets, malls, parks: what callers actually say). Carries the ODbL attribution. | make gis (scripts/build_chennai_gis.py, pyosmium) |
hospital_profiles.json | For each of 7,153 facilities (the 828 Chennai hospitals plus the statewide list), an LLM reading of its own OSM name and tags, not a sourced capability record: level (tertiary / secondary / primary / specialty_non_emergency / not_a_hospital), emergency_department, cardiac_cath_lab, trauma_care, obstetric, paediatric, confidence, rationale, model. Result: 4,189 emergency departments (2,738 of them with confidence below 0.6), 172 cath labs, 336 trauma. 828 profiles are from gemma3:4b (Chennai), 6,325 from deepseek-flash (statewide). No profile carries an ER bed estimate, so every hospital starts with er_beds=0 and a placeholder load_score=0.5 (geo/gis.py) until ER staff or the hospital status API report real values. | make hospital-profiles (scripts/profile_hospitals.py, uses get_llm()) |
tn_hospitals.json | Every healthcare facility in Tamil Nadu: 7,102 deduplicated records: 7,039 from OSM Overpass, 35 from Wikidata, 28 from both. The collector also supports data.gov.in and TN Health facility lists, but both contributed 0 rows (no API key, no list supplied; see tn_hospitals/qa_report.md). 6,958 records have emergency: unknown. built by tn_hospitals/collect_tn_hospitals.py. Same record shape as chennai_gis.json["hospitals"]; QA report, GeoJSON, CSV and a Leaflet viewer are in tn_hospitals/. A facility becomes a receiving hospital for dispatch only once profile_hospitals.py has profiled it with an emergency department. PHCs and clinics stay on the maps but are never a destination. The geocoder keeps using only Chennai-area hospital names. | tn_hospitals/collect_tn_hospitals.py, then uv run python scripts/profile_hospitals.py --input backend/app/data/tn_hospitals.json |
fleet_plan.json | MEXCLP solution (OR-Tools CP-SAT): 37 units on 4,189 candidate bases (every hospital profiled with an emergency department) × 656 demand points, 8-min target, busy fraction 0.35. Covers 93% of demand. The committed plan was solved on straight-line (Haversine) times, not OSRM: the 4,189 × 656 OSRM request exceeded the URL limit and fell back silently. Table requests are now chunked and the plan records coverage_matrix (osrm or haversine); re-run make fleet-plan to get a road-time plan. Demand weights are OSM locality counts, not call history. | make fleet-plan (deletes and re-solves; needs OSRM) |
Zones are k-means clusters of the localities (VAAZHVU_ZONES, default 16), named after the locality nearest each centroid. Demand per zone starts from the locality count (the prior) and is blended with observed incidents as they accumulate.
Where each dataset lives
Nothing below is bundled into an app. The web apps fetch it over HTTP; the iOS apps fetch at runtime and hold no offline copy. Live operations state is the only data in the database; the generated files are held in memory by the GIS layer. See Database for the schema.
| Dataset | Stored in | Reaches the app by | Bundled? |
|---|---|---|---|
| Live events, incidents, audit | SQLite (not in DB: hospitals/GIS/fleet) | /api/ops/* + SSE /api/ops/stream | No |
chennai_gis.json (828 hospitals, stations, localities, landmarks) | Memory (geo/gis.py) | /api/ops/facilities, /api/ops/hospitals, geocoder | No |
hospital_profiles.json (capability) | Memory (geo/gis.py) | capability fields on /hospitals, /facilities | No |
tn_hospitals.json (statewide) | Memory (geo/gis.py) | /api/ops/facilities (viewport query) | No |
fleet_plan.json | Memory (ops/world.py) at start | /api/ops/state | No |
config/*.yaml (copy, thresholds, roles) | Read per request | /api/ops/app/config, /api/config | No |
| Map tiles | CARTO (browser) | key via /api/config | n/a |
| iOS facility list | Server only | ios/Vaazhvu/Shared/Facilities.swift → GET /api/ops/facilities?… | No |
backend/app/geo/gis.py merges the Chennai layer (828) with the statewide set
(7,102) deduped on osm_id: 7,153 facilities total. Only facilities profiled
with an emergency department become ambulance destinations; the rest stay on the
map as non-receiving.
What is hardcoded
This table covers files and code. What the screens show that is simulated or estimated (the fleet, sim clock, vitals, zones, forecast, hospital capability) is in What is simulated.
| Where | Hardcoded | Notes |
|---|---|---|
backend/app/data/*.json | The geo (GIS), hospital-profile and fleet datasets themselves | Static, committed. Regenerate with the scripts below; nothing is hand-placed. |
backend/app/sim/scenarios.py | Legacy only: 5 zones, 4 ambulances (amb_A..D), 3 hospitals, coverage rows, 7 scenarios | Not used by the live ops/ path. |
config/*.yaml | Clinical thresholds, dispatch parameters, fleet composition, roles/permissions, all UI wording | This is the intended place to change behaviour — config, not code. |
frontend/src/pages/Landing.jsx | POLICY (mirrors config/policy.yaml), SEV colours, APPS, FAQ | The POLICY copy can drift from the YAML. |
frontend/src/live/LiveMap.jsx, frontend/src/terminal/TerminalMap.jsx | SEV_COLOR / UNIT_COLOR hex values | Two maps, different hex for the same severity. |
frontend/src/live/IncidentDetail.jsx, frontend/src/terminal/*, frontend/src/ui.jsx | Severity key lists (critical/urgent/non_urgent/unknown) | Repeated in several components. |
.env | Real CARTO + LLM keys | Git-ignored; rotate before any recording or public push. |
config/env.example | LLM provider/model defaults | Safe to commit. |
Known gaps
None of the 7,153 committed hospital profiles carries per-record provenance (only model): they predate
the change in scripts/profile_hospitals.py that records profiled_at, prompt_version and source.
--stale re-profiles records made with another model or prompt, and /api/ops/datasets reports how many
profiles lack provenance. The committed profiles came from gemma3:4b (828, Chennai) and deepseek-flash
(6,325, statewide). OSM carries no bed counts for any of the 828 Chennai hospitals. The iOS apps cache every
hospital they load (and pre-load nearby emergency hospitals daily), so the map works offline.
Open work is tracked in docs/todo/NOW.md.
External data and models (not committed)
| Path | What | How |
|---|---|---|
infra/osrm/southern-zone-latest.osm.pbf + .osrm* | Geofabrik South India extract and its OSRM MLD graph (~6 GB) | make osrm-data |
~/.cache/huggingface | faster-whisper, IndicTrans2 (gated), MLX Whisper (host runs only), optional NLI model. Bind-mounted into the api container (HF_CACHE overrides) | make models (scripts/fetch_models.py), MLX on first use |
~/.cache/vaazhvu-models/lid.176.ftz | fastText language ID. Bind-mounted into the api container (VAAZHVU_MODELS_DIR overrides) | make models |
xlit image | IndicXlit models, downloaded at image build | services/xlit/Dockerfile (make build) |
| Ollama store | gemma3:4b in the native Ollama.app | make llm |
pg-data volume | The live database (Postgres): events, incidents, audit, accounts. make db-backup dumps it to var/backups/; docker compose down -v deletes it. | Created by the postgres service |
var/vaazhvu.db | The SQLite database from before Postgres, kept as a backup (make db-migrate copies it in). Still the default when VAAZHVU_DB is unset. | Created at startup (SQLite mode) |
| Docker volumes | pg-data (above), nats-data (JetStream), prometheus-data, grafana-data, ollama-models (opt-in profile) | docker compose down -v drops them |
Scripts (scripts/)
| Script | Purpose |
|---|---|
build_chennai_gis.py | OSM extract → chennai_gis.json (see above) |
profile_hospitals.py [--limit N] [--workers 5] | LLM capability profiling of every hospital (resumable; writes every 50) |
fetch_models.py [whisper|indictrans2|lid|nli] | Download pretrained models (HF_HUB_DISABLE_XET=1 avoids stuck downloads) |
eval_dispatch.py --calls 150 --rate 12 --seeds 1,…,10 [--miscalibrated] | Discrete-event evaluation of dispatch policies B0–R4; writes docs/eval/ |
voice_call_sim.py a.wav [b.wav …] --url ws://…/api/ops/voice/ws?caller=x&lang=ta [--wait 10] | Plays WAV turns into the voice line and prints a timeline (greeting, transcripts, replies, interrupts) |
synthea_patients.sh | Synthea run (not integrated: Synthea ships US geography only) |
monitor_stack.py [--once|--json|--serve] | Stack monitor: terminal dashboard (make monitor), JSON, or the Prometheus exporter run by the monitor compose service |
Statewide hospitals (done)
The prompt below produced tn_hospitals/; its output is loaded as backend/app/data/tn_hospitals.json. The maps show it through GET /api/ops/facilities (viewport query), and dispatch routes patients to its profiled emergency departments.
Going statewide (the original prompt)
docs/prompts/tamil-nadu-hospitals.md is a prompt for an external LLM (with code execution) to collect every hospital in Tamil Nadu from open sources:
- OSM Overpass, Wikidata, data.gov.in, TN Health lists geocoded via Nominatim (in the committed output only OSM and Wikidata contributed rows);
- deduplicated, with source provenance, plus a map.
Its tn_hospitals_vaazhvu.json output has the same record shape as chennai_gis.json["hospitals"], so it can feed profile_hospitals.py and the fleet planner. The OSRM graph already covers Tamil Nadu. A baseline sanity check: OSM had 5,469 hospital nodes in Tamil Nadu (October 2026).