Supermarket ERP
An ERP for a multi-branch, multi-floor supermarket chain.
- .NET 10
- Next.js 16
- PostgreSQL
- EF Core
- React 19
- TanStack Query
- IndexedDB
- Docker Compose
Closed source · case study
The problem
A supermarket chain needs one system for stock, purchasing, the tills, outside orders, its public shop and in-store advertising, across several branches, each with its own catalogue and stock.
Two things can't go wrong: a till that stops selling when the network drops, and a stock number nobody can explain.
My role
I built 9 modules, front to back:
- Inventory & warehouses
- Purchasing
- Point of sale
- External orders
- Public website
- Marketing & in-store advertising
- User management
- Shared tools
- Settings
Architecture
ALSO IN THE SYSTEM
- Catalogue changes reach every till within seconds, pushed over Server-Sent Events
- Two currencies: prices are dated, and exchange rates are frozen on every movement and order
- The low-stock screen suggests order quantities from reorder points per product variant and stock zone
- Tools include a price checker and price labels
Key decisions
The till never waits for the network
- CHOSE
- Every sale is written to the browser's IndexedDB first, then flushed in order: customers, then sales, then returns. Tills number their own receipts offline from a two-digit register code.
- REJECTED
- Online-only tills that call the API on every sale.
- WHY
- A supermarket can't stop selling when the connection drops. The server's two-part idempotency means a sale retried after a timeout is never booked twice.
Stock is a ledger, not a number
- CHOSE
- An append-only stock movement ledger, enforced by a database trigger, with corrections as reversal rows and balances per variant per zone.
- REJECTED
- Editing stock quantities in place.
- WHY
- Every number on screen can be explained by the movements behind it. Negative stock is flagged, never blocked, so the shelf and the system get reconciled instead of the till refusing a sale.
Transfers lock in a fixed order
- CHOSE
- Take advisory locks in a fixed order before posting any movement that touches several variants.
- REJECTED
- Relying on the database's row locks alone.
- WHY
- Two opposite transfers deadlocked, reproduced three times out of three. Ordering the locks removes the cycle instead of retrying around it.
Prices are dated, not overwritten
- CHOSE
- A price change adds a dated line. The exchange rate is frozen on every movement and order, and the rate history is append-only.
- REJECTED
- Updating the price in place.
- WHY
- A sale made last week is still explained by the price that applied then, and in a two-currency market a till's hours-old rate can be checked against the history.
Results
9
modules I built
4
branches in the rollout
Offline
tills keep selling, and sync when the network returns
Daily
core modules in use every day
What I'd do next
- 01
Build the nightly balance check the ledger was designed for: recompute every balance from its movements and flag any drift.
- 02
Derive reorder points from sales velocity instead of typing them by hand.
- 03
Value stock in one base currency, so reports across dollar and local-currency costs add up.