Chapter 10 · Low Level Design
Interview drill
15 questions from this chapter. Answer each one out loud first, then open it to compare.
-
10.1"Design a reusable Table component."
- Start with the API out loud:
columnsconfig,data,onSort,renderCellfor escape hatches, slots for empty and error states. - Keep sorting and pagination controlled so the parent can drive them from the URL (6.10).
- Name the accessibility contract — real
<table>semantics,scopeon headers, sortable columns announcingaria-sort.
- Start with the API out loud:
-
10.2"How would you build a home screen that changes without a release?"
- Server returns an ordered list of typed sections; the client maps types to components via a registry.
- Validate the config, ignore unknown types for forward compatibility, and version the schema.
- Keep data fetching per section (each declares its own
source) so one slow API doesn't block the whole screen — stream or lazy-load below the fold.
-
10.3"Spinner or skeleton?"
- Skeleton when the layout is known and the wait exceeds a second — it removes the layout shift and sets expectations.
- Spinner for short or unpredictable waits; nothing at all under ~300ms.
- Best of all is stale-while-revalidate, so returning users see content instantly and it refreshes underneath.
-
10.4"How do you protect routes in an SPA?"
- A guard component wrapping the protected subtree, driven by a three-state auth value so refresh doesn't flash the login page.
- Preserve and validate the return path, and use
replaceso the back button doesn't bounce between login and page. - Say plainly that this is presentation only — the server authorises every request regardless of what the client renders.
-
10.5"Redux or Context?"
- Neither, usually — most of what people put in Redux is server state and belongs in a query cache.
- Context broadcasts to every consumer, so it fits low-frequency values like theme and locale, not a cart.
- For genuine global client state I'd default to a selector-based store and reach for Redux Toolkit when the team needs strict conventions, middleware, or time-travel debugging.
-
10.6"How would you add multi-language support to an existing app?"
- Extract to keys with a source bundle, wire
Intlfor all formatting, and lazy-load one locale at a time. - Fix layout for text expansion and switch to logical CSS properties so RTL is a
dirattribute, not a second stylesheet. - Decide URL strategy early —
/de/pathis best for SEO and shareability, and it makes locale a routing concern rather than hidden state.
- Extract to keys with a source bundle, wire
-
10.7"Build an infinite feed. What breaks first?"
- The DOM: without virtualization, memory and scroll performance degrade after a few hundred items.
- Offsets: with items being inserted at the top, offset pagination duplicates and skips — use cursors.
- Then the details that get skipped: the double-fire guard, the end state, scroll restoration, and a keyboard-accessible load-more.
-
10.8"Build an accordion."
- Ask single or multiple first, because it decides the state shape.
- Buttons inside headings,
aria-expandedandaria-controlswired,hiddenon closed panels, focus staying on the trigger. - If the content is heavy, lazy-render panels on first open and keep them mounted afterwards to preserve scroll and form state.
-
10.9"Build Reddit-style nested comments."
- Normalized flat store, memoised parent→children map, recursive component with a depth prop.
- Cap indentation around five levels and link deeper threads to their own view — this is a UX requirement, not a shortcut.
- For very large threads, flatten to a visible-nodes array and virtualize; recursion and virtualization don't compose easily.
-
10.10"Build an image carousel."
- Track with a single
translateX, transform-only animation, neighbour preloading, and pointer-based swipe with a commit threshold. - Autoplay pauses on hover, focus, and hidden tab, stops after interaction, and honours reduced motion.
- Mention CSS
scroll-snapas the simpler path when autoplay isn't required — it gives you momentum and accessibility for free.
- Track with a single
-
10.11"Why did the same item appear on two pages?"
- Offset pagination on a list that receives inserts — every new row at the top shifts the window by one.
- Cursors fix it because position is defined by the row you last saw, not by a count.
- Keep a unique tiebreaker in the sort key, or identical timestamps will still cause skips at boundaries.
-
10.12"Build a pagination component."
- Start with the API:
total,page,pageSize,onChange— and state that page lives in the URL, not in the component. - Extract the ellipsis range into a pure function so it's unit-testable, and keep the slot count fixed to avoid layout shift.
- Use
<nav>witharia-current="page"and real links, so keyboard, screen reader, and middle-click all behave correctly.
- Start with the API:
-
10.13"Live updates arrive while the user is scrolled into the feed. What do you do?"
- Buffer inserts behind a "N new posts" banner and keep scroll anchored; only auto-insert when the user is at the top.
- Patch entities by id in a normalized store so unrelated rows don't re-render.
- Handle sequence numbers, reconnect deltas, and dirty local fields — those three are what separate a real implementation from a demo.
-
10.14"Design live chat for a stream with 500k viewers."
- Client side: buffer and flush on a frame, cap the window, virtualize, and pin to bottom only when the user is already there.
- Transport: SSE or WebSocket per viewer, fanned out from a pub/sub layer — and at extreme volume the server samples messages rather than sending all of them.
- Say the quiet part: nobody can read 300 messages a second, so sampling and "chat paused" are features, not degradations.
-
10.15"Build an autocomplete. What are the failure modes?"
- The race: an earlier slow request landing after a later fast one — fix with
AbortControllerand a stale-response check. - The traffic: no debounce and no minimum length means a request per keystroke.
- The accessibility: it's a
comboboxwitharia-activedescendant, so focus stays in the input while arrows move the selection — most implementations get this wrong.
- The race: an earlier slow request landing after a later fast one — fix with