#case-study: 04•Multi-Branch Pharmacy ERP & POS•In Active Development
PharmaDaily
Enterprise-grade multi-branch pharmaceutical inventory, POS, and procurement platform built as an installable PWA with Serwist service worker, allowing offline cashier billing during internet dropouts while enforcing strict branch isolation at the PostgreSQL database level.
#note:Multi-branch ERP schema, POS caching, and inventory modules in active development.
01.Problem & Context
Retail pharmacies suffer from expired drug stock losses, manual billing errors, lack of branch isolation, and severe revenue disruption when internet drops disable cloud POS systems.
02.System Architecture & Data Flow
Next.js 16 App Router with TypeScript and Tailwind CSS, Supabase (PostgreSQL with strict Row Level Security & SECURITY DEFINER helpers), atomic database functions (create_sale, create_purchase, create_stock_adjustment), and Serwist PWA service worker for offline resilience.
03.Engineering Challenges & Solutions
- Enforcing database-level branch isolation via PostgreSQL RLS and SECURITY DEFINER helpers so client-side tampering is impossible.
- Designing an append-only immutable stock movement ledger (stock_movements) verified by 70+ automated transaction tests.
- Building an offline-first PWA caching pipeline so billing continues uninterrupted during network disconnects.
#technologies-utilized
Next.jsTypeScriptSupabasePostgreSQLTailwind CSSSerwist (PWA)