System Design Atlas

Grocery orders with store inventory and substitutions

02 / 10Worked example

Requirements

What rules ensure the handover, and what number describes only the operation?

From the boundary of the first step, two types of requirements arise. Business requirements describe permitted actions and rules. Quality objectives describe measurable characteristics of the operation. An invariant is a rule that must apply after each completed operation. For B-17, it connects the allowed replacement pack with the actual amount charged. For the stock rule, P denotes the shelf forecast in packs and Z the as yet unpicked online allocations; max(0,P−Z) gives the newly offerable quantity.

Starting point Replacement is picked, the payment response is missing.

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.

The handover has three requirements

Conditional network · Release and pick are checked together

ApprovalA-11 · 1 packet · ≤ 220 cents
AND
PickA-11 · 1 packet · 220 cents
  1. 1
    Basket frozenFinal amount: 220 cents
  2. 2
    Acknowledgement of payment220 cents confirmed
  3. 3
    Handover of B-17 permittedOne time for the same order
Unknown payment → investigationThe path ends before the output; from 120 seconds, the work list begins.

Approval and actual pick must match. The frozen basket and confirmed charge then protect the single handover.

Release and pick must match for item, quantity and positive integer cent price. A matching payment confirmation in EUR allows the handover; an unknown result leads to the clarification.

Business rules (functional)

Further reading
Store and order line closure
Every order belongs to exactly one store. Each line ends as picked or omitted; a completely empty basket enters cancellation review without a payment instruction.
Substitution approval
A replacement meets the expressly permitted item, the quantity and a strictly positive integer cent price up to and including 220 cents. A price of zero, 221 cents or an unauthorized item will be rejected.
Stock and handover
New allocations are tested atomically against P−Z. The handover is one-time and requires a confirmed payment success for the same order.

Operational goals (non-functional)

Further reading
Local pick commands
95 % of completed local pick commands are to be in 15-minute test profile from step 3 within: 800 milliseconds. The external response time of the payment service is not included.
Open charges
A charge whose outcome has been unknown for at least 120 seconds appears in the work queue. The threshold triggers investigation; it does not create payment success.

Case decision and verification approach

Open payment status

A visible open payment status with a clearing threshold.

The payment service may respond delayed after the provision of goods.

Handover requires a confirmed charge. Exactly at the threshold, a work item is created while handover remains blocked.

Alternative considered
An handover after mere acceptance of the order shifts the risk of default to the merchant.
Trade-off
Customers can wait for pick-up.
Reassess
Measured waiting times require a separately agreed quality process.

Terms in this step

Invariant
A business rule that must apply after each completed operation.
Quality objective
A measurable design assumption for operation, here local response time and age of open payments.

Try it yourself

State two domain requirements for handover and explain the effect of the 120-second threshold.

A hint for your attempt

An alarm does not produce proof of payment.

Compare with a possible solution
Release of goods
Items, quantity and positive whole cent price must correspond to the release; the basket is frozen.
Proof of payment
An authenticated confirmation must confirm B-17, the same payment instruction, the frozen amount and the EUR together; the open order is not sufficient.
Clarification threshold
From 120 seconds, the clarification by the customer service begins; payment and stock remain unchanged.

Apply to your project

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

Step 3 determines the load profile of these local tests.