System Design Atlas

Service marketplace

05 / 10Worked example

Data and states

Why is an accepted flag on an offer insufficient?

Relationships make uniqueness and history testable.

Starting point Check order uniqueness and the losing offers.

Assumptions for the example case

Illustrative design: 10,000 searches and 1,000 new requests per day, averaging five offers per request; a peak of 25 searches/s; and 20 concurrent award attempts against the same request. Payment, service delivery and warranty are outside the scope.

Data and state model

Request A-17 · Keep identities and states separate

Request A-17Maintains offers until a single award
Technically linked
Offers O-17/O-18own identity and comprehensible state
Technically linked
Order L-17own identity and comprehensible state
Technically linked
Command K-17own identity and comprehensible state

A-17: published → awarded; O-17: submitted → accepted; O-18: submitted → rejected. Withdrawn remains possible before the award.

A-17 has offers and at most one order.

States

ObjectTransitionsProtection
A-17published → awarded | cancelled | closedAward only from published
O-17submitted | accepted | rejected | withdrawnOnly the offer’s provider may withdraw it.
L-17pending_confirmationUnique per A-17

A-17

Transitions
published → awarded | cancelled | closed
Protection
Award only from published

O-17

Transitions
submitted | accepted | rejected | withdrawn
Protection
Only the offer’s provider may withdraw it.

L-17

Transitions
pending_confirmation
Protection
Unique per A-17

Terms in this step

Optimistic version
Commit succeeds only against the version that was read.

Try it yourself

Name the four changes made by an award commit.

A hint for your attempt

The request, two offers and order.

Compare with a possible solution
Request and winning offer
A-17 awarded and O-17 accepted.
Losing offer and order
O-18 rejected and L-17 created.

Apply to your project

Apply the boundary to another award decision.

The runtime architecture assigns the commit to a process.