All lessons Leer en español

Foundations · Unit 13 · Lesson 1 of 2

From click to response

Follow a ticket booking through presentation, transport, service decisions, and durable data.

7 minready

Helpful before thisWeb application architectures

After this lesson you can

  • explain the request and response without equating one click with one transaction
  • locate authoritative validation and authorization on the receiving service
  • distinguish a displayed success message from committed application state

A fictional theater sells seats through a phone-friendly website. You tap “Reserve,” a spinner appears, and a confirmation follows. That smooth experience hides several decisions. Learning where they happen helps explain why the browser, server, and database cannot simply trust one another’s assumptions.

From click to responseThe browser expresses intent, the service checks identity and the requested operation, and the data layer commits an allowed state change before the result is presented.Browser requestUser intent and inputService decisionsIdentity and availabilityCommitted resultThen present the outcome
The browser expresses intent, the service checks identity and the requested operation, and the data layer commits an allowed state change before the result is presented.

A click starts client-side work

The browser may submit a form or run JavaScript that prepares a request. The page could have been rendered by a server, assembled in the browser, or built using both approaches. One click can cause several requests, and some visual interactions cause no request at all. The appearance alone does not reveal the deployment architecture.

HTTP gives requests a method, target, headers, and sometimes content. Responses carry a status, headers, and possibly content. An application decides how these messages map to its operations. Calling something an API means it provides a software interface; it does not tell us who is allowed to use every operation.

The receiving service owns the decision

Client-side checks can make an empty form easier to correct. The service still validates the information it receives, establishes the relevant identity, and checks permission for the action and object. Choosing a seat and cancelling someone else’s booking are different authorization questions even if both requests are well formed.

The price and seat availability must come from authoritative state when the booking is committed. Two people can view the same available seat at once. The data operation must prevent both requests from successfully claiming it, using appropriate transaction or concurrency rules. A correct-looking page cannot solve that race by itself.

PredictThe service commits a booking, but the network drops before the confirmation reaches the phone. Does the missing confirmation prove that no booking exists?

No. The client has an uncertain outcome. The application needs a way to recover the result and handle retries without accidentally creating another booking. A timeout describes what the client observed, not everything the server did.

Responses can come from different places

A public event description may be reusable from a browser or shared cache. A private booking result needs caching rules appropriate to its sensitivity and audience. Encryption alone does not select the right cache policy. A CDN or reverse proxy may answer or forward a request, and an application may queue later work such as email delivery.

The email worker should receive only the details and authority it needs. Its success is also different from the booking’s success: a seat can be reserved even if the confirmation email is delayed. Clear user messages should distinguish those outcomes.

Read the whole result

A status code is useful evidence, not a complete business explanation. The response body and application state matter too. Trace input, identity, permission, state change, and presentation separately. That sequence exposes the responsibilities that remain necessary whether the service runs on one machine, many containers, or managed cloud components.

Check yourself

No timer. No penalties. Read the explanation and try again whenever you like.

  1. A browser disables a sold-out seat button. What must still happen?

    Show the answer

    Correct answer: The service must enforce availability when committing the booking. The authoritative decision belongs with the state transition.

  2. A response is lost after a booking is committed. What is the safest conclusion?

    Show the answer

    Correct answer: The client does not yet know whether the operation completed. A missing response is not proof that the server performed no work.

  3. A public event description comes from a cache. Did the origin necessarily handle this request?

    Show the answer

    Correct answer: No; a permitted cached response can be reused. Caching can avoid contacting the origin for each request.

  4. The API accepts the request format. Does this permit cancelling any booking?

    Show the answer

    Correct answer: No; it must check this identity’s authority over this booking. Well-formed input and object-specific authorization answer different questions.

Try it

  • WriteOn paper, trace a fictional seat booking with six cards: click, request, identity check, seat decision, durable result, response. Add a second customer requesting the same seat. Decide which component must prevent both bookings from succeeding.
References