System Design Atlas

Grocery orders with store inventory and substitutions

10 / 10Worked example

Final design

Which three decisions carry the purchase until the completed conclusion?

The final design brings together the complete architecture from step 6. B-17 is accepted in filiale-17; original item A-10 is missing, and permitted substitute A-11 is picked for 220 cents. E-17 charges exactly that amount. A lost response leads to reconciliation of the same instruction; confirmed success then permits a single handover. The following evidence is a test plan, not measured results.

Starting point The complete architecture and the error cases are side by side.

Assumptions for the example case

Own example design for pick-up from a store and packaged piece goods with strictly positive integer cent prices. Free and fully discounted baskets are outside the case. Replacement items are specifically allowed in advance; the final positive amount arises from goods actually provided and is collected on collection. Figures and target values are illustrative design assumptions.

Comprehensive architecture with test reference

Seven nodes · twelve directed relationships · one backend boundary

  1. 1Order/Allocation · Customer interface → API → Storage
  2. 2Replacement Pick · Branch Interface → API → Memory
  3. 3Introduction · Background Process → Payment Service
  4. 4Confirmed output · API → Branch interface
Customer interfaceGroceries, substitution approvals, status
Store interfacePick, restock, hand over

Back end limit · Order application

Order APIContracts, authorisation, atomic domain changes, webhook acceptance
Background processOutbox, feed import, payment reconciliation, clearance lists
Transactional storeOrder, P/Z, Picks, Commands, Inbox/Outbox, Payment Order
Inventory managementagreed ordered movement feed
Payment serviceCharge and confirmed payment status
  1. 01Customer interface → Order APIOrder/Read status
  2. 02Order API → Customer interfaceBasket and status
  3. 03Store interface → Order APIPick / restock / hand over
  4. 04Order API → Store interfaceResult / Conflict / Release
  5. 05Order API → Transactional storeAtomic Commands / Inbox
  6. 06Transactional store → Order APICommit / authoritative state
  7. 07Background process → Transactional storeRead Outbox, Feed and Save Results
  8. 08Transactional store → Background processOpen instructions / sequence watermark
  9. 09Inventory management → Background processOrderly branch movements
  10. 10Background process → Payment serviceExecute E-17 / Reconcile status
  11. 11Payment service → Background processResponse / confirmed status
  12. 12Payment service → Order APISigned feedback
Alast pack, both ordersTransactional store · Return Step 5
CResponse loss after chargingPayment service / background process · Return Step 7
DDuplicate restocking reportTransactional store · Return Step 5
EUnknown since 120 sCustomer-service evidence · Return Step 9

Order API and background process belong to the same application. Local decisions share the transactional store; external effects remain orders in need of confirmation.

The overall architecture combines allocation, replacement pick, payment reconciliation and handover. Five test markers in the diagram and six test cases in the table lead back to the affected design steps.

Decisions and expected evidence

Decision or building blockTest and target resultReturn to an earlier step
Secure API and Transaction Store AllocationTwo requests for the last pack in both orders: exactly one winner.Steps 3 and 5
Replacement check connects release and pickReplacement prices 0, 219, 220 and 221 cents, as well as unauthorized items: only allowed items with a positive price up to and including 220 cents.Step 2 and 4
Inventory management separates P, Z and PickReplacement pick, cancellation and double restocking: original remains zero, replacement comes back exactly once.Step 5
Worker and payment service clarify E-17Lose response after charge: exactly one charge; no handover before confirmation of B-17, E-17, 220 cents and EUR.Steps 4 and 7
Clarification list has role and threshold119,999, 120,000 and 120,001 milliseconds: escalation from the limit, state remains open.Step 9
Feed Contract Protects AuthorizationDouble movement works once; a gap blocks promises until the proven joint matching.Step 4 and 8

Secure API and Transaction Store Allocation

Test and target result
Two requests for the last pack in both orders: exactly one winner.
Return to an earlier step
Steps 3 and 5

Replacement check connects release and pick

Test and target result
Replacement prices 0, 219, 220 and 221 cents, as well as unauthorized items: only allowed items with a positive price up to and including 220 cents.
Return to an earlier step
Step 2 and 4

Inventory management separates P, Z and Pick

Test and target result
Replacement pick, cancellation and double restocking: original remains zero, replacement comes back exactly once.
Return to an earlier step
Step 5

Worker and payment service clarify E-17

