Backend Engineering
HMS — Multi-Tenant Hospital Management System — A Developer's Deep Dive
Modular, multi-tenant hospital platform: 53 backend modules across clinical, finance, HR, and supply chain.
A modular, multi-tenant hospital management system built as a Go + Rust + Next.js monorepo. The Go backend ships 53 business modules — patient registration, OPD/IPD, pharmacy, laboratory, EMR, e-prescription, nursing, operation theatre, radiology, blood bank, ambulance, billing, general ledger, AR/insurance, accounts payable, procurement, payroll, recruitment, telemedicine, patient/doctor portals, CSSD, dietary, housekeeping, biomedical equipment maintenance, and a cross-module BI dashboard, among others — each implementing a shared module contract with its own routes, migrations, permissions, tests, and generated docs, so modules can be excluded per customer to build smaller, licensed offline installers. The Next.js + TypeScript frontend is offline-first (IndexedDB via Dexie, sync outbox), backed by a Rust sync-engine for push/pull replication, PostgreSQL for data, Redis for caching, and Meilisearch for search.
The problem
Hospitals running dozens of departments — clinical, pharmacy, lab, billing, HR, procurement — typically stitch together separate systems per department with no shared patient record, no offline resilience during network drops, and no way to license or deploy a smaller build per customer without shipping the entire system.
The approach
Designed a modular Go backend where all 53 business modules implement a common module contract (routes, migrations, permissions, tests, generated docs) registered through a per-tenant module toggle system, so unused modules can be excluded to produce smaller offline installers. Backed it with PostgreSQL, Redis, and Meilisearch, added a Rust sync-engine (Axum push/pull) feeding the offline-first Next.js/TypeScript frontend (Dexie-backed IndexedDB cache + outbox), RBAC with branch-scoped overrides, a tamper-evident audit hash-chain, and Ed25519-based offline license verification.
The outcome
53/53 backend modules complete and tested, a Next.js dashboard with a generic CRUD UI across every module plus dedicated pages (results portal, subscription, clinic settings), Playwright end-to-end coverage across 19 specs, and a generated documentation site (BRD/FRD/SRS/API/permissions per module) — roughly 97% weighted complete, with external pentest sign-off and installer packaging as the remaining steps.
Stack
Go, Rust, Next.js, TypeScript, PostgreSQL, Redis, Meilisearch, Docker Compose
Live architecture demo
See it move, not just read about it.
Re-using the original animation from the linked project — same diagrams and trace you see on the case-study page.
HMS 53-Module Monorepo
STATE: OFFLINE CLINIC WRITESEd25519-signed offline writes, drained into PostgreSQL with RLS once reconnected.
The Sub-2s Offline Reconcile
STEP 1/6