Mobile Design Rounds
Build guideAndroidiOS18 min read

Build it: a booking app on Android and iOS

Last reviewed . Drafted with AI assistance. Checked against official documentation where noted (how this is checked). Part of: Design a hotel or ride booking app (Android and iOS): holds, payments and recovery · Live data and payments · The five-step method.

This is the implementation material behind the hotel booking interview case. It covers:

  • local tables, REST calls and the booking states
  • the hold clock, idempotency (doing a request twice has the same result as doing it once), wallets and 3-D Secure (an extra check that the bank asks for)
  • search, paging, deep links and the ride contrast
  • platform limits and the iOS version

None of it belongs in the 45 minutes. I draw it only if the interviewer asks. The snippets use Room 3.0 (androidx.room3, current stable 3.0.3, from the Room guide and the 2.x to 3.0 migration guide). Room 3 needs KSP (no KAPT) and a SQLiteDriver on the builder. I did not compile these snippets against Room 3. The tables and the architecture are the same in Room 2.x.

1. Local tables (Room)

  • booking_attempt(idempotencyKey, offerId, holdId, status, version, holdExpiresInMs, holdSentAtElapsed): the app writes it before the first network call. The key is the attempt id (the primary key). It is the record that lets the app recover after the system stops it.
  • trip(bookingId, status, propertyJson, dates, voucherCode, syncedAt): confirmed bookings, which the user can read offline.
  • recent_search(query, placeId, usedAt) and result_page(queryKey, pageIndex, itemsJson, quotedAt): the search side.

The idempotency key (a unique ID that lets the server spot a repeat request) has several names in this guide. They are all one value. The "attempt id" in the state machine case is the same value:

WhereNameWhat it is
HTTP headerIdempotency-KeyThe key as the server sees it
Room columnidempotencyKeyThe key, stored before the first send
Kotlin BookingApi.confirmkeyThe same value, passed as a header
Swift PayDelegateattemptKey and idempotencyKeyThe same value, property and parameter

From here on, "the key" means this idempotency key.

2. REST

GET  /v1/places/suggest?q=lis

GET  /v1/offers?placeId=..&dates=..&cursor=..
     → 200 { items: [{ offerId, quoteId, price, quotedAt }], nextCursor }   // cursor is opaque

GET  /v1/offers?bbox=..&dates=..                      // map viewport

POST /v1/holds
     Idempotency-Key: <attemptId>
     { offerId, quoteId }
     → 201 { holdId, expiresInMs, price }
     → 409 { error: "price_changed", price }

POST /v1/bookings
     Idempotency-Key: <attemptId>
     { holdId, paymentToken }
     → 200 { bookingId, state, version, nextAction? }          // a repeat returns the same answer

GET  /v1/bookings/{id}
GET  /v1/bookings?attempt=<attemptId>                       // recovery lookup after a restart
GET  /v1/holds/{holdId}
     → 200 { state, expiresInMs }

POST /v1/attempts/{attemptId}/close
     → 200 { booking } or { closed: true }                     // later requests with this key are refused

How to read the snippet. Each block is one call: the method and path, then the headers, then the JSON body (the data the app sends) in braces. A line that starts with → is a reply from the server. Text after // is a comment. These are sketches for this guide, not a vendor API.

CallWhat it is forWhen the app makes it
GET /v1/places/suggestPlace suggestions for the search box.As the user types. Short input is served from local recents first.
GET /v1/offers?placeId=…A page of offers for a place and dates. Each offer has a quoteId (a price offer with an ID) and quotedAt.When results open and when the user nears the end of the list. The app saves nextCursor and sends it back unchanged.
GET /v1/offers?bbox=…Offers inside the visible part of the map.When the user moves or zooms the map.
POST /v1/holdsHold the room for a short time at the quoted price.When the user taps Reserve. The reply has expiresInMs, the time left.
POST /v1/bookingsPay for the hold and make the booking.When the user confirms payment. The reply has a state. If the bank needs 3-D Secure, nextAction says what to show.
GET /v1/bookings/{id}Read one booking and its state.To refresh the booking screen, and to poll while the state is still PROCESSING.
GET /v1/bookings?attempt=…Find the booking that belongs to an attempt key.After a restart, for any attempt that is not in a final state. The app does not need to remember the booking id.
GET /v1/holds/{holdId}The hold state and the time left.To check the clock again, for example when the app comes back to the foreground.
POST /v1/attempts/{attemptId}/closeClose an attempt. Later requests with this key are refused.When the user abandons checkout, so a late retry cannot create a booking.

