Selected workCircuit 1 · Money
Gold trading engine
No two buyers can take the same piece of gold
- My role
- Architect and builder
- When
- AcuteBusiness · 2024 – present
- Where it stands
- Company product
What I built
A high-concurrency gold trading system for Estore, with the geo-spatial delivery engine and the digital wallet integration around it.
Why it mattered
Prices change in fractions of a second, and many people can try to buy the same item at once. Without care, two orders could both succeed for one piece of gold, or a trade could go through at a stale price.
- 1Signature
- 2Lock
- 3Commit
pieces in stock3
last serial soldnone
No orders yet.
Illustration running in your browser. It shows the real system’s approach in simplified form; names and numbers are invented, and nothing here touches the real system.
What made it difficult
Everyone arrives at once
Concurrent orders can reach for the same item in the same instant.
Prices don’t wait
Price fluctuations are measured in fractions of a millisecond, so a trade can’t be half-done when the price moves.
Balances are a target
Wallet requests come from clients, and a changed payload must never change a balance.
How I solved it
Lock, then trade
Redis atomic locks guard each trade, so concurrent orders for the same item are handled one at a time.
Two-phase commit
A trade is prepared first and committed only when every part agrees, which prevents race conditions mid-trade.
Every piece has a serial
Inventory is tracked by serial number, so stock can never be sold twice or go missing.
The backend owns the balance
Wallet requests are signed with HMAC and the backend is the single source of truth, so a tampered payload cannot change a balance.
Delivery fees from the map
MySQL Spatial (GIS) checks which district polygon an address falls in, and the fee follows from that point-in-polygon test.
What I delivered
The trading core of Estore, an asset-trading product at AcuteBusiness.
Guarantees by design: no race conditions on a trade, strict inventory integrity, tamper-proof wallet balances.
Around it: a geo-spatial delivery engine and the digital wallet integration. No trading volumes are published here.
Built with
- Laravel
- Redis atomic locks
- MySQL
- MySQL Spatial
- HMAC signatures