System Design Atlas

Hotel inventory and room pricing

10 / 10Worked example

Final design

Which tests verify reservation concurrency control and completion in the overall architecture?

The conclusion takes over the entire topology from step 6. Within the system boundary: Interface → Reservation API → Room-category inventory per night, offers and reservations; channel reconciliation reads durably stored work from this data store. Outside: distribution channel. The processing receives or transmits the domain messages described in the main path; the result is sent to the interface via the reservation API. The verification plan complements reservation R-27 with contention, repetition, boundary conditions and terminal completion. All results in the table are expected outcomes; these tests have not yet been run.

Starting point The reservation team owns unresolved channel responses.

Assumptions for the example case

Own fictitious example design. One hotel, one room category, full nights and a fixed offer in EUR without prepayment. A price offer is valid for 300 seconds; at exactly 300 seconds, a new confirmation is rejected. All figures and test goals are illustrative assumptions.

Overall architecture with checks and review loops

Runtime topology · processes, data stores and external systems

  1. 1 · Offer read model → Reservation API
  2. 2 · Reservation API → Category-night inventory
  3. 3 · Category-night inventory → Channel reconciliation
  4. 4 · Channel reconciliation → Distribution channel
Offer read modelEntrance or reading path

Hotel reservations

Reservation APIDomain validation and commit
Category-night inventoryAuthoritative relational data store
Channel reconciliationProcess durably stored work
Distribution channelUse of results
Offer read model → Reservation APIRequest or message
Reservation API → Category-night inventorychange in atomic state
Category-night inventory → Channel reconciliationCommitted task
Channel reconciliation → Distribution channelSubstantiated result
Concurrency and replay4 · 5 · 7
Exact limitOffer valid before 300 s · expired at 300 s · 2
CompletionRole evidence · 9

The booking is committed directly against the authoritative category-night inventory; external channels sell only through this confirmation path.

Guests search through a rebuildable offer read model. The reservation API makes the commitment directly on the relational category-night inventory and stores reservation plus channel order atomically. The channel reconciliation processes distribution channel requests and confirmations separately. Reception uses the same authoritative reservation state for arrival and completion. External channels may only sell via the confirming API path in the example; an independent sale of the same capacity would be an additional open quota contract. The same building blocks and arrows as in step 6. Test marker: API/Commit → Contention and Replay (4/5/7); Boundary Check → Exact Boundary (2); Specialist Role/Close → Terminal Evidence (9).

Test plan for the complete design

ComponentTest and expected resultReturn to an earlier step
Reservation APITwo confirmations claim the last night. In either order of competing requests, exactly one reservation receives every night; the other receives a conflict and no partial allocation.Steps 3 and 5
Command journalIdentical retries take effect once; changed content produces a conflict.Steps 4 and 7
Domain boundary checkCheck values 299, 300 and 301 seconds. Oracle: A price offer is valid for 300 seconds; at exactly 300 seconds, a new confirmation is rejected.Step 2
Room-category inventory per night, offers and reservationsDouble cancellation releases the quota once. A completed reservation can neither be confirmed again nor released again.Steps 5 and 9
Channel reconciliationReservation API locks category nights in date order, checks the remaining inventory for both nights and commits the reservation together with the channel request. After a lost response, the same key will deliver the same reservation. External channel success is reconciled separately.Steps 6 and 7

Reservation API

Test and expected result
Two confirmations claim the last night. In either order of competing requests, exactly one reservation receives every night; the other receives a conflict and no partial allocation.
Return to an earlier step
Steps 3 and 5

Command journal

Test and expected result
Identical retries take effect once; changed content produces a conflict.
Return to an earlier step
Steps 4 and 7

Domain boundary check

Test and expected result
Check values 299, 300 and 301 seconds. Oracle: A price offer is valid for 300 seconds; at exactly 300 seconds, a new confirmation is rejected.
Return to an earlier step
Step 2

Room-category inventory per night, offers and reservations

Test and expected result
Double cancellation releases the quota once. A completed reservation can neither be confirmed again nor released again.
Return to an earlier step
Steps 5 and 9

Channel reconciliation

Test and expected result
Reservation API locks category nights in date order, checks the remaining inventory for both nights and commits the reservation together with the channel request. After a lost response, the same key will deliver the same reservation. External channel success is reconciled separately.
Return to an earlier step
Steps 6 and 7

First end-to-end test and outstanding evidence