Why there is an Idempotency-Key. A request can reach the server while the reply is lost. The app then cannot tell if it worked. If it sends the request again without a key, the server may hold two rooms or charge twice. With a key, the server remembers the first result and returns it for the same key.

  • The app makes the key once per checkout attempt and saves it in booking_attempt before the first send.
  • Every retry of that attempt sends the same key. This includes a retry after the app was stopped and started again.
  • The hold and the booking calls use the same key, because they are steps of one attempt.
  • A new attempt gets a new key. After a price change the user starts a new request for the new quote, so the app makes a new key. The same key would return the saved 409 again.

What the app does with each answer.

AnswerMeaningWhat the app does
201 on holdsThe room is held.Start the countdown from expiresInMs, using a monotonic clock, and go to payment.
409 price_changed on holdsThe quote is old. The reply has the new price.Show the new price and ask the user to confirm. If they agree, send a new hold request with a new key.
200 on bookingsThe server accepted the request. The state may not be final.Show the state. For nextAction, show the bank step. For PROCESSING, poll or wait for a push, and do not charge again.
Same key sent againA retry of a request that already ran.Treat the reply as the original result. Nothing new happens on the server.
Network error, timeout or 5xxThe app does not know if the request worked.Retry with the same key, with backoff. If the app was stopped, ask GET /v1/bookings?attempt=… first.
Other 4xxThe request itself is wrong.Stop. Show an error. Do not retry the same request.

One checkout in calls.

  1. The user picks an offer. The app has a quoteId from the offers list.
  2. The app makes a key and saves the attempt in Room.
  3. POST /v1/holds with the key. The reply has holdId and expiresInMs.
  4. The user pays. POST /v1/bookings with the same key.
  5. The reply is lost, or the app is stopped. At the next start the app finds the open attempt and calls GET /v1/bookings?attempt=….
  6. The server returns the booking. The app shows its state and marks the attempt final.

A cursor is a saved position in a list. The server gives the cursor to the client, and the client does not read it ("opaque"). A quote is a price offer with an ID (quoteId) and a time (quotedAt).

The server returns expiresInMs, a duration that it computes when it sends the response. It does not send only an absolute end time. A duration does not depend on the clock of the device.

3. States, quotes, dates and money

Server-driven states:

  • Normal path: HELD, PAYMENT_REQUIRED, ACTION_REQUIRED (only when the bank asks for 3-D Secure), PROCESSING, CONFIRMED.
  • Before CONFIRMED, a booking can end in EXPIRED or FAILED.
  • After CONFIRMED, it can become CANCELLED.

The client copies this list as a sealed type (a Kotlin type with a fixed set of cases). The client never moves the state on its own.

Each response carries a version, a counter for each booking that the server increases. I only compare it. Unlike the seq of the chat app (a sequence number), a booking has no gaps to detect. I ignore any response that is not newer, so late responses cannot move the state backwards.

Dates and money need the same care:

  • A check-in date is a calendar date in the time zone of the hotel. It is not an instant. I send 2026-11-03 as a plain date string. I never send it as a UTC timestamp, because that can move the date by one day in another time zone.
  • Prices travel as a whole number in minor units (the smallest unit of a currency, such as cents) plus a currency code.
  • The server returns the full breakdown: nightly rate, taxes, fees and total. The client formats these numbers and never adds them up.

4. The hold clock

A hold means that the server keeps the room for the user for a short time. The common mistake is to use System.currentTimeMillis(). A user whose clock is, for example, 20 minutes fast sees a hold that has already ended. The server decides when the hold ends, and the client only shows it.

  1. POST /holds returns expiresInMs.
  2. Record a monotonic timestamp before you send the request, and compute the time left from it. Network delay then makes the screen show slightly less time than the server grants, never more.
  3. Use a monotonic clock (SystemClock.elapsedRealtime()). It does not jump when the user changes the date.
  4. At zero, lock the pay button, but read the hold again with GET /holds/{holdId}. The server may have extended it.
  5. Save expiresInMs and the monotonic reading in booking_attempt. After a restart, the countdown can be rebuilt from them. If elapsedRealtime() is lower than the saved reading, the phone rebooted. Then read the hold from the server.
  6. The server still checks the pay request. On EXPIRED, show "Room no longer held" with an action to check again.
