Inspiration
In rural regions, seasonal monsoons trigger predictable yet devastating surges in vector-borne and waterborne diseases like malaria and cholera. Operating with a 21-day (3-week) supplier delivery lead time and zero predictive visibility, rural clinics often discover a critical shortage only after shelves are already empty—turning preventable illnesses into life-threatening emergencies.
We built PulseChain AI to transform rural medical supply chains from reactive crisis management into proactive, weather-aware prevention—ensuring medicines move before the rains arrive.
What it does
PulseChain AI is an offline-first Progressive Web App (PWA) that forecasts disease outbreaks, models batch-level medicine depletion, alerts health workers via SMS, and orchestrates safe inter-clinic transfers.
Core Capabilities
| Module | What It Does | Key Rules & Safeguards |
|---|---|---|
| 8-Week Disease Forecasting | Projects weekly clinic-level cases for Malaria, Cholera, and Pneumonia using lagged rainfall (1–2, 2–5, and 8 weeks prior), temperature, seasonality (sin/cos), and catchment population. |
Outputs mean predictions plus calibrated 80% prediction intervals (10th/90th percentiles). |
| FEFO Inventory Engine | Translates projected cases into daily demand for 6 essential medicines (ACT, RDT kits, ORS, Ringer's lactate, etc.) and simulates day-by-day First-Expired, First-Out (FEFO) stock depletion. | Automatically excludes expired batches, tracks expiry waste, and computes stock-out dates and reorder quantities. |
| Risk Classification & Reordering | Calculates margin = days_until_stock_out - supplier_delivery_time across every clinic-medicine pair. |
Critical: < 0 daysHigh: < 10 daysWatch: < 21 daysAdequate: ≥ 21 days |
| Automated SMS Alerts | Generates concise, actionable warnings (≤ 320 characters) with exact depletion timelines, demand surge percentages, and recommended reorder pack sizes. |
Simulated phone UI by default; live Twilio dispatch locked behind 4 explicit safeguards (SMS_MODE=live, SMS_ALLOW_LIVE=true, credentials, and confirm_live: true). |
| Smart Redistribution Map | Matches at-risk receivers (Watch or worse) with safe donors (Adequate clinics holding surplus above their 90th-percentile pessimistic demand + 28-day buffer + safety stock). |
Requires ≥ 90 days shelf life on arrival, same medicine, road distance ≤ 140 km (1.3 × straight-line) and ≤ 6 hours, and 100% human approval. |
| Interactive 8-Step Monsoon Demo | Injects a simulated 3× normal rainfall event ramping over 2 weeks to demonstrate live case surges, stock-out spikes (14 → 36 at-risk pairs), SMS alerts, and map transfers. | Clearly labeled as synthetic/illustrative data on every screen; one-click reset restores baseline state. |
How we built it
We intentionally engineered PulseChain AI with zero frontend build steps and minimal dependencies so it installs reliably on low-resource hardware and operates seamlessly offline.
System Architecture & Tech Stack
- Backend & API (
Python 3.10+,Flask,SQLite):api.pyserves 14 RESTful JSON endpoints and static assets.engine.pyhandles caching, state orchestration, offline replay, and scenario injection.db.py&data_gen.pymanage a deterministic, seeded SQLite database spanning 12 clinics across 3 regions (Highland, Riverine, Coastal), 5 years of weekly epidemiological/weather history, 6 medicines, and 148 inventory batches (including pre-expired and near-expiry batches to test FEFO edge cases). Plain SQL is kept compatible for seamless PostgreSQL migration.
- Machine Learning Pipeline (
scikit-learn):- Trained pooled
HistGradientBoostingRegressormodels (mean + 10th/90th quantile models) on ~24,000(clinic, origin_week, horizon 1–8)rows per disease, targeting $\log(1 + \text{cases per 1,000 catchment population})$. - Chosen over XGBoost to eliminate extra binary dependencies while remaining modularly swappable in
forecast.py.
- Trained pooled
- Offline-First Frontend (
Vanilla ES Modules,Custom SVG,Service Worker):- Built without React, TypeScript, or map tile servers—charts and the regional redistribution map are rendered as lightweight, hand-written SVGs.
- A custom Service Worker caches the app shell and
GET /api/*responses inlocalStoragewith visible last-sync timestamps, while queuing offline inventory edits and alert acknowledgments to replay automatically upon reconnection.
Key REST API Surface
| Endpoint | Method | Purpose |
|---|---|---|
/api/summary & /api/clinics |
GET |
Dashboard KPIs, risk distributions, and clinic-level stock profiles |
/api/forecast |
GET |
8-week disease projections, demand curves, driver importance, and validation metrics |
/api/scenario |
GET / POST |
Inspect or trigger the simulated 3× monsoon rainfall scenario |
/api/inventory & /api/inventory/batches |
GET / PATCH / POST |
FEFO stock lines, batch quantity edits, and incoming stock receipts |
/api/transfers & /api/transfers/decision |
GET / POST |
Donor-receiver transfer matching and human approval/rejection workflows |
/api/alerts & /api/sms/send |
GET / POST |
Threshold alerts, acknowledgments, and safeguarded SMS dispatch/logs |
/api/demo/walkthrough |
GET |
Data pipeline powering the 8-step interactive Monsoon Demo |
Challenges we ran into
- Calibrating Quantile Uncertainty Intervals: Raw 10th/90th percentile gradient-boosted models initially under-covered true variance during sharp seasonal spikes. We solved this by splitting the held-out validation year into two halves—calibrating a widening multiplier on the first half and verifying empirical coverage on the second half.
- Separating Offline Edits from Server Re-Computation: In rural clinics, connectivity drops unpredictably. Allowing users to edit stock levels offline while preventing stale client-side forecasts required strict state boundaries: offline edits and alert acknowledgments are queued locally with conflict detection, while ML inference, SMS dispatch, and transfer recalculations lock cleanly until reconnection.
- Preventing Donor Depletion & Expiry Waste in Redistribution: Naive surplus sharing risked stripping a donor clinic right before its own outbreak or shipping medicine that would expire before use. We solved this by calculating donor surplus against their 90th-percentile pessimistic forecast over
(delivery_time + 28 days)plus safety stock, and enforcing a strict ≥ 90-day remaining shelf-life rule upon arrival.
Accomplishments that we're proud of
1. Outperforming Epidemiological Baselines (52-Week Held-Out Test Split)
Across a strict temporal split holding out the final 52 weeks of data, our pooled gradient-boosted models beat both Seasonal Naive and Persistence baselines across every disease:
| Disease | PulseChain Model (MAE) | Seasonal Naive (MAE) | Persistence (MAE) | Calibrated 80% Band Coverage |
|---|---|---|---|---|
| Malaria | 3.46 | 4.18 | 5.65 | 81% |
| Cholera | 1.46 | 2.65 | 3.25 | 87% |
| Pneumonia | 4.63 | 5.12 | 6.02 | 77% |
(Metrics measured in cases per clinic-week on the held-out synthetic validation year.)
2. Quantifiable Impact in the Monsoon Simulation
During the 8-step monsoon stress test (3× normal rainfall over 2 weeks):
- Early Risk Detection: At-risk clinic-medicine pairs jump from 14 to 36 before shelves empty, surfacing exact shortages (e.g., Mahulpali Dispensary projected to run out of ACT in 16 days amid a +154% demand surge).
- Zero-Build, Single-Command Deployment: Runs end-to-end with a single
pip install -r requirements.txtandpython -m pulsechain.cli serve(~30s for data generation and model training), verified by an automatedpytestsuite and headlessscripts/e2e_check.pyrunner.
What we learned
- Forecasts Don't Save Lives—Actionable Margins Do: Rural health workers cannot act on raw epidemiological curves alone. Translating cases into FEFO batch depletion, days-of-cover margins, and exact reorder pack sizes bridges the gap between data science and clinic operations.
- Deterministic Guardrails Build Clinical Trust: Keeping ML strictly in the forecasting layer while enforcing transparent, deterministic rules for inventory math, transfer safety, and human-in-the-loop approvals makes AI recommendations auditable and trustworthy for healthcare teams.
What's next for PulseChain AI
- Real-World Surveillance & Weather Integration: Replacing synthetic tables (
clinics,weather,cases,consumption,inventory_batches) with live Ministry of Health surveillance feeds and automated meteorological forecasts, paired with formal epidemiological validation and locally approved clinical protocols. - PostgreSQL & Per-Clinic Quantile Calibration: Migrating from SQLite to PostgreSQL for multi-district scale and introducing clinic-specific interval calibration to push pneumonia coverage above the 80% target.
- Two-Way SMS / USSD & Multi-Language Alerts: Adding localized SMS templates and USSD/SMS reply commands so health workers on basic feature phones can update stock counts and approve transfers without smartphones or internet access.
- Authentication & Supplier Lead-Time Learning: Implementing role-based access control (RBAC) for clinic staff vs. district pharmacists and dynamically learning supplier delivery lead times from historical order receipts.
Built With
- css3
- es6
- flask
- gradient-boosting
- html5
- javascript
- localstorage
- machine-learning
- npm
- open-meteo
- pwa
- pytest
- python
- rest-api
- scikit-learn
- service-workers
- sqlite
- svg
- twilio

