Frontend Architecture & Resilience

Prevent stale state and duplicate mutations with state topology, FSMs, and idempotent outboxes.

5 concepts · 24 min

  1. Step 1Not explored

    Client State Topology: Ephemeral, URL, Server Cache & Persistent

    Eliminates stale data, broken back-button navigation, and redundant re-renders by assigning every piece of UI state to its canonical owner: ephemeral memory, URL search params, a server cache, or IndexedDB.

  2. Step 2Not explored

    Runtime Boundary Validation (Parse, Don't Validate)

    Prevents silent TypeError crashes from drifted API payloads and corrupted localStorage by parsing untrusted JSON at I/O boundaries into typed structures without blocking INP.

  3. Step 3Not explored

    Finite State Machines for UI

    Replaces overlapping boolean flags (isLoading, isError, isRetrying) with a discriminated union and explicit (state, event) transition table that makes invalid states unrepresentable.

  4. Step 4Not explored

    Optimistic UI & Rollback Safety

    Applies speculative UI state immediately on user action while retaining an immutable confirmed snapshot for atomic rollback if the network request fails.

  5. Step 5Not explored

    Outbox Queues, Idempotency Keys & Causal Ordering

    Prevents duplicate charges and out-of-order server overwrites on flaky networks by persisting mutations in an IndexedDB FIFO outbox with UUID idempotency keys.