Inspiration
During urban disease outbreaks such as dengue or acute respiratory waves, municipal public health offices rarely have the staffing or supply budget to intervene in every district at once. Standard reactive policies simply dispatch teams to whichever wards report the highest active case counts. However, because commuter networks tightly couple neighborhoods together and hospital ICU capacities vary unevenly across a city, reactive allocation often lags behind transmission hubs and allows under-bedded wards to overflow.
We built SennaGrid for the Code for Change (Global) hackathon to give public health planners an accessible, zero-server decision-support workbench that proves how network-aware predictive allocation outperforms reactive dispatch under the exact same operational budget.
What it does
SennaGrid is a 100% client-side spatial epidemic digital twin and constrained mathematical resource allocator. It simulates a deterministic 91-day (13-week) outbreak across urban districts and compares standard reactive dispatch against predictive optimization across 10% to 40% weekly intervention budgets:
- Dual Spatial Disease Models:
- Vector-Borne SEIR-SEI (Default): Simulates climate-modulated dengue/arbovirus transmission driven by daily temperature and 7-day rolling rainfall via the free Open-Meteo API (with silent fallback to bundled seasonal climatology).
- Direct-Contact SEIR: Models mobility-coupled respiratory outbreaks with targeted vaccination suppression.
- Gravity Mobility Network: Models inter-district spread using a row-normalized N×N Haversine commuter matrix and incoming commuter hub centrality scoring.
- Constrained Predictive Optimizer: Combines receding-horizon multi-seed initialization with bounded multi-pass checkpointed coordinate descent (2-week sustained block swaps and 1-week swaps), ICU-overflow-first acceptance, a Hospital Safety Guardrail that guarantees ICU overflow never worsens beyond the reactive baseline, deterministic rationale tagging, and an auditable swap trace.
- 5 Automated Policy & Integrity Gates: Every run is verified against ODE mass conservation (< 1e-9 drift), weekly budget compliance, objective dominance, ICU collapse mitigation, and early mobility hub coverage.
- Urban Presets & Global City Search: Explore four calibrated presets (Metro Tropica, Harbor Corridor, Highland Ring, and Monsoon Delta) or search any city worldwide via Open-Meteo Geocoding to simulate a normalized 18-ward grid with live local weather.
- Operational Exports: Download structured 13-week dispatch schedules in RFC-4180 CSV or full simulation telemetry in JSON.
How we built it
We structured SennaGrid as an npm workspaces monorepo to isolate pure mathematical computation from the browser interface:
- Simulation & Optimization Engine (
@sennagrid/engine): Built in pure, dependency-free TypeScript using RK4 numerical integration overFloat64Arraytyped arrays inside a native Web Worker, ensuring zero backend servers, zero cold starts, and sub-second solve times (~210–600 ms). - Interactive Geospatial Client (
@sennagrid/web): Built with Vite, React 19, Tailwind CSS v4, MapLibre GL, and Recharts to visualize district-level epidemic trajectories, ICU bed pressure, five-axis impact radars, and weekly intervention dispatches. - Live Environmental Data: Integrated the free Open-Meteo Weather & Geocoding APIs for real-time local climate modulation without requiring paid API keys.
- Quality & Documentation Automation: Enforced correctness with Vitest suites across both workspaces alongside automated pre-commit hooks and GitHub Actions CI (
npm run check:docs) to keep architectural blueprints and benchmarks synchronized with code changes.
Challenges we ran into
- Keeping Heavy Numerical Optimization Responsive in the Browser: Running 91-day multi-district RK4 ODE sweeps inside coordinate descent risked freezing the UI thread. Moving the entire
@sennagrid/enginepipeline into a dedicated Web Worker with pre-allocatedFloat64Arraybuffers brought solve times down to ~213–597 ms with smooth 60fps map rendering. - Balancing Case Reduction vs. ICU Collapse: Pure case-minimization sometimes shifted resources away from smaller, under-bedded wards at risk of hospital saturation. Designing an ICU-overflow-first acceptance rule paired with a strict Hospital Safety Guardrail ensured predictive plans protect vulnerable hospitals first while still lowering overall objective cost.
- Deterministic Reproducibility: Ensuring exact mass conservation (< 1e-9 drift) and auditable swap explanations across both live Open-Meteo weather feeds and offline fallback presets required strict mathematical gating.
Accomplishments that we're proud of
- Zero-Infrastructure Accessibility: Public health students, researchers, and municipal teams can run full spatial-epidemic optimizations directly in a browser without deploying cloud servers or managing API keys.
- Measurable ICU Pressure Reduction: On our verified Metro Tropica (20% budget) benchmark, SennaGrid cut ICU overflow from 16.8 bed-days to 0.0 (-100%) and eliminated all 5 ICU collapse days in 597 ms, passing 5/5 policy gates (100/100 score). On Harbor Corridor (30% budget), it reduced ICU overflow by 87.7% and cumulative cases by 2.12% in 214 ms.
- Full Auditability: Every weekly allocation decision includes human-readable rationale tags and an auditable swap trace rather than acting as an opaque black box.
What we learned
- Epidemiological resource allocation is fundamentally a spatial network and capacity-bottleneck problem—targeting high-centrality commuter hubs early prevents downstream hospital collapse far more effectively than chasing lagging case counts.
- Decoupling pure numerical TypeScript packages from UI frameworks makes deterministic testing, benchmarking, and Web Worker execution dramatically cleaner and faster.
What's next for SennaGrid
- Custom GeoJSON & Hospital Capacity Upload: Allow local health departments to import real municipal ward boundaries, census demographics, and actual hospital ICU bed counts.
- Stochastic Uncertainty Bands: Add Monte Carlo ensemble runs to visualize confidence intervals around weather forecasts and commuter mobility shifts.
- Multi-Intervention Portfolios: Support simultaneous mixed budgets (e.g., combining larviciding, fogging, mobile clinics, and targeted vaccination) with distinct lead times and decay curves.