Stateful products and dependable requests

Webapp Stacks API

Web applications coordinate user actions, persistent data, and services that can fail independently. Learn how to assign state to the right place, design request boundaries, handle background operations, and test authorization so your stack supports a dependable product rather than only a successful first demo.

Decide which component owns each state

A web application contains temporary interface state, persisted business data, and often a cache of information retrieved from a service. Distinguish them explicitly. A selected tab may belong in the browser; a submitted order needs an authoritative record. Confusing a displayed value with the underlying source of truth makes synchronization and recovery difficult.

Map a meaningful action from click to persisted outcome. Identify the API request, validation, permission check, database change, and response. If the work continues after the response, provide an observable job state. A user should be able to tell the difference between accepted work, completed work, and an operation that needs attention.

Design the browser boundary deliberately

The MDN CORS guide explains how HTTP headers let servers specify browser access across origins, including preflight behavior for some requests. CORS configuration belongs in the browser integration design. It should not be treated as a substitute for checking the caller's authorization to access application data.

Keep privileged credentials out of delivered browser assets. Decide which actions the browser can call directly and which need a trusted application service. Review how session expiry, lost network connections, and revoked access affect the interface. Clear error states help users recover without blindly repeating an operation that may already have completed.

Account for repeated and competing actions

Two browser tabs may edit the same record, or a user may resubmit while the first request is still processing. Define how the application detects conflicts and handles repeated work. Prefer an explicit policy over whichever result happens to win a race. Make operations observable so support staff can explain what occurred.

Background jobs need the same attention to ownership and permissions as interactive requests. Carry the relevant account context, retain enough execution history to diagnose failures, and define retry behavior. Bound queue growth and decide how the application responds when a dependency remains unavailable.

Evaluate one complete failure scenario

Choose a representative workflow and interrupt it after the server accepts the request. Confirm that the user can reconnect, discover the result, and proceed without duplicate work. This exercise connects front-end design, API semantics, persistence, and operations in a way that a framework feature comparison cannot.