Front End System Design Playbook · Chapter 4 of 11

Architecture and data model

Once requirements are set, the next 15–20 minutes go to the A and D of RADIO: the high-level structure of the application, and the data that moves through it. These two steps are closely linked. Where you put a piece of state depends on which component reads it, and how you split components depends on what data they own.

What a good architecture diagram contains

A front end architecture diagram is not a list of every component. It shows:

  • Major modules (5–8 boxes): server/API, client cache/store, controllers or feature hooks, view components, and infrastructure like CDN, service worker, or real-time channel.
  • Data flow direction: arrows labeled with what moves ("feed pages", "mutations", "events").
  • Boundaries: what runs on the server vs the client, and what's cached where.

Walk through one user action end to end using the diagram: "User taps like, the hook optimistically updates the cache, the UI re-renders, the hook sends POST, and on failure the cache rolls back and we show a toast." This one narrative shows that the boxes actually work together.

Rendering strategy decision

Make this explicit early. It affects data fetching, caching, and performance.

StrategyFirst paintInteractivitySEOServer costGood fit
CSRSlow (JS first)Fast once loadedWeakLowDashboards, internal tools, logged-in apps
SSR (streaming)FastNeeds hydrationStrongMedium–highPersonalized public pages, feeds
SSGFastestNeeds hydrationStrongLowestDocs, marketing, blogs
ISR / revalidationFastNeeds hydrationStrongLowProduct catalogs, content that updates periodically
Server Components plus islandsFastOnly interactive parts hydrateStrongMediumContent-heavy apps with targeted interactivity

A reasonable answer for a social feed: "SSR the shell and first page of the feed with streaming so content appears quickly, hydrate the interactive parts, then switch to client-side fetching for pagination." Saying why matters more than the choice itself.

Component architecture

Split the view layer by responsibility:

LayerResponsibilityExample
Route / pageData requirements, layout, code-split boundaryFeedPage
Container / controllerConnects data hooks to presentational componentsFeedController uses useFeed()
PresentationalPure rendering from props, reusablePostCard, Avatar, LikeButton
PrimitivesDesign system componentsButton, Dialog, Menu

With hooks, "containers" are usually just custom hooks. You don't need a separate component layer to justify the split, but the separation of concerns still applies.

function FeedPage() {
  const { pages, fetchNextPage, hasNextPage, status } = useFeed();
  if (status === 'pending') return <FeedSkeleton />;
  if (status === 'error') return <FeedError />;
  return (
    <Feed
      posts={pages.flatMap((p) => p.items)}
      onEndReached={hasNextPage ? fetchNextPage : undefined}
    />
  );
}

Where state lives

The most useful habit in front end design is classifying every piece of state:

CategoryDescriptionToolingExample
Server stateOwned by the server, cached on the client, can go staleTanStack Query, SWR, RTK Query, Apollo, Relayposts, users, products
URL stateShould survive reload and be shareableRouter params and search paramsfilters, sort, page, selected tab
Local UI stateEphemeral, belongs to one componentuseState, useReducerdropdown open, input value
Shared client stateCross-cutting UI state with no server ownerContext, Zustand, Reduxtheme, sidebar collapsed, multi-step form
Persistent client stateMust survive reload or work offlinelocalStorage, IndexedDBdrafts, offline mutation queue
Form stateValidation and dirty trackingReact Hook Form, native forms, actionscheckout form

Rule of thumb: server state doesn't belong in a general client store. Treating server data as a cache (with staleness, refetching, dedupe) removes most of the complexity that global stores used to hold.

Designing the data model

Entities and relationships

List entities with id, key fields, and relationships. Note which fields are display-only and which drive behavior.

type Conversation = {
  id: string;
  participantIds: string[];
  lastMessageId: string | null;
  unreadCount: number;
  updatedAt: string;
};

type Message = {
  id: string;            // server id
  clientId: string;      // temporary id for optimistic sends
  conversationId: string;
  senderId: string;
  body: string;
  status: 'sending' | 'sent' | 'delivered' | 'read' | 'failed';
  createdAt: string;
};

The clientId and status fields show you've thought about optimistic updates and failure, which is a typical senior detail.

Normalization

Store entities once, keyed by id, and reference them from lists:

type ClientCache = {
  users: Record<string, User>;
  messages: Record<string, Message>;
  conversations: Record<string, Conversation>;
  messageIdsByConversation: Record<string, string[]>;
};
ApproachProsCons
NormalizedOne source of truth; updates propagate everywhere; cheap lookupsMore code to read and write; needs selectors
Denormalized (nested responses)Simple; matches the APIDuplicated data goes stale; updates must touch many places
Query-keyed cache (TanStack Query)Simple per-query cachingCross-query consistency needs manual updates or invalidation

Pick based on how much data is shared across views. Chat and social apps benefit from normalization. Dashboards with independent widgets often don't.

Derived state

Don't store what you can compute. Compute unreadTotal from conversations, and visible items from data plus filters. Memoize only when the computation is expensive.

Pagination model

type Page<T> = { items: T[]; nextCursor: string | null; prevCursor?: string | null };

Cursor-based pagination is the default for feeds and chats because inserts don't shift positions the way they do with offsets.

Architecture patterns to name-drop (correctly)

  • Unidirectional data flow: state flows down, events flow up. This is the default mental model.
  • Optimistic UI with rollback: apply the change locally, reconcile with the server response.
  • Stale-while-revalidate: show cached data immediately, refresh in the background.
  • Event-sourced local state: for collaborative editing, store operations rather than snapshots (CRDT or OT).
  • Feature-sliced structure: organize code by feature, not by type, so teams can own vertical slices.
  • Backend for frontend (BFF): a thin server layer that shapes APIs for one client, which cuts over-fetching and round trips.

Common mistakes

  • A diagram with 25 boxes and no arrows.
  • Putting all server data in Redux "because it's global".
  • Forgetting URL state, so filters are lost on refresh and links can't be shared.
  • Not deciding a rendering strategy, then being surprised by SEO or first-load questions.
  • A data model with no ids, timestamps, or status fields.

What lead candidates add

  • Team boundaries: "Each feature folder can be owned and deployed by a different team. Shared state goes through a typed event bus or the URL, not direct imports."
  • Evolution path: "Start with query-keyed caching; if cross-view consistency issues grow, move hot entities to a normalized store."
  • Contracts as code: generated TypeScript types from OpenAPI or GraphQL schemas, and contract tests.
  • Cost awareness: SSR adds server cost and on-call load. Is the latency gain worth it for this product?

Checklist

  • 5–8 boxes with labeled arrows; client vs server boundary shown
  • Rendering strategy chosen and justified
  • One user action walked through end to end
  • Every important piece of state classified (server, URL, local, shared, persistent)
  • Entities defined with ids, timestamps, and status fields
  • Normalization decision explained
  • Pagination model chosen

Spotted a mistake or a rights concern? Report an issue