Platform · 2026
PrivateJamaican Online Market
An offline-first marketplace for vendors with unreliable data.
Overview
A progressive web app putting Jamaican street vendors online. Built on the assumption that the merchant's phone has spotty signal, so the dashboard is local-first: every action applies instantly against local state and syncs later, and the sync is designed to be correct when ops arrive hours out of order.
The hard part
Conflict resolution that respects what the vendor actually knew
Every user action is an op with a client-generated id and a client timestamp — the moment the vendor actually acted, which matters when it syncs three hours later. The subtle rule is that sales and stock counts resolve differently. A sale is a commutative fact, so it is always ledgered; but it only decrements exact stock if the sale postdates the vendor's last absolute stock assertion. A vendor who counted twelve left at 3pm has already accounted for the 1pm sale that is only now syncing. Absolute stock sets are last-write-wins by client time, and losing to a later write returns 'stale' rather than an error — the other device simply spoke last. Undo works by deleting the queued op before the server ever sees it, so there are no compensating negative sales lying in the ledger.
What it does
- IndexedDB outbox with exponential backoff, flush on reconnect and on visibility change
- Sync exposed as a route handler, not a server action — server-action ids rotate across deploys, and an op queued for days would 404
- Idempotency keyed on client-generated op ids: first writer wins, replays acknowledged as duplicates
- Pure, unit-tested conflict reducer shared by client and server
- PostGIS for geo, pg_trgm for fuzzy search, MapLibre with keyless tiles
What it proves
- Distributed-systems reasoning applied to a real constraint, not a hypothetical one
- Designing for the user's actual network, not the developer's
- Knowing when a framework's convenience feature is the wrong tool
Stack
- Next.js 16
- React 19
- TypeScript
- PostGIS
- Drizzle
- IndexedDB
- MapLibre GL
- SSE
- Zod 4
Related