Retail / commerce
StockPoint
Orders, stock, promotions and returns across stores and a distribution centre, with no overselling when hundreds of checkouts chase the same units.
In the demo you replay Black Friday for a fictional NZ homewares retailer: 600 checkouts compete for 40 units, a stock count releases exactly the promises it broke, and you compare a recovery plan before applying it. Underneath: an append-only stock ledger behind one conditional UPDATE, allocation that stores the reason for every choice, and versioned pricing.
- My role
- Sole engineer: spec to deployment
- Walkthrough
- 90-second guided scenario
- Focus
- Correctness under concurrent demand
Launch guided demo (opens in a new tab)Engineering evidence
Stack: React · TypeScript · PHP/Symfony · PostgreSQL · Playwright + axe
Independently built portfolio showcase · simulated data

The business problem
A retailer with eight stores, a distribution centre, a website and an app runs Black Friday. Hundreds of checkouts chase a few discounted units, a store count finds stock missing, a supplier delivers early and short, and a promotion stacks by mistake — all landing on orders customers were already promised.
Try the workflow
Step 1

Flash sale: checkouts compete for 40 eligible units; reservations stop exactly at what exists. Step 2

Reality check: a store count finds 5 where the system expected 12. Approving it releases exactly the broken promises. Step 3

Recovery: three plans compared before anything changes; applying one commits a reviewed decision, or gets a conflict if the data moved.
Engineering invariants
Rules the system enforces whatever the user does, and where each one is proven.
| Invariant | Why it matters | Evidence |
|---|---|---|
| A channel can reserve stock only if enough is free after reservations, picks and store protection. One conditional UPDATE on the balance row checks this; a CHECK constraint is the last guard. | Never commits more stock than exists, even when hundreds of requests hit the same SKU. | Contention test: 600 requests, exactly 40 commit, 20 runs (opens in a new tab)Integration/StockPointContentionTest.php :: testExactlyTheEligibleUnitsCommitUnderContention |
| Stock movements are INSERT-only. The balance row and its movements change in one transaction, and a ledger check proves balance = sum of movements for every key. | History is never rewritten, and drift is detected rather than assumed away. | ADR 0008 decision + 'Ledger check' (opens in a new tab)ADR 0008 — Stock reservations under contention: append-only ledger + transactional balance gate |
| A recovery preview records the version of everything it read. Applying it re-checks exactly those; if anything changed, it returns 409 and writes nothing. | A reviewed decision is never applied to a state the reviewer did not see. | Stale preview → 409, no partial write (opens in a new tab)Integration/StockPointRecoveryTest.php :: testAChangeOnAnAffectedKeyMakesThePreviewStaleWithNoPartialWrite |
System architecture
Key decisions
One conditional UPDATE on a balance row under READ COMMITTED, plus an INSERT-only movement ledger.
Why: Each reservation costs the same however long the history, and contention on a hot item queues on one row instead of causing retry storms.
Rejected: SERIALIZABLE with retries (retry storms), and a key lock with a ledger SUM on every reservation.
ADR 0008
Store protection is a reservation policy, and inbound supply is not stock: back-orders are promised only against confirmed deliveries.
Why: Store stock stays available for walk-in shoppers, and unknown supply never produces a promise date.
Rejected: Counting inbound supply as stock (my first design, corrected after review).
docs/specifications/013-stockpoint.md review history, §4, §13
Engineering evidence
Benchmark
Contention test
600 single-unit requests from 32 worker processes against 40 eligible units: exactly 40 committed and 560 refused in each of 20 runs, and the ledger matched every time. p95 latency 130 ms, because requests queue on one hot row by design.
Conditions: Local Docker, 8 CPUs, PostgreSQL 19, measured 2026-11-23 (ADR 0008)
Benchmark
Peak hour on production
20,000 orders over 5,000 SKUs at 9 locations in 24.9 s: 804 orders/s, p50 4.0 ms, p95 12.0 ms, no deadlocks or lock timeouts, ledger consistent.
Conditions: Production host: shared 4 vCPU, PostgreSQL 19, 4 worker processes
End-to-end
Playwright Black Friday smoke with axe
The whole Black Friday story with axe checks on four screens. 1/1 passing on production on 26 Nov 2026.
Conditions: Desktop only (the trading floor is a desktop surface)
Engineering page
“How it's engineered” in the live demo (opens in a new tab)
The full detail: rules, data model, tests and measurements, next to the running product.
I use AI-assisted development for implementation, exploration and review. I remain responsible for architecture, business rules, code quality and deployment. Critical behaviour is verified with deterministic tests, static analysis and reproducible benchmarks.
Trade-offs and limits
- Fictional retailer (Harbour & Home) and synthetic data
- No storefront, checkout or payments; refunds are calculated, not paid
- No real POS, ERP or warehouse integration
- No carriers, forecasting or loyalty
My contribution
I built StockPoint as an independent engineering showcase: product specification, architecture, frontend, backend, data model, automated tests and deployment.
Want to discuss the engineering behind this?
Launch demo (opens in a new tab)Get in touch
Source-code walkthroughs available on request.