Skip to content

    Frontend System Design

    Front-End Case Study: Travel Booking Flow

    Design a travel booking front end: price and availability freshness, a hold that expires, a safe retry after a lost reply, with a runnable pure-core lab.

    By Published 22 min read

    • frontend-system-design
    • case-study
    • booking
    • checkout
    Share

    Case studyadvancedReact labFrontend System Design

    Before this: How to Read and Reproduce a Front-End Case Study, Form State and Validation, State Machines With XState

    What you'll learn: By the end of this case study you will be able to design the client side of a multi-step booking flow: model the steps as a small state machine, treat the price as a versioned quote that the server can change, reserve a fare with a hold that expires and show its deadline honestly, block a submit that would be rejected, and make the final submit safe to press twice or to repeat after a reply that never came.

    Think of a cinema box office that lets you hold two seats while you look for your card. The clerk writes your name next to the seats and starts a stopwatch. While you search, the price on the poster may change, someone may ask the clerk about the same seats, and the stopwatch keeps running. When you hand over the card, the clerk checks the stopwatch, the price and the seats again, and if the till jams after you paid, you do not want to pay a second time to find out. A booking flow is that counter: a price that can change, a seat that is only yours for a while, and a payment that must happen once.

    This is an educational reference design, not the verified internal architecture of any airline, hotel, agency or booking platform. The title names the shape of the product (a flow that reserves something scarce and then takes payment); nothing here is claimed about how any company builds it. Every price, time limit and seat count is illustrative, and the lab at the end is a model with no network and no payment provider.

    The method (requirements, estimates, layers, deep dives, failure modes, a decision record) follows Front-End Case Study Method. The lesson builds on Form State and Validation and State Machines with XState, and it is the travel counterpart of the shop in E-Commerce Storefront.

    The core idea

    1. Three things can go stale, and each has its own truth. The price and availability belong to a versioned quote. The time you may take belongs to a hold with a deadline. The identity of "this booking attempt" belongs to a key. The client displays all three; the server owns all three.
    2. The user agrees to a number, and the server is told that number. The client remembers the price the traveller accepted. If a newer quote differs, submit is blocked until the traveller accepts the new price, and the server rejects a submit whose agreed price is no longer true.
    3. The last click is the one that must not run twice. A key travels with the booking request. A second click, a retry after a timeout and a reload all refer to the same attempt, as long as the request has not changed.

    Three illustrations run through the lesson: a minimal example (one fare selected, held and booked), a realistic example (a traveller who is interrupted for a few minutes while the price changes) and a failure example (the reply to the booking request never arrives).

    Requirements and scope

    Functional. A list of offers with a price each. Choosing one starts a flow: traveller details, a review of everything including the price, then a single "Book now". After it, a confirmation with a reference. A visible hold countdown while the fare is reserved. A way to start again when the hold ends or the fare is gone.

    Non-functional. The price the traveller sees at "Book now" is the price charged, or the traveller has explicitly accepted a different one. A booking is created at most once per traveller action. Nothing the traveller typed is lost because a hold ended. The flow works with the keyboard and a screen reader, and its time limit is communicated, not sprung.

    Out of scope here. Card entry (normally a field hosted by the payment provider, which keeps card data out of your page), seat maps, add-ons, several travellers, loyalty and currency conversion. On the server: inventory, the hold itself and the payment ledger (see Ticket Booking and Overselling, Payment System and Idempotency Keys and Safe Retries). The client's job is to be honest about what it knows and to ask the server for what it does not.

    Illustrative sizing

    The numbers below are assumptions for reasoning, not measurements or any provider's limits.

    Quantity Assumed value Why it matters
    Offers on a results page 40 Prices and seats on this list age while the user reads
    A quote counts as stale after 60 seconds Selecting a stale offer should re-check it
    Hold length 10 minutes Longer than a form takes, shorter than a coffee break
    Warning before the hold ends 2 minutes Time to finish or ask for more
    Wait for a booking reply 15 seconds Beyond this the outcome is unknown, not "failed"
    Steps 4 (choose, details, review, done) Each step is a place the user can stop for minutes

    The point of the table is the ratios. A flow that takes under two minutes to fill in faces a 10-minute hold with room to spare, so expiry is mostly an interruption problem: the phone rings, the tab is left open. And a 15-second wait that ends without an answer is the rare case with the worst consequence, so it gets its own state.

    The architecture: a state machine between the page and the server

    Figure 1. The layers of a booking client

    A booking client: a pure flow core between the page and four server callsBooking UI to Flow core (events); Flow core to Booking UI (state); Flow core to Hold API (place-hold); Flow core to Booking API (submit, lookup); Offers API to Flow core (requote); Clock to Flow core (tick)Booking UI: thin ReactBooking UIthin ReactFlow core: pure reducerFlow corepure reducerOffers API: quotes, versionsOffers APIquotes, versionsHold API: deadlineHold APIdeadlineBooking API: key, lookupBooking APIkey, lookupClock: ticks from outsideClockticks fromoutsideeventsstateplace-holdsubmit, lookuprequotetick

    How to read this: the middle box holds every rule. The page sends events and draws state. Anything that touches the world leaves the core as an effect (place-hold, submit, lookup), and the clock is an input too: time enters as a number inside an event, never read from inside the core.

    The clock as an input is what makes expiry testable. A reducer that calls Date.now() needs a fake timer in every test; a reducer that is handed now can be driven through ten minutes of hold in a test that takes a millisecond.

    The flow as a state machine

    The steps are a small machine, and the machine is worth drawing because the interesting arrows are the ones that go sideways.

    Figure 2. The states of a booking flow

    stateDiagram-v2 accTitle: States of a booking flow accDescr: The flow starts at select. Choosing an offer moves to details and requests a hold. Details move to review when the hold exists and the traveller is valid. Book now moves review to submitting. A confirmation moves submitting to confirmed. A missing reply moves submitting to unknown, and a status lookup moves unknown to confirmed or back to review. The hold deadline moves details or review to expired, and a refused hold or a rejection moves to sold out. Expired and sold out return to select. [*] --> Select Select --> Details: choose offer, request hold Details --> Review: hold exists, details valid Review --> Details: edit details Review --> Submitting: book now Submitting --> Confirmed: confirmed Submitting --> Unknown: no reply Unknown --> Confirmed: lookup found it Unknown --> Review: lookup found nothing Details --> Expired: deadline passed Review --> Expired: deadline passed Details --> SoldOut: hold refused Expired --> Select: start again SoldOut --> Select: start again Confirmed --> [*]

    How to read this: the clock only acts on Details and Review. Submitting and Unknown have no arrow to Expired, on purpose: once a request is on its way, the server decides what happened to it, and the client must not announce a failure it does not know about.

    A hand-written reducer is enough for eight states, and it is what the lab uses; a statechart library earns its place when states nest or run in parallel, which State Machines with XState covers.

    Price and availability: a quote with a version

    An offer on a results page is a snapshot. The lab models a quote with an offer id, a price in integer cents, a version, a seats-left count and the time it was quoted. Three rules follow from calling it a quote.

    It ages. Browsing a list can use data that is a minute old; choosing an offer should re-check it. A simple classifier, fresh or stale by age, drives the wording ("price checked a moment ago") and the decision to re-quote on selection. At payment the age does not matter at all, because the server will check anyway.

    It has a version, and older news is ignored. Quotes can arrive out of order: a push, a refresh and a response to the hold request. The core keeps the highest version it has seen and returns the same state for an older or repeated one. That is the same forward-only rule as a receipt watermark in the chat case, applied to a price.

    The traveller agrees to a number. On selection the client stores the agreed price. When a newer quote differs, the core sets a price change and blocks submit; the page shows an alert ("The price changed from $249.00 to $269.00") with a button to accept, and accepting stores the new agreed price. When the traveller does press Book now, the request carries the agreed price and the quote version, so the server can refuse it if it no longer matches. HTTP has a status for that: 409 (Conflict) is defined as the request not being completed because of a conflict with the current state of the target resource, in situations where the user might be able to resolve the conflict and resubmit (RFC 9110, section 15.5.10). A changed price is exactly that.

    Availability is the same idea with one exception. Before a hold exists, a quote with no seats left means the fare is gone. After a hold exists the seat is ours, so a later "0 seats left" is not news about us. The lab encodes that difference, and the demo shows the price case end to end.

    Expected output, captured from a real run (Node 26.13.1; section 2):

    === 2. The price changes after the traveller agreed
      traveller chooses F1 and reaches review
          effect: place-hold F1 (quote v1)
          step details, no hold, can submit: false
      hold placed
          step details, hold 9:59 (ok), can submit: false
      details and review
          step details, hold 9:58 (ok), can submit: false
      continue
          step review, hold 9:57 (ok), can submit: true
      a newer quote arrives with a higher price (version 2)
          step review, hold 8:30 (ok), price change $249.00 -> $269.00, can submit: false
      an OLDER quote (version 1) arrives late
          (no change) step review, hold 8:29 (ok), price change $249.00 -> $269.00, can submit: false
      a press on Book now is refused
          (no change) step review, hold 8:28 (ok), price change $249.00 -> $269.00, can submit: false
      traveller accepts the new price
          step review, hold 8:25 (ok), can submit: true

    Three things to read in it. The older quote (version 1, a lower price) changes nothing. The press on Book now is refused with no effect while a change is pending. After the traveller accepts, can submit is true again.

    Holds and the clock

    A hold is a reservation the server makes for a limited time. The client does not enforce it; it displays it. The server's deadline is the truth, and every client-side expiry is a courtesy plus a way to avoid sending a request that will be refused.

    Where the deadline comes from. The reference design takes the deadline from the server's hold response and never hard-codes a length. A browser's wall clock may be wrong or may change: MDN notes that Date.now() may have been impacted by system and user clock adjustments and clock skew, and that performance.now() is relative to a timeOrigin that is a monotonic clock. So the safe conversion is: the server sends how long is left, and the client adds it to a monotonic reading taken when the response arrived. The lab keeps this outside the core: the core compares now with expiresAt, and whoever feeds it decides which clock that is.

    Do not count down by subtracting. MDN says browsers enforce a minimum timeout delay in inactive tabs and that a timeout can fire later than set when the page is busy; MDN adds that Chrome checks timers in a throttled tab once per second, or once per minute under intensive throttling. A countdown that decrements a number on every setInterval tick therefore drifts in a background tab. Compute the remaining time from the deadline on every tick and on every visibilitychange, and a late tick is only a late repaint.

    Say it, and let the user act on it. WCAG 2.2 success criterion 2.2.1 (Timing Adjustable) asks that, for a time limit, the user can turn it off, adjust it or extend it: the user is warned before time expires and given at least 20 seconds to extend with a simple action, unless the time limit is essential and extending it would invalidate the activity. The Understanding document's examples include a ticket purchase that gives two minutes to confirm before the seats return to the general pool, and a variant that warns the user and allows an extension. Whether a hold may be extended is the server's rule and a product decision; the client's part is to show the countdown, warn at the threshold and offer the extension the server permits. The lab shows the countdown and the warning and leaves the extension as an exercise.

    Announcing time is easy to get wrong. MDN's timer role has an implicit aria-live of off, so a counting timer is not read out on every change; its own example switches the role to alert near the end so that it is announced once. The lab does the equivalent with a role="timer" for the number and a separate role="status" message when the hold enters its last two minutes.

    When it ends. The core moves Details and Review to Expired, clears the hold, and keeps the traveller's details so that "Start again" does not mean retyping. The demo's section 3 prints it: at four minutes left the state is unchanged, at 1:40 it is soon, and at the deadline the step is expired.

    Submitting once

    The final click is the one with consequences, and it has four ways to go wrong. The reducer guards all four before it emits anything.

    Figure 3. What the core does when Book now is pressed

    flowchart TD accTitle: Decision when Book now is pressed accDescr: If the step is not review, do nothing, which also covers a second click while submitting. If the hold deadline has passed, move to expired and send nothing. If a price change is pending or the traveller details are invalid, do nothing. Otherwise move to submitting, reuse the key of an earlier identical attempt or take the new one, and emit one submit effect. A[Book now pressed] --> B{Step is review?} B -->|no, includes submitting| C[No change, no effect] B -->|yes| D{Hold deadline passed?} D -->|yes| E[Expired, no effect] D -->|no| F{Price change pending or details invalid?} F -->|yes| C F -->|no| G[Submitting, reuse earlier key or take the new one] G --> H[Emit one submit effect]

    How to read this: the page also disables the button while submitting, but the button is a hint and the reducer is the guarantee. A second submit event while the first is in flight returns the same state object and no effect, which is what the lab's test and the React test both check.

    The key

    The request carries a key the client generated, such as a random UUID, so a server that sees it twice can tell "same attempt" from "a new attempt". The IETF's Idempotency-Key header is an Internet-Draft (revision 09 when read, intended for the Standards Track, so not yet a standard); it says the value is a string, that a key MUST be unique and MUST NOT be reused with a different request payload, that a repeat after completion SHOULD get a response consistent with the request having completed, that a reused key with a different payload SHOULD get 422 and that a retry while the original is still processing SHOULD get 409. The back-end lesson on Idempotency Keys and Safe Retries covers the server side. The lab's protocol is its own; it follows the same idea.

    Two client rules come from that contract.

    • One key per exact request. The lab keeps the key while the request is unchanged, and drops it when anything the request contains changes: the traveller's details or the agreed price. Reusing a key for a different payload is the mistake the draft forbids, and the demo's section 6 shows the key k1 replaced by a fresh k3 after a name was corrected.
    • Generate the key at the first press, not at page load and not at every press. The reducer takes state.submitKey ?? event.key: a retry after a lost reply carries the original key even though the page offered a new one.

    The reply that never came

    HTTP's own guidance explains why the client cannot just send the request again: RFC 9110, section 9.2.2, says a client should not automatically retry a request with a non-idempotent method unless it has some means to know the request is actually idempotent or can detect that the original was never applied. A key is that means, but only if the server honours it.

    A timeout is also not a failure. AbortSignal.timeout() aborts with a TimeoutError after the time you set; it tells you that you stopped waiting, not what the server did. So the core has a state for it, unknown, and a different set of buttons. There is no "Book now" in it, because pressing it again is how a traveller pays twice. There is "Check booking status", which sends the key to a lookup endpoint. If the server found a booking, the flow is confirmed and nothing was sent again. If it found nothing, the flow returns to review with the same key, so the next press is a safe repeat.

    Figure 4. A lost reply, a lookup and a safe retry

    sequenceDiagram accTitle: Lost reply, lookup by key and retry with the same key accDescr: The client sends the booking request with key k1 and waits. No reply arrives before the time limit, so the client moves to unknown and shows a status check instead of a book button. The traveller checks. The client asks the booking API to look up key k1 and nothing is found. The client returns to review keeping k1. When the traveller presses Book now again, the request is sent with k1, and the server confirms it. participant U as Traveller participant C as Flow core participant S as Booking API U->>C: Book now C->>S: submit(key k1, agreed price, hold, details) Note over C,S: no reply within the time limit C->>C: step unknown, key k1 kept U->>C: Check booking status C->>S: lookup(key k1) S-->>C: nothing found C->>C: back to review, key k1 kept U->>C: Book now C->>S: submit(key k1, same request) S-->>C: confirmed(ref R-1002)

    How to read this: the page offered a new key on the second press, and the core ignored it. The repeat is safe because the key says "this is the attempt you may already have seen".

    A last edge case: while the outcome is unknown the hold may end. The core does not turn an in-flight or unknown request into Expired on a tick; a lookup that found nothing returns to review, and the next tick then expires the flow if the deadline has passed. Section 5 of the demo prints that order.

    The form and the review step

    The details step is an ordinary form, so everything in Form State and Validation applies. Two additions matter here. Give the fields the right autocomplete tokens: MDN lists name, given-name, family-name and email, and says valid tokens also satisfy WCAG 2.2 success criterion 1.3.5, Identify Input Purpose, which saves a traveller from typing what the browser already knows. And keep the review step, because it is the "confirmed" option of WCAG 3.3.4 (Error Prevention for legal, financial and data submissions): at least one of reversible, checked or confirmed must hold, and "confirmed" means a mechanism for reviewing, confirming and correcting information before finalising. The review page shows the traveller and the agreed price, offers Edit details, and is the only place Book now exists.

    Do not persist payment data. If the flow survives a reload (session storage, or the URL for the chosen offer), restore the offer id, the hold id and the traveller's non-sensitive details, turn any submitting state back into unknown, and ask the server for the hold's remaining time instead of trusting a stored deadline.

    Build it: the flow core and a thin React layer

    Goal. Drive the flow through a price change, a hold that runs out, a double click and a lost reply, and read the effects it emits.

    Setup. The lab travel-booking-flow is in the course's example workspace (Node 26). It is new, so it does not duplicate the others: storefront-cart-checkout covers a cart, money as integer cents and one idempotent place-order, and form-state-and-validation covers the form. This one adds a quote with a version, a hold with a deadline, and the unknown-outcome path with a lookup. The logic is one pure function, step(state, event); a small store and the React component BookingApp read it with useSyncExternalStore, and the clock is a prop. No network, payment provider or real browser is involved.

    cd examples/frontend
    pnpm install
    cd labs/travel-booking-flow
    pnpm test           # 32 tests: 26 for the core, 6 React (jsdom)
    node src/demo.ts

    Steps.

    1. Run the tests, then the demo. In section 2 the agreed price is $249.00, a newer quote says $269.00, and can submit is false until acceptPrice.

    Expected output, captured from a real run (Node 26.13.1; section 4):

    === 4. The reply is lost: check by key, then retry with the same key
      traveller chooses fare F1
          effect: place-hold F1 (quote v1)
          step details, no hold, can submit: false
      hold placed
          step details, hold 9:59 (ok), can submit: false
      details
          step details, hold 9:58 (ok), can submit: false
      continue
          step review, hold 9:57 (ok), can submit: true
      traveller presses Book now
          effect: submit key=k1 offer=F1 v1 price=$249.00 hold=h1
          step submitting, hold 9:00 (ok), key k1, can submit: false
      no reply within the time limit
          step unknown, hold 8:50 (ok), key k1, can submit: false
          notice: We do not know whether the booking went through.
      traveller presses Check booking status
          effect: lookup key=k1
          (no change) step unknown, hold 8:49 (ok), key k1, can submit: false
      the server has nothing under that key
          step review, hold 8:48 (ok), key k1, can submit: true
          notice: No booking was made. You can try again.
      traveller presses Book now again (the page offers a new key k2)
          effect: submit key=k1 offer=F1 v1 price=$249.00 hold=h1
          step submitting, hold 8:47 (ok), key k1, can submit: false
      the server confirms
          step confirmed, hold 8:46 (ok), key k1, can submit: false
    1. In section 4 the first press emits submit key=k1. After the missing reply the step is unknown and the key is kept. The lookup finds nothing, and the second press emits submit key=k1 again, not k2.
    2. In section 3 the hold shows ok at four minutes, soon at 1:40 and expired at the deadline. In section 5 a tick far past the deadline changes nothing while the request is unknown; only after the lookup does the next tick expire the flow.
    3. In section 6, after the traveller edits the name the key disappears from the status line, and the next press sends k3.

    What the lab does not show. No network, server, payment, real clock or browser: time is a number in each event, and jsdom (used by the React tests) does no layout, so the countdown's look, focus movement and screen-reader output were not observed. The quote versions, the hold deadline and the lookup are this lab's own protocol, not any provider's. Seats, several travellers and extensions are not modelled.

    Break it. In src/flow.ts, in the submit case, replace const key = state.submitKey ?? event.key; with const key = event.key;. A retry after a lost reply then sends a new key; the test "not found: back to review, and the retry reuses the SAME key" fails and demo section 4 shows key=k2 on the retry. Restore the line and run the tests again.

    Trade-offs

    Decision Option A Option B Reference choice
    Price truth Whatever the list showed A versioned quote the server can change Versioned quote; the agreed price is sent and checked
    A newer price Overwrite silently Block and ask Block until accepted; announce as an alert
    Hold deadline Hard-coded length on the client The server's deadline The server's deadline, compared with a monotonic clock
    Countdown Subtract on every interval Compute from the deadline Compute; a late tick is only a late repaint
    In-flight request at the deadline Cancel and show expired Leave it to the server Leave it; the server decides
    Double click Disable the button Guard in the reducer too Both; the reducer is the guarantee
    After no reply Show an error and let them retry Unknown state with a lookup Unknown state; no Book now until checked
    Key lifetime New key each press One key per exact request One key per exact request, dropped when it changes
    Review step Book from the details page A review before submit Review; it is the confirmation WCAG 3.3.4 asks for

    In practice: a booking flow that charged some travellers twice

    NOTE

    This is a realistic scenario, not a case history. It is a composite built from common production patterns. It describes no specific company or product, and every number in it is an illustrative assumption.

    The situation

    A small travel site gets three kinds of complaint in one week: "the price at payment was higher than the one I clicked", "I filled in everything and then it said the fare was gone", and "I was charged twice after the page froze". Support also notes that some people reported a countdown that said they had minutes left when the booking was refused.

    Starting architecture

    Figure 5. Starting point: cached price, a guessed countdown, a bare POST

    Starting architecture: the price comes from the list, the countdown is a client counter, and the booking request has no keyResults list to Booking page (old price); Booking page to Booking POST (click, click)Results list: price cachedResults listprice cachedBooking page: counts down 10 minBooking pagecounts down 10minBooking POST: no keyBooking POSTno keyold priceclick, click

    How to read this: nothing in the path checks the price again, takes the deadline from the server or tells a repeat from a new request, so each complaint has a direct cause.

    Options considered

    Option What it fixes What it costs Risk
    Disable the button after the first click Most double clicks One line A reload or a timeout still produces a second request
    Re-fetch the price on the payment page Some price drift A request Race: the price can change after the fetch; the user still did not agree
    Versioned quote, server deadline, key and an unknown state in a pure core All three complaints A small core with tests, and a server contract The server must honour keys, versions and holds

    The decision

    Field Decision record
    Context Price drift, fares lost mid-form, and double charges after a timeout.
    Decision Send the agreed price and quote version with a booking key; show the server's hold deadline; block submit on a price change until accepted; on no reply, enter an unknown state with a lookup by key and no Book button.
    Consequences, good A price is charged only if agreed; a retry cannot create a second booking; the countdown matches what the server enforces.
    Consequences, bad The server contract grows (versions, deadlines, lookup by key); a traveller sees one more state.
    Revisit when Several travellers or seat selection require a hold per item, or the server can extend holds.

    Rollout and verification

    1. Replay recorded sessions through the reducer in a test: a price change before submit, a hold that ends in review, a double click and a lost reply.
    2. Ship the server side first: key handling and lookup by key, then the version check, so old clients keep working.
    3. Watch three counters: submits rejected as price-changed (some are normal, a spike means quotes are too old), submits rejected as hold-expired (a spike means the client countdown disagrees with the server) and lookups that found a booking (each is a double charge avoided).

    The 2 a.m. failure

    The server team shortens the hold from 10 minutes to 5 (illustrative). A client build that still counts 10 minutes from its own timer shows "9 minutes left" to travellers whose fares are already gone, and their booking is refused with hold-expired. The rate of that rejection jumps right after the deploy.

    First three checks: (1) does the rejection rate rise only for the older client version; (2) does the hold response carry a deadline, and does the client use it or its own constant; (3) did any server setting about hold length change in the same release. Mitigation: make the client read the deadline from the hold response, which the reference design already does. Follow-up: add a contract test that the client never derives the deadline from a constant, and log both deadlines on a refusal.

    The other side of this topic

    On the back end the same moment is about inventory and money: how a hold is stored and expires, how a seat is never sold twice, how a payment is recorded once, and what a lookup by key returns while the first request is still running. See Ticket Booking and Overselling, E-Commerce Order System and Idempotency Keys and Safe Retries. The client's states are only as honest as the server's promises about versions, deadlines and keys.

    Architect's notes

    • Name the three truths. Quote version, hold deadline and request key: write down who issues each, what it looks like on the wire and what the client does when it changes.
    • Write the server contract before the screens. The agreed price and version in the booking request, the deadline in the hold response, a lookup by key and the status for a changed price are what the flow depends on.
    • Model the unknown. A timeout is a state with its own buttons, not an error message.
    • Keep time as an input. A reducer that is handed now is testable; one that reads the clock is not.
    • Keep what the traveller typed when a hold ends, and never keep payment data.
    • Test orders, not screens: a newer quote before the hold response, a tick during submitting, a second click, a lost reply followed by a lookup.

    Common mistakes

    • Trusting the price of the list at payment, or overwriting it without asking.
    • Hard-coding the hold length on the client.
    • Counting down by subtracting on every interval tick, which drifts in a background tab.
    • Disabling the button and calling it idempotent. A reload, a timeout or a second tab still sends a second request.
    • Treating a timeout as a failure and offering Book now again.
    • Reusing a key for a changed request, or making a new key for every press.
    • Cancelling an in-flight request when the client timer ends.
    • Throwing the traveller's details away when a hold ends.
    • Announcing every tick of a countdown to a screen reader.

    Key takeaways

    • A price is a versioned quote: ignore older versions, block submit on a change and send the agreed price with the booking.
    • A hold is the server's deadline; the client displays it, computes the remaining time from it and never decrements a counter.
    • Warn before a time limit ends and offer the extension the server permits.
    • A key belongs to one exact request: keep it across retries, drop it when the request changes.
    • After no reply the outcome is unknown: check by key before offering a repeat.
    • The reducer is the guarantee against a double click; the disabled button is only a hint.
    • Keep rules in a pure core with effects and a clock passed in, so expiry and ordering are unit tests.

    Practice exercises

    1. Extension. Add an extendHold event and a hold-extended reply carrying a new deadline. The countdown must not jump backwards if an older reply arrives late; write that test first.
    2. Stale selection. Use freshness so that selecting a stale quote emits a requote effect before place-hold. What does the page show while it waits?
    3. Two tabs. The traveller opens the same booking in two tabs. Which of the three truths goes wrong first, and how would Cross-Tab Sync with BroadcastChannel help?
    4. Reload. Persist the offer id, hold id and details, restore them and turn submitting into unknown. What must the server's hold lookup return for restore to work?
    5. Clock skew. The server sends an absolute deadline and the user's clock is five minutes slow. Show what the countdown displays, then change the design to use a remaining duration and a monotonic reading.
    6. Accessibility pass. Write what a screen reader announces on a price change, at the two-minute warning and on expiry, and decide where focus goes after each.

    Official documentation

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments