LifeOS
← projects
in progressSep 2026 · 5 min read · 1 diagram

Synapse

Stack React · TypeScript · Hono · Cloudflare Workers · Postgres · Drizzle

The itch

Synapse is hospital management software for outpatient care, built for one pilot hospital in India. That hospital runs on paper today. It sees 100 to 250 outpatients a day with one regular doctor, a stand-in for leave and a visiting specialist about once a week. One front desk handles reception, billing and the pharmacy. The goal was a real system for that building first, structured so it could later serve other hospitals as a product.

What it does

A patient's day runs through a queue, and the app follows it:

A patient's visit

The desk finds a patient by phone number or name, or registers them, and issues a token. Tokens restart at 1 each day with separate numbering per doctor. A nurse records vitals. The doctor writes the consultation and prescription, picking medicines from what the pharmacy actually stocks and seeing when a line is out. From there the patient goes to the lab, to the procedure room or to the pharmacy, and one bill covers the whole visit at the end. Prescriptions, receipts and lab reports print on the hospital's own letterhead through the browser.

Underneath sit the less visible parts: stock with batches and expiry dates, dispensing earliest-expiry first, a free follow-up window that the app applies automatically, admin-only discounts that get logged, a day-end close split by cash, UPI and card, and an access log of who changed what. Each role gets one screen it can work a full day on.

The newest piece is dictation. The doctor speaks the consultation, and one call to Gemini hears the audio and returns the form's fields as structured data, with medicines matched against the hospital's own list. It comes back as a card to accept or discard, so nothing fills in silently. On the bench it got every medicine, dose and day right in three to five seconds.

How it works

The stack was chosen around one constraint: nobody should have to administer anything. There's no clinic server, no virtual machine and no container to restart. The API is Hono on Cloudflare Workers, the web app is a Vite and React single-page app, Postgres and file storage are managed by Supabase in Mumbai, and Zod schemas shared between the two halves keep the forms and the API agreeing on shape. Deploying is two uploads.

It's multi-tenant from the first commit. Every tenant table carries a hospital_id, and Postgres row-level security enforces it. The API connects as a role that can't bypass those policies, and one wrapper sets the current hospital inside every transaction, so feature code never filters by hospital and can't forget to. Business rules such as bill totals, the follow-up window and which batch to dispense from all run on the server. The UI hides what a user can't do. The API is what stops them.

What got hard along the way

The worst day was a demo. On 2026-10-10, sign-in and every screen failed for about twenty minutes, mid-demo. The postmortem found three causes stacked on each other. A reseed of the demo data, run on request, deleted and recreated every demo login, which signed everyone out at once. Every screen then signed in again together, and a sign-in costs about 150 ms of CPU for password hashing against the Workers free tier's 10 ms limit. Cloudflare tolerates that occasionally, and here it stopped tolerating it. Then a burst of diagnostic requests against the live API drained it further and tripped the sign-in rate limit. The fixes were as concrete as the causes. The seed now restores the clinic from a saved snapshot and leaves logins and sessions alone, a nightly job reseeds at 3 a.m., and nobody load-tests production without asking. The deeper issue, a new database connection on every request, is parked for the go-live milestone with its measurements written down.

Dictation had its own bad evening. Gemini's model answered "high demand" errors for hours, which is load shedding rather than a quota problem. The fix falls back to a lighter Flash model that the bench showed returns the same medicines and doses, then retries the first one, all inside a minute.

Most of the design time went into the screens rather than the code. Every visual decision went through side-by-side mockups before it was built, and the rejected list is long: rooms stacked in pairs, a colour per room, short room names like "Pharm," a full-width search. Switching users on a shared front-desk computer ended up as a lock screen with a four-digit PIN per person, which only works on a browser where that person has already signed in with their password.

Where it stands

Milestones one through nine are done: foundation, patients and queue, consultation, pharmacy, billing, lab, reports, a design pass and the role workspaces. Dictation shipped on 2026-10-03 as the first of the extra features. A demo hospital with fictional patients runs on the deployed app and refreshes every night. Pilot go-live is the last milestone and hasn't started.