The problem
A shop till has to keep selling when the internet and the power go out, and two offline tablets must not overwrite each other's sales when they reconnect.
The approach
IndexedDB is the source of truth and Supabase is a replica. Stock is never synced as a quantity: each device appends stock movements, and stock on hand is their sum, so concurrent offline sales commute. Sales are append-only; a mistake becomes a void row, not a deletion.
Results
- A sale writes to IndexedDB in one transaction and never touches the network.
- A sync test suite covers the five failure modes that only appear across multiple devices, including two tablets selling the last unit while offline.
- Amharic-first UI, ETB pricing and 80mm thermal receipts.
What broke and what I learned
- Last-write-wins silently destroys a sale when two devices sync absolute quantities. Append-only rows avoid the conflict instead of resolving it.
- Free hosting tiers have limits that matter for a live shop: Supabase free projects pause after 7 days of inactivity.