How stock updates and reservations work

This guide covers: how warehouse changes update the shop and how checkout reserves the available stock.
About this guide

Prepared with AI under human direction. This guide describes the July 2026 implementation, with source and test references where noted.

1. What it does

Warehouse changes update the availability shown to customers. At checkout, Stock checks the current quantity again before reserving it.

Customer visibilityAvailability follows committed warehouse changes.

Availability updates reach the open product page through a live browser connection.

Checkout correctnessThe final unit is decided by Stock.

An atomic reservation guard accepts one valid hold and refuses every request that arrives too late.

Practical example: a stock manager removes damaged units and later records a delivery. The open product page first becomes sold out, then sellable again. If two shoppers race for the final available unit, only one reaches shipping.

2. From warehouse to product page

The first film shows the complete visible story with on-screen captions.

WAREHOUSE → STOREFRONT / 43.16S

Warehouse changes update the open shop

A damage adjustment closes the purchase action. A goods receipt reopens it. The customer does not reload the page and the operator does not coordinate with the storefront.

01
Record the warehouse changeStock validates the adjustment or receipt and preserves the reason as an auditable movement.
02
Send the updated availabilityConsumers receive the resulting state rather than an arithmetic delta that could be applied twice.
03
The open product page followsA snapshot establishes current state; live updates keep the connected customer informed.

3. The final unit is decided once

A displayed quantity does not reserve stock. The second film shows what happens when two customers try to reserve the last unit.

CONCURRENT CHECKOUT / 31.32S

One shopper wins the last unit

Both customers begin checkout simultaneously. Stock grants one reservation, lets that customer continue to shipping, and gives the other customer a clear sold-out result.

SHOPPER A

Reservation accepted

The guarded update holds the unit and checkout continues.

Stock decidesavailable ≥ requested
SHOPPER B

Insufficient stock

No stock remains to reserve, so this checkout cannot continue.

4. What changes for the customer

TECHNICAL DEEP DIVE

How inventory works

The sections below explain ownership, transactions, asynchronous delivery, browser recovery and the database decision that prevents overselling.

5. How inventory moves

One path keeps the shop current. A separate path confirms availability at checkout before any unit is reserved.

Two straight flows show warehouse changes reaching the storefront and checkout confirming availability with Stock
Checkout reservation pathAvailability update path
Warehouse updates refresh the availability shown in the shop. Checkout asks Stock to reserve the requested quantity separately.
BoundaryOwnsMay projectMust never decide
StockQuantity, movements, reservations, available-to-sellAuthoritative state and audit ledgerProduct merchandising or order lifecycle
Catalog / StorefrontProduct presentation and customer interactionAvailability for fast customer readsWhether the final unit is held
CartCheckout orchestrationReservation identity and statusStock allocation without Stock confirmation

6. Live availability sequence

The browser starts from a database snapshot and then follows complete availability updates emitted after committed warehouse transactions.

Sequence from warehouse adjustment through Stock transaction, outbox, Kafka and Catalog to browser availability
The Stock request ends after its local transaction commits. Publication and customer visibility happen asynchronously. The SSE endpoint subscribes to deltas before reading the initial snapshot.

7. Reservation concurrency

Two requests can reach checkout together. Correctness comes from the database mutation predicate, not request timing or the customer-facing projection.

Sequence where two shoppers request one final unit and the atomic database guard accepts only one
Idempotency prevents one checkout from reserving twice. The availability predicate prevents two independent checkouts from owning the same final unit.
Why this matters: the product page can be briefly stale without corrupting inventory. The authoritative reservation command evaluates current database state.

8. Reservation lifecycle

A checkout hold either becomes committed order stock, returns through cancellation, or expires safely. Each route keeps quantity changes and reservation state consistent.

Three straight lanes show an active reservation entering the FULFILLED Stock state and later shipping, being cancelled with stock released, or expiring with stock released
FULFILLED is the current Stock state name for a reservation committed to an Order; it does not mean Cart owns the business capability of fulfilment. Quantity remains reserved until shipment deducts physical stock. Cancellation and expiry return held quantity. Cleanup claim and release share one transaction, so a release failure leaves the active hold available for the next sweep.

9. Failure and recovery

Distributed reads can update at different times. Stock saves quantity and reservation changes in one transaction, while other services may take longer to catch up.

Database transaction failsQuantity, movement, reservation and outbox effects roll back together.
Kafka publication failsThe outbox retries; committed Stock state remains authoritative.
Projection is delayedVisibility can lag briefly, but the projection cannot award inventory.
SSE disconnectsThe browser reconnects with backoff and obtains a fresh snapshot.
Two checkouts collideThe guarded update accepts one mutation and cleanly rejects the other.
Expired-hold cleanup failsThe claim and release roll back, leaving the hold retryable.