System Design Atlas

B2B wholesale orders with credit limits

06 / 10Worked example

The overall architecture

Where does the local transaction end before external fulfilment?

The data contract leads to this topology: customer portal → order API → relational order, stock and credit-reservation datastore. The fulfilment worker reads the outbox → inventory management. Response intake stores inbox records → reconciliation worker converts reservations to receivables. The sales interface maintains versioned offers through the same API. Internal modules are domain code boundaries; a separate process has its own operational lifecycle.

Starting point Perform both checks and reservations in one transaction.

Assumptions for the example case

A fictional example design with one customer, one currency and one warehouse; a binding price offer; complete local stock and credit reservations; and one complete delivery. Figures and quality goals are illustrative test assumptions. Multiple currencies, tax calculation, partial delivery and credit insurance are outside the scope.

Runtime architecture

Runtime architecture · Local reservations, asynchronous fulfilment

Customer portalPurchasing
Sales interfaceOffers

Wholesale platform

Order APIPrice + stock + credit
Relational datastoreOrders · Reservations · Outbox · Inbox
Fulfilment workerDeliver outbox work
Response intakeCommit inbox record
Reconciliation workerConvert to a receivable
Inventory managementFulfilment + proof of delivery
Customer portal → Order APIOrder + Key
Sales interface → Order APIMaintain offer
Order API → Relational datastoreOrder + reservations + outbox
Relational data store → Fulfilment workerOutbox
Fulfilment worker → Inventory managementFulfilment request
Inventory management → Response intakeDelivery evidence
Response intake → Relational datastoreInbox
Relational data store → Reconciliation workerInbox entry
Reconciliation worker → Relational datastoreConvert reservation to receivable

The API commits the order, both reservations and outbox; inbox and reconciliation bring external delivery evidence back into the system.

Inventory management responds slowly. Persist the local commitment and transmit the external order separately. Network waits hold no inventory lock.

Domain modules within the application

Inside the order API · Five domain modules

Price validationOffer + Quantity
Stock commitmentReserve boxes
Credit commitmentReserve credit
FulfilmentTrack handover
Conversion to receivablesReplace the reservation

The modules coordinate a local commit and share the authoritative relational datastore.

Price validation binds a valid offer and quantity. Stock commitment checks and reserves available boxes. Credit commitment checks remaining credit and reserves the order amount. Fulfilment tracks handover and actual delivery. Receivable conversion replaces the credit reservation with a confirmed receivable.

Operational boundaries

Runtime
Customer portal → order API → relational order, stock and credit-reservation datastore. The fulfilment worker reads the outbox → inventory management. Response intake stores inbox records → reconciliation worker converts reservations to receivables. The sales interface maintains versioned offers through the same API.
Persistence
Transactional datastore for order A-101, offer P-101 and stock W-101. Authoritative changes and retry results are stored together; external effects require their own evidence.

Process fulfilment after the commitment

Process fulfilment after the commitment

Persist the local commitment and transmit the external order separately.

Inventory management responds slowly.

Network waiting time does not hold a stock lock.

Alternative considered
An external call inside the transaction prolongs locks.
Trade-off
Fulfilment status initially remains open.
Reassess
Inventory management offers a shared atomic interface.

Terms in this step

Process fulfilment after the commitment
Network waiting time does not hold a stock lock.

Try it yourself

Inventory management responds only after ten seconds. Where does the network call run, and which state is already durable?

A hint for your attempt

Use the specific entities and conditions from this step. The two solution parts distinguish the decision from its evidenced outcome.

Compare with a possible solution
First part of the solution
The local commitment and fulfilment request are first stored durably together.
Second part of the solution
The worker calls the external system. During those ten seconds, no local inventory lock is held for the network call.

Apply to your project

Which corresponding assumption would you test first in your project? Consider this trigger: Inventory management offers a shared atomic interface.

Step 7 examines applying delivery once.