← work

Sneaker Drop

Real-time inventory system

A limited-inventory reservation system that provably cannot oversell under concurrent load.

Sneaker Drop screenshot

about

Sneaker Drop is a small system built to answer one specific question: how do you stop two users from buying the same last item at the same time? It is the classic limited-drop problem, and almost every demo solution gets it wrong.

The frontend is a simple React app. The backend is Express with PostgreSQL and Sequelize. The interesting work is entirely in the reservation logic and in proving that it works.

interesting

Reservations use PostgreSQL transactions with pessimistic locking. Two users hitting the last item cannot both succeed. The second transaction blocks, sees the updated stock, and fails cleanly.

A 100-user race test verifies that exactly one reservation succeeds for a single available item. The test is the proof, not the claim.

Socket.io broadcasts inventory changes to all connected clients in real time. Users see stock drop the moment it drops, not on the next poll.

The system models the reservation itself as a first-class entity with a lifecycle, not as a boolean flag on the product. That makes expiry, cancellation, and audit straightforward.

Pessimistic locking was the right call here. With limited stock and a small window, blocking the second transaction and letting it fail cleanly is simpler than optimistic retry loops.

stack

Node.js · Express · PostgreSQL · Sequelize · Socket.io

links