Test and target result
Lose response after charge: exactly one charge; no handover before confirmation of B-17, E-17, 220 cents and EUR.
Return to an earlier step
Steps 4 and 7

Clarification list has role and threshold

Test and target result
119,999, 120,000 and 120,001 milliseconds: escalation from the limit, state remains open.
Return to an earlier step
Step 9

Feed Contract Protects Authorization

Test and target result
Double movement works once; a gap blocks promises until the proven joint matching.
Return to an earlier step
Step 4 and 8

First end-to-end path to be implemented

Replacement pick until issue
First, carry a basket with an original order line and allowable replacement through order, replacement pick, payment instruction, simulated loss of response, reconciliation and handover. In addition, cancel the same pick before the start of payment and report physical restocking repeatedly. Only then does a shopping cart with several items expand the sum and final check. Open integration issues are the common stock sequence watermark, the provider status after the expiration of the Idempotency period and the separate refund process for already paid, not yet handed-over goods. They are concluded before production with specific contracts and responsible persons.

Case decision and verification approach

Complete first end-to-end path

Implement a complete end-to-end path with a replacement pick and lost payment result.

The first implementation step is intended to demonstrate the most difficult commitment.

Physical deviation, local contention and unknown payment are examined in the same case. All expected results of the proof table and the case contract are executed.

Alternative considered
A first implementation of only catalogue and shopping cart postpones the decisive risks.
Trade-off
Even the first end-to-end path requires a simulated payment service and controlled error points.
Reassess
The scope is only expanded after the counterexamples have been passed; reader examination and user acceptance remain separate proofs.

Terms in this step

End-to-end path
A complete main path from order and replacement pick through payment reconciliation to handover.
Validation plan
It combines every central decision with test, target result and return to the draft.

Try it yourself

Justify three decisions: a shared transaction for substitution, reconciliation of the existing charge, and physically confirmed restocking. For each, name a test, expected result and design step to revisit.

A hint for your attempt

The return leads to the erroneous acceptance or rule, not just the implementation file.

Compare with a possible solution
Replacement joint transaction
Replacement changes Original Allocation, Original Forecast, Replacement Forecast and Pick together. A crash before commit does not change a page; after commit, all changes are visible. An error leads back to step 5.
Clarification of collection
Reconcile an unknown charge using E-17. Response loss after success must leave exactly one charge and keep handover blocked until evidence arrives. A failure leads back to step 7 and, for an unclear provider protocol, step 4.
Physically confirmed restocking
The restocking only increases the actual picked item after physical confirmation. A double message increases the replacement once, the original remains zero. An error leads to step 5 and, in the absence of ownership, to step 9.

Apply to your project

Take these three types of evidence into your own design: atomic local decision, confirmed external effect, proven physical action.

Use the Markdown draft template and formulate the first end-to-end path of your own system.

Start your own design

Choose a small case from your project. The template collects the ten design tasks and leaves space for your sketches, decisions, and open assumptions. You can edit it in your text editor or note-taking app.

Download design template (.md)
Compare the ten tasks with the example case
  1. Purpose and boundary

    Where do your system plan and actual execution differ?

    In the example: The boundary separates forecasts, physical goods and payment effects.

  2. Requirements

    Which waiting period must trigger only a reaction in your project, but no domain success?

    In the example: Invariants and operational goals have separate evidence.

  3. Scale estimates

    Which single item concentrates contention in your project?

    In the example: Quantity calculations and conflict tests are separate test profiles.

  4. Interfaces

    Which inputs define the same intention in your project?

    In the example: Identity, content and version have separate contracts.

  5. Data and states

    Which two state changes must be visible together in your draft?

    In the example: A stock movement has appropriate domain evidence and takes effect once.

  6. Overall architecture

    Which boundary solves a specific operational problem in your system?

    In the example: Runtime structure and domain structure are separately visible.

  7. Critical flow

    What external effect could have occurred in your system despite Timeout?

    In the example: A lost response changes what is known, not the external effect retroactively.

  8. Bottlenecks and trade-offs

    Which two similar symptoms have different causes in your project?

    In the example: Actions follow concrete measurements.

  9. Operations and security

    What open states do you need in your system a work list with owner?

    In the example: Every signal has a response, responsible role and completion criterion.

  10. Final design

    Take these three types of evidence into your own design: atomic local decision, confirmed external effect, proven physical action.

    In the example: The design includes a testable main path, clear failure outcomes and specific unresolved integration questions.