// Sketch: countdown anchored to a monotonic clock
data class HoldClock(val expiresInMs: Long, val sentAtElapsed: Long) {
    fun remainingMs(now: Long = SystemClock.elapsedRealtime()): Long =
        (expiresInMs - (now - sentAtElapsed)).coerceAtLeast(0)
}

5. Idempotency in detail

This is the classic failure. The request reaches the server, the response is lost, and a retry (a second try) or a second tap sends the request again. Without protection, that is two charges.

  • Generate the key once for each checkout attempt (a UUID, a random unique ID). Write it to booking_attempt before the first send. Use the same key on every retry of that attempt.
  • Send it as Idempotency-Key. The docs of Stripe describe this pattern for the caller of their API, which is your server. The phone sends its key to your server, and your server maps it to the provider call. V4 UUIDs are suggested, up to 255 characters. For API v1, the server saves the first result and returns it on retries.
  • A saved failure is sent again. For API v1, the saved response includes 500 errors. So the same key gives the same 500 again. Requests that fail validation, or that collide with a request still running, are not saved. You can retry those with the same key.
  • A changed cart needs a new key. Stripe compares the new parameters with the original request. It returns an error if they do not match.
  • A fresh attempt is a new key. A new wallet authorization makes a new token, so it is a fresh attempt. Close the old key first (the Close call), so a late request cannot charge as well. Some providers say to start a new key after the user leaves the bank page, after a failed challenge or after a change of payment method. I have not verified that rule on the page of Stripe, so I follow the rules of my provider.
  • Keys expire. Stripe says API v1 keys can be pruned (deleted) once they are at least 24 hours old. Your backend picks its own time window.
  • The hold call has its own key. If the hold response is lost, retry with the same key. The server makes one hold.
  • Double tap: the ViewModel (the class that holds the screen state) ignores Pay while the state is Submitting. The key is the safety net, not the first protection.
  • After a timeout, look before you send again: GET /bookings?attempt=<key>. If a booking exists, use it. If not, send again with the same key.
  • Retry rule (my choice, not Stripe's): retry network errors, 408 and 429, and obey Retry-After when it is present. After a 5xx, do not just resend: the saved 500 comes back. Look up the key first. If a booking exists, use it. If not, close the key and start a new attempt with a new key. Any other 4xx is final. The exceptions are answers that this API defines as states, such as 409 PRICE_CHANGED and SOLD_OUT. Those go to the user.
  • A 401 is not a failed payment. The login can expire while the user is in the bank page. Then the pay call or the lookup returns 401. Refresh the token once, then call again with the same key. A new key here could charge twice. The booking lookup after a relaunch uses the refreshed token.

This is the same pattern as the send path of the chat app and the second mistake in the offline-first guide. The difference here is that a retry costs money. The app saves the key before the first send. Unlike the chat app, there is no outbox (a table of waiting writes). There is only the one attempt record.

// Sketch: the key comes from the persisted attempt (wrapped by a data source; not called from the ViewModel)
interface BookingApi {
    @POST("v1/bookings")
    suspend fun confirm(
        @Header("Idempotency-Key") key: String,
        @Body body: ConfirmRequest,
    ): BookingDto
}

The pay call runs in a scope that the repository owns (the repository is the class that reads and writes data). It does not run in viewModelScope, because leaving the screen must not cancel a charge in flight. The ViewModel only waits for the result. BookingApi sits behind a remote data source and BookingRepository, so the ViewModel never calls it.

The recovery lookup at launch could be a WorkManager job (Android's scheduler for work that survives restarts). A plain call at startup is enough here.

6. Wallets, 3-D Secure and card data

The wallet sheet produces a token, which is a code that stands for the card. The client never charges anyone. The sheet or the SDK of the payment provider collects the card. My app and my servers only handle a token.

As I understand it, this keeps raw card numbers out of my systems and makes PCI scope smaller (PCI is the card industry's security rules). I have not verified the exact scope rules, so confirm them with your payment provider.

  • Google Pay: the user picks a method in the sheet. Google Pay returns a token to the app, which sends it with the purchase details to your backend. The backend passes it to the payment provider. PaymentsClient.isReadyToPay decides whether to show the button, and loadPaymentData opens the sheet.
  • Apple Pay: PKPaymentAuthorizationController shows the sheet. In didAuthorizePayment, you send the token to your server and report the result.
  • 3-D Secure: in the flow of Stripe, the PaymentIntent (the record of one payment) moves to requires_action. The SDK shows the challenge. Or a web view uses a return_url that routes back into the app. Stripe says 3-D Secure is not supported for every transaction, and wallets are one example. In practice, you meet it with cards.

The result of the redirect is a hint, not the truth. The user may finish the bank page and never return. Or the user may return to a new process (a new running copy of the app). On resume, or on the return link, move to Processing and ask the server for the booking state.

  • Poll (ask the server again and again) with backoff (wait longer after each failure), or wait for a push. A push is only a hint, so I still poll once.
  • The server learns the real result from provider events. Stripe sends server events with the final result. Use the event your provider documents for the outcome. The server shows it as the booking state.
  • In its web flow, the page of Stripe says to get the updated PaymentIntent after the challenge. This is the same idea: ask, and do not assume.

Polling budget, as arithmetic on an assumption: delays of 1, 2, 4 and then 8 seconds (the longest delay) give 9 polls in 55 seconds. After about a minute, I show "still checking" and rely on push and the next launch.

7. Process death mid-payment

Process death means that the system stops the running copy of the app. SavedStateHandle survives when the system stops the app. It does not survive a force stop by the user or a swipe away from Recents, and it is meant for small values. The page of Android says saved state is tied to the task stack.

Keep only the key there, and keep the rest in Room. At startup, find the booking_attempt rows that are not in a final state. Reconcile each one with GET /bookings?attempt=<key>. To reconcile means to compare the phone with the server and fix differences. After a force stop, the Room row still lets this run at the next launch. Only the screen that was open is lost.

8. Search and autocomplete

Debounce (wait a short time after the last key press, for example 250 ms, tuned with data), trim, drop duplicates, and cancel the previous request. Then a slow "lis" cannot replace "lisbon".

  • Show recent searches from Room when the field is short, and cache suggestion responses by query.
  • Short input skips the debounce, so the recents appear at once.
  • If the suggest call fails with an IOException (for example when offline) or an HttpException (a 4xx or 5xx), the list becomes empty. Without this, the error would reach viewModelScope and crash the app on a key press.
  • Other exceptions still go up, because I would rather see a real bug than hide it.

The snippet needs import java.io.IOException and import retrofit2.HttpException, which the block does not show. A Retrofit call throws HttpException for a 4xx or 5xx, so catch it too.

// Sketch: debounce + cancel-previous with flatMapLatest
@OptIn(FlowPreview::class, ExperimentalCoroutinesApi::class)
class SearchViewModel(private val repo: PlaceRepository): ViewModel() {
    private val query = MutableStateFlow("")

    val suggestions: StateFlow<List<Place>> = query
        .debounce { if (it.trim().length < 2) 0L else 250L }   // recents show at once
        .map { it.trim() }
        .distinctUntilChanged()
        .flatMapLatest { q ->
            if (q.length < 2) repo.recents()        // Flow<List<Place>> from Room
            else flow { emit(repo.suggest(q)) }     // cancelled by the next query
                .catch { if (it is IOException || it is HttpException) emit(emptyList()) else throw it }
        }
        .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptyList())

    fun onQueryChanged(q: String) { query.value = q }
}

9. List, map, staleness and offline

List and map. Use Paging 3 with a RemoteMediator. The news feed case explains it. The database is the source of truth. The mediator is the signal that the cached data ran out, so it fetches the next page into Room.

  • Put the whole query (place, dates, guests, filters) in the page key, so a change of filter starts a new list.
  • Load the next page before the user reaches the end (PagingConfig.prefetchDistance).
  • For the map, query by viewport (the visible part of the map) once the camera stops. Debounce, cancel the previous request for a map box, and group nearby pins on the server.

Staleness. Treat every price as a quote. Items carry quoteId and quotedAt.

  • Show "Prices may have changed" on old cached pages.
  • Refresh when the user pulls down, and when the app returns to the foreground after a long gap.
  • Always check the price again at checkout. POST /holds takes the quoteId. If the price differs, the server answers 409 PRICE_CHANGED with the new price, and the user accepts it or goes back.
  • SOLD_OUT returns the user to the results, with the item marked. The client never computes the final total.

Offline. Confirmed bookings sit in trip with the confirmation code and the address, so the user can show them at the door. Search shows cached pages with a banner that says the data is old. Hold and pay are disabled, and the screen shows the reason.

A deep link is a link that opens a screen inside the app. A confirmation email opens https://example.com/trips/<id>.

  • Android: use verified App Links. That means an intent filter with autoVerify, plus assetlinks.json on your domain. On Android 15 and later, the system checks domains again from time to time. Allow up to a week for changes to that file to reach devices.
  • iOS: use universal links. The guide of Apple calls them a possible attack path and says to discard malformed URLs.
  • Both: check every parameter. Route by ID. If the user is signed out, sign in first. Show the cached trip, then refresh from the server. Never trust state that is encoded in the link.

11. Ride hailing: what changes

I treat this as a contrast, not as a second design. The base is the same: state owned by the server, idempotent requests and a state machine. The scarce thing changes. In a hotel it is rooms. In a ride it is drivers who are moving. This is industry practice, not a documented source.

AspectHotelRide
ReservedA room for dates, held for minutesA driver, matched in real time
TimeoutHold expiryMatching timeout; show "no drivers", offer retry
PriceQuote, checked again at checkoutEstimate shown before the request
Live dataAlmost noneDriver location stream
PaymentAt bookingOften authorized up front, finalized after the trip
OfflineSaved bookings are usefulLittle value

For live location, open a WebSocket (a two-way open connection; OkHttp on Android, or URLSessionWebSocketTask on iOS) only while the trip screen is visible. Move the marker smoothly between points. On reconnect, fetch the latest trip state by ID instead of replaying the stream. The ride request is idempotent, like a booking. After the app is stopped, the client resumes by asking for the active trip.

12. Platform and store limits

LimitAndroidiOSSo the design changes by
App stopped while the user is in the bank page or wallet sheetSavedStateHandle survives when the system stops the app, not force stop or a Recents swipe, and holds small values onlyNot checked hereSave the attempt row; restore it at launch on both
Work after the screen is goneCoroutines stop when the app closes; WorkManager persists across restarts and rebootsNot checked hereThe pay call runs in a repository scope; the lookup at startup repairs what the scope lost
Wallet resultGoogle Pay returns a token; how the result reaches the activity is not on the pages I readThe sheet waits for your handler; the delegate is main-actorKeep the server call short; an unknown outcome fails the sheet and starts a lookup
RolloutA halted Play rollout reaches no more users; users who have the build keep it (staged rollouts)Phased release runs 7 days; it can be paused for a total of 30 days; manual updates always work (phased release)Old versions stay in the field; the server keeps accepting the old shape
Deep link checksautoVerify and assetlinks.json; Android 15 checks again from time to timeUniversal links; discard malformed URLsCheck every parameter on both
Payment rules in the storeGoogle's matching policy not checkedApp Review 3.1.3(e) says goods and services consumed outside the app use something other than in-app purchase; hotels and rides are not namedPay by wallet or card token, not store billing; read the rule again before shipping

13. How to build a booking app on iOS (Swift)

The architecture carries over. What changes is the platform tools.

ConcernAndroidiOS
Local DBRoomSwiftData or Core Data (or GRDB)
WalletGoogle Pay API (PaymentsClient)PKPaymentAuthorizationController
3-D Secure returnPSP SDK; return_url via App LinkPSP SDK; return_url via universal link or custom scheme
Process deathSavedStateHandle (ids) + RoomAttempt row in SwiftData or Core Data, restored on launch. SceneStorage is not guaranteed, so it only restores the screen.
Deep linksApp LinksUniversal links (associated domains, NSUserActivity)
Monotonic clockSystemClock.elapsedRealtime()ContinuousClock (counts through sleep; its behaviour when the date changes is not on the Apple page, so treat that as unverified)
Cancel-previous searchflatMapLatestCancel the previous Task
PagingPaging 3 + RemoteMediatorCursor loading; no official paging library
Live locationOkHttp WebSocketURLSessionWebSocketTask

PSP means payment service provider, the company that takes the payment.

What changes in practice:

  • No durable retry framework is needed. Booking works online only on both platforms. There is no outbox of waiting writes. There is only the saved attempt record and the check against the server at launch.
  • Keep the call alive. A normal URLSession request is suspended soon after the app goes to the background. Wrap the confirm call in UIApplication.beginBackgroundTask. If it is cut off, the lookup repairs it.
  • Who owns the call. Use a repository actor that lives as long as the app. Do not start the charge from a SwiftUI .task, because the system cancels it when the view goes away.
  • Apple Pay setup. You need a merchant ID and the Apple Pay capability. Check PKPaymentAuthorizationController.canMakePayments() before you show the button.
  • Scene phase. SwiftUI's ScenePhase reports active, inactive and background. When the app returns to active after the bank page, fetch the booking state. Close the driver socket when the app leaves the foreground.
  • The Apple Pay result blocks the flow. Apple documents that the controller waits for your handler before the next delegate method. In the async variant used below, it waits for the method to return. Apple declares the delegate @MainActor, so the sketch does too.

Keep the server call short. The sketch sets no timeout, so add a short one on confirm. Then the three outcomes are:

  • A definite error from the server fails the sheet.
  • A URLError, such as a timeout, means I do not know whether the card was charged. I still fail the sheet, because I will not show a success mark for a payment that I have not confirmed.
  • The delegate also tells the screen to move to PROCESSING, and the screen looks the booking up by the attempt key. If the card was charged, the lookup finds the booking. If not, close the key. The next Apple Pay try makes a new token, so it is a new attempt with a new key.

The other option is to report success and reconcile later. That looks smoother, but it is wrong whenever the charge failed.

// Sketch: Apple Pay delegate sending the wallet token with the persisted attempt key
@MainActor
final class PayDelegate: NSObject, PKPaymentAuthorizationControllerDelegate {
    let api: BookingAPI
    let attemptKey: String
    let onUnknownOutcome: () -> Void   // the screen moves to Processing and looks the booking up by key
    init(api: BookingAPI, attemptKey: String, onUnknownOutcome: @escaping () -> Void) {
        self.api = api; self.attemptKey = attemptKey; self.onUnknownOutcome = onUnknownOutcome
    }

    func paymentAuthorizationController(
        _ controller: PKPaymentAuthorizationController,
        didAuthorizePayment payment: PKPayment
    ) async -> PKPaymentAuthorizationResult {
        let token = payment.token.paymentData
        do {
            _ = try await api.confirm(idempotencyKey: attemptKey, walletToken: token)
            return PKPaymentAuthorizationResult(status: .success, errors: nil)
        } catch is URLError {
            // Timeout or dropped connection: the server may already have charged.
            // Fail the sheet, then look the booking up by the attempt key. If none exists, close the key; a new try gets a new key.
            onUnknownOutcome()
            return PKPaymentAuthorizationResult(status: .failure, errors: nil)
        } catch {
            return PKPaymentAuthorizationResult(status: .failure, errors: nil)
        }
    }

    func paymentAuthorizationControllerDidFinish(_ controller: PKPaymentAuthorizationController) {
        controller.dismiss()
    }
}

14. Edge cases checklist

ScenarioHandling
Device clock wrongServer duration plus monotonic clock; server enforces expiry
Double tap on PayViewModel ignores while Submitting; idempotency key collapses duplicates
Response lost after booking createdLook up by attempt key; use the server state; keep the same key
Hold expires during 3-D SecureServer returns EXPIRED or voids per its rules; client shows server state, offers a re-check
App stopped in the bank appbooking_attempt in Room; check against the server at startup
User returns without finishingTreat as unknown; fetch state; offer resume or cancel
Price changed since search409 with new price; user confirms
Last room soldSOLD_OUT at hold; back to results
Late response for old searchCancelled by flatMapLatest; keyed by query
Out-of-order updatesCompare version; ignore older

15. More practice prompts

These are practice prompts, not a claim about what any interviewer asks. They are my reconstruction.

  1. How do you support modify and cancel? Use the same idempotent pattern with a version check first. The refund state comes from the server.
  2. How do you handle two devices on one account? Server state is the truth. Trips sync by version. A hold belongs to the user.
  3. How do you test checkout? Use a fake API that drops the response after success, forces PRICE_CHANGED and EXPIRED, and sends versions out of order. Stop the process in the middle of an attempt.
  4. What happens after the booking? Cancel and modify with refund state, push updates and a calendar entry. The ride contrast adds matching, a cancellation fee and surge (higher prices when demand is high).

Further reading (official docs)

Words on this page (23)
Coroutine
A light background task in Kotlin. It can pause and continue later without blocking a thread.
Cursor
A saved place in a list. The server gives it to the app, and the app sends it back to get the next part.
Debounce
To wait a short time and then act once. For example, send one request after the user stops typing.
Deep link
A link that opens a specific screen in the app.
Exponential backoff
Waiting longer after each failure. For example, wait 1 second, then 2, then 4.
Idempotency key
A unique ID that the app sends with a request. It lets the server see a repeat request and not do the work twice.
Idempotent
Doing it twice has the same result as doing it once. This makes a retry safe.
Monotonic clock
A clock that only moves forward. The user cannot change it, so it is good for measuring how much time passed.
Outbox
A saved list of changes that the server has not confirmed yet. The app sends them later, even after it restarts.
Paging
Loading a long list in small parts. The app asks for one page at a time.
Polling
Asking the server again and again if there is news. It costs battery and data.
Process death
The system ends the process of your app to free memory. Anything that is only in memory is lost.
Repository
The class that reads and writes data for the rest of the app. It hides whether the data comes from the network or the database.
Room
Android's library for the database on the phone. You use a DAO to read and write the data.
SDK
Software development kit. Code that other developers add to their own apps.
Sequence number
A number that grows by one with each message. It shows the order, and it shows a gap when a number is missing.
Source of truth
The one copy of the data that the app trusts. In these cases it is the database on the phone, and the screen only reads it.
Staged rollout
A release to a growing share of users, not to everyone at once. It limits the harm of a bad release.
SwiftData
Apple's library for saving data on an iPhone. It has the same role as Room on Android.
UUID
A random unique ID. Two devices almost never make the same one.
ViewModel
A class that holds the state of one screen. It survives a screen rotation.
WebSocket
A two-way connection that stays open. The server can send data to the app at any time.
WorkManager
Android's tool for background work that must run later. The work survives when the app closes or the phone restarts.

Read the whole glossary

Verification notes (last reviewed 14 Oct 2026)

What I checked:

  • The HoldClock, BookingApi and SearchViewModel snippets compiled, with Retrofit and the app types stubbed. The search pipeline also ran in a small JVM test. The Swift Apple Pay delegate was type-checked with a stub API. I changed the search catch line and the delegate comment after that, so compile them again.
  • Facts come from official pages read on 14 Oct 2026: Stripe idempotent requests and 3-D Secure, Google Pay, Android (offline-first, ViewModel, saved state, WorkManager, App Links), Apple (PassKit, universal links, ScenePhase, URLSessionWebSocketTask), Play staged rollout, App Store phased release.
  • Android 15 and later re-check App Links domains from time to time.

What I did not verify:

  • How Google Pay returns its result to the activity, and any Apple Pay sheet time limit.
  • The ContinuousClock behaviour when the user changes the date.
  • The PCI scope paragraph and the "new key after an abandoned bank page" convention. Ask your payment provider.
  • App Review 3.1.3(e) was read through a summary, and Google's matching policy was not checked.
  • No iOS engineer has reviewed the iOS sections.

My design, not a source: the Close call, the retry rule, the ride table, the 10-minute hold, the 250 ms debounce and the polling delays. BookingAPI.confirm, ConfirmRequest, BookingDto and PlaceRepository are placeholders.

Questions or corrections?

Add them to the discussion thread for this case on GitHub. To post, you need a free GitHub account. What you write there is public and follows GitHub's terms. Good answers are added to this page.

Keep reading

Get the free one-page cheat sheet

One page: the five steps, a 45-minute time plan and two checklists. Print it or keep it on your phone.

We email you the cheat sheet after you confirm your address. You can also open it now from the Start here page. You also get a short email each week with a follow-up round, and a note when a new case is published. Unsubscribe any time. Privacy.