Building blocks of a client architecture · core
Component architecture and state ownership
Break the screen into a tree of components and give every piece of state exactly one owner (the lowest common parent of its users). Keep most components presentational, and decide which parts render on the server and which need client JavaScript.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Start from the screen: regions become components; mark containers (own data and state) and presentational components (props in, events out).
- State lives in the lowest common owner of the components that use it; lift it only when siblings need it; keep it low so updates re-render small subtrees.
- Layers: view components → hooks/controllers (logic) → data layer (API client + cache) → services (socket, analytics, storage). Views should not call fetch everywhere.
- React Server Components (Next.js App Router): server components fetch and render non-interactive parts with zero client JS; put 'use client' only on interactive leaves (like button, composer); props crossing the boundary must be serialisable.
- Reusable components favour composition (children, slots, compound components) over many boolean props.
- Communication: props down and events up; a shared store for cross-cutting state; an event bus only for decoupled concerns like analytics.
- Put an error boundary and a Suspense boundary around each independent widget so one failure or slow call doesn't block the page.
- Slack's rewrite rule is a good one to quote: assume the data model is lazily loaded and incomplete.
The red pen
Common traps: mistake → fix
Mistake: Put everything in a global store or Context
Fix: server data belongs in a query cache, local UI state stays local, and Context re-renders all its consumers.
Mistake: 'use client' at the top of a page is harmless
Fix: the whole subtree becomes client JavaScript.
Mistake: Micro-frontends are how big apps are organised
Fix: they solve team and deployment problems, not code structure.
Easy to hard
Questions interviewers ask, easy to hard
- Draw the component tree for this screen.
- Where does the selected item live, and why there?
- Which components can be server components?
- One widget's API is slow. What does the user see?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.