SYSTEM ARCHITECTURE & POSTMORTEM
1. Situation Context
PharmacyIQ operated inventory APIs across regional pharmacies. During peak counter traffic, inventory lookups suffered from 450ms latencies, causing massive delays at the checkout counters.
2. Why It Was Interesting
WAN links are notoriously unstable in outlying postcodes. A central database locking pattern meant that if one store dropped packets, the central catalog locked, blocking checkouts nationwide.
3. What We Built
We built an offline-first inventory proxy in Rust. We cached the catalog locally in each shop using SQLite. Writes are buffered to an local event log and replicated asynchronously to the central database using NATS JetStream. Latency dropped to sub-10ms for checkout operations, and stores remained fully operational even during network blackouts.