End-to-end path
Two nights with a scarce night form the end-to-end path. Reservation API locks category nights in date order, checks the remaining inventory for both nights and commits the reservation together with the channel request. After a lost response, the same key delivers the same reservation. External channel success is reconciled separately.
Clarify before extending the scope
Agree on the real contract with distribution channel, retention, recovery targets and role assignments. All the limit values here are design assumptions. The proof table describes tests to be carried out; technical integration, browser testing and comprehension testing with readers follow separately.

Test a two-night stay with one scarce night end to end

Test a two-night stay with one scarce night end to end

Test a two-night stay with one scarce night end to end.

Two guests want to book the last available room night within a two-night stay. Completion requires technical and domain evidence.

Two confirmations claim the last night. In either order of competing requests, exactly one reservation receives every night; the other receives a conflict and no partial allocation. The exercise specifies the input and expected result.

Alternative considered
An initial end-to-end path limited to lists and forms postpones the critical state checks.
Trade-off
The first end-to-end path needs controlled concurrency and failure points.
Reassess
Passing the counterexample tests and checks with readers provides grounds for extending the case.

Try it yourself

Choose two architectural decisions: concurrency protection and evidence-backed completion. For each, name the test, expected result and step to revisit.

A hint for your attempt

Link the markers of the overall architecture with the associated design steps.

Compare with a possible solution
Concurrency control
Two confirmations claim the last night. In either order of competing requests, exactly one reservation receives every night; the other receives a conflict and no partial allocation. The invariant is expected: Each confirmed reservation atomically occupies all required nights; occupancy never exceeds the local inventory for its room category. Deviation leads back to step 5 and to the command contract in step 4.
Test completion and retries
Initial state: A confirmed reservation occupies one room each for two consecutive nights. Cancel it, repeat the same cancellation order and try a new confirmation of the same reservation. Oracle: Both night allotments are released exactly once, Replay delivers the same cancellation document, the new confirmation receives conflict. The reservation remains cancelled; no night receives duplicate available capacity. Deviations lead back to step 9 for responsibility and step 7 for the error sequence.

Apply to your project

Which two counterexample tests will you run first in your own end-to-end implementation?

Transfer the architecture and counterexamples to the editable Markdown design template.

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

    What proof of reservation would arise in your own project outside of the application?

    In the example: Nights and price form a time-limited offer. One hotel, one room category, full nights and a fixed offer in EUR without prepayment.

  2. Requirements

    Which rule of your project remains binding even with slow processing?

    In the example: Commit all nights of a stay together. A price offer is valid for 300 seconds; at exactly 300 seconds, a new confirmation is rejected.

  3. Scale estimates

    Which individual entity in your project concentrates load more strongly than the daily average in this room-night reservation example?

    In the example: The last available night determines the concurrency test. An average of 0.0833333 events/s says little about 50 requests for the last available night.

  4. Interfaces

    Which input fields make two change intentions different in your project?

    In the example: Confirmation binds the price offer version. The category, arrival, departure, price offer version and total price in cents must remain identical on replay.

  5. Data and states

    Which states must remain protected in your model against late replay?

    In the example: Cancellation releases the same nights exactly once. Duplicate cancellation releases inventory once. A completed reservation can be neither confirmed again nor released again.

  6. Overall architecture

    Which planned service boundary would distribute a currently local guarantee across the network?

    In the example: Room-night inventory remains with the reservation core. Room-category inventory per night, offers and reservations must express the same valid state.

  7. Critical flow

    What feedback could be missing even though the underlying action has already taken place?

    In the example: Channel reconciliation follows the local commit. Every confirmed reservation occupies all required nights atomically; occupied nights never exceed the local inventory for their category.

  8. Bottlenecks and trade-offs

    Which similar display could have two different causes in your project?

    In the example: Search results may be older than the data used to decide a booking. Many searches load the read view; conflicts over the same night arise on the write path. A search cache always carries the offer time and cannot replace confirmation.

  9. Operations and security

    Which open state in your project needs a domain specialist as well as technical operations?

    In the example: The reservation team owns unresolved channel responses. Duplicate cancellation releases inventory once. A completed reservation can be neither confirmed again nor released again.

  10. Final design

    Which two counterexample tests will you run first in your own end-to-end implementation?

    In the example: Test a two-night stay with one scarce night end to end. Two confirmations claim the last night. In either winning order, exactly one reservation receives every night; the other receives a conflict and no partial booking.