Skip to content
AVAILABLE NOWMUMBAI · UTC+5:30
Aniket VishwakarmaStill online

Case 02 · 2026 · Deployed

SwasthyaSetu

An offline-first referral network for India's public health system, designed so no patient is lost between facilities.

No connectivityInconsistent identityHandwritten recordsClinical accountability
Role
Lead full-stack architect · monorepo
Year
2026
Status
Deployed
Focus
Platform · Offline-first · Real-time sync
Links
Live ↗ · Source ↗

01 / The brief

An offline-first referral network for India's public health system, built so no patient is lost between facilities.

Why it existed

Paper referral chits, inconsistent identities and disconnected EHRs cause patients to disappear between Sub-Centres, PHCs and district hospitals.

What shipped

Zero data loss on reconnect, a nine-state referral lifecycle, and an OCR confidence gate that never auto-saves an extraction below 90%. Clinicians never wait on the network.

02 / Context

The constraint came first.

India's public health system moves patients through Sub-Centres, PHCs, CHCs and district hospitals. Paper referral chits, inconsistent identities and offline EHRs cause patients to disappear between facilities.

  • Frontline devices are often offline for hours.
  • Patient identity is inconsistent across facilities; silent merges are unacceptable.
  • Handwritten OCR errors must never become clinical record without review.

03 / What I owned

My hands were on these.

  • Monorepo architecture spanning web, API, shared types and the AI service
  • IndexedDB-first write path and the idempotent EVT- sync queue
  • Multi-vector patient identity matching with human confirmation
  • Confidence-gated OCR and the nine-state referral state machine
  • Docker Compose deployment across frontend, API and AI services

04 / Decisions

Four choices that mattered.

  • Local-first writesIntake is written to IndexedDB first, then pushed through an idempotent EVT- queue when connectivity returns. The clinician never waits on the network.
  • Match, do not mergeMulti-vector scoring across phone, RapidFuzz name similarity, village and age/gender surfaces identity candidates for a human to confirm.
  • Confidence-gated OCRGemini Flash and TrOCR extract diagnosis, medication and follow-up dates. Anything below 90% confidence is flagged NEEDS_REVIEW and never auto-saved.
  • An explicit referral state machineNine states from DRAFT to FOLLOW_UP_COMPLETED, with an immutable audit event on every transition. Clinical accountability is part of the data model.

05 / Architecture

How the pieces fit.

ClientReact 18 · Vite PWA · Dexie / IndexedDB
SyncEVT- idempotent queue · domain conflict rules
APIExpress · Prisma · Zod · JWT
DataPostgreSQL · Supabase · audit events
AIFastAPI · TrOCR · Gemini Flash · RapidFuzz

06 / Evidence

What can be measured.

0Data loss on reconnect
9 statesReferral lifecycle
<90%OCR review gate
4Clinical roles

Metrics state their source on the receipts ledger.

07 / Reflection

What broke, and what I would change.

Last-write-wins is not good enough for clinical data. I would add a sync simulator that injects partitions and reordered events into CI, then resolve conflicts with domain rules rather than timestamps.

08 / Stack and fit

Stack

ReactViteTypeScriptDexie.jsExpressPrismaPostgreSQLFastAPITrOCRGeminiRapidFuzzDocker

Reads as

PlatformOffline-firstReal-time syncAI reliability