Chapter 10 · Low Level Design
Revision sheet
Every lesson's idea and recap on one page. Read it before an interview, or print it.
-
10.1Component Design
Design the props API before the implementation — the API is the part you can't change later.
- Write the call site before the implementation; the API outlives the internals.
- Variants over booleans, slots over props, controlled and uncontrolled.
- Loading, empty, error, success belong in the component, not in every consumer.
-
10.2Config Driven UI
The server sends JSON describing the screen, and the client renders whatever it's told.
- Config describes arrangement; code provides capability.
- Unknown types must degrade silently — that's what makes old clients safe.
- Validate and version the config, or you've moved your bugs to a CMS.
-
10.3Shimmer UI
Show the shape of the content while it loads — perceived speed improves even though nothing got faster.
- Skeletons buy perceived speed and protect CLS by reserving exact space.
- Delay the loader ~300ms; never flash it.
- Reduced motion and screen-reader handling are part of the component, not extras.
-
10.4Routing & Protected Routes
A route table plus a guard that knows three answers: yes, no, and not yet.
- Routes as data, guards on subtrees, code-split per route.
- The third state — loading — is what separates a working guard from a flickering one.
- Client-side route protection is UX; the API is the actual boundary.
-
10.5State Management + Libraries
Pick the library by re-render behaviour and team size, once you've classified the state correctly.
- Classify the state first; the library question is smaller than it looks.
- Context re-renders every consumer; selector stores re-render one.
- Store the source, derive everything else.
-
10.6Multi Language Support
Keys not sentences, one locale bundle at a time, and a layout that survives text growing 35%.
- Keys by meaning, plurals by library, formatting by
Intl. - Design for +35% text and RTL from the start; retrofitting either is expensive.
- Pseudo-localise early — it finds the bugs before translation does.
- Keys by meaning, plurals by library, formatting by
-
10.7Infinite Scroll
A sentinel element triggers the next page, and virtualization stops the DOM from growing forever.
IntersectionObserveron a sentinel withrootMargin, guarded against double-firing.- Virtualize once lists get long — that's the actual scaling limit.
- Cursor pagination, scroll restoration, and a keyboard alternative are what separate a demo from a feature.
-
10.8Accordion
A list of disclosure toggles — trivial to render, and a complete accessibility contract to get right.
- Mode decides the state shape — ask before coding.
- Button-in-heading plus
aria-expanded/aria-controlsis the whole contract. <details>is free and correct when you don't need custom animation.
-
10.9Nested Comments
A recursive tree render over a flat, normalized store — with a depth cap so it stays usable.
- Flat, normalized storage; tree derived and memoised at render.
- Recursion needs a base case and a depth cap.
- Collapse hides the subtree; nested lists give a11y depth for free.
-
10.10Image Slider
One transform on a track, plus autoplay, swipe, preload, and the accessibility everyone forgets.
- Move one track with
transform; never animate layout properties. - Preload neighbours, lazy-load the rest.
- Autoplay without pause controls is an accessibility failure, not a feature.
- Move one track with
-
10.11Pagination Part-1
Offset is simple and drifts; cursor is stable and can't jump to page 7 — pick by what the data does.
- Offset drifts under inserts and gets slower with depth; cursor is stable and constant-cost.
- Always sort by (value, unique id) so page boundaries are deterministic.
- Page state belongs in the URL; the next lesson builds the component.
-
10.12Pagination Part-2
Build it: URL-driven state, an ellipsis page range, and a keyboard-accessible nav element.
- URL is the source of truth for page, size, sort, and filters.
- A pure range function keeps the ellipsis logic testable and the control stable.
- Dim old rows instead of blanking the table while the next page loads.
-
10.13Real-Time Updates
Merge live events into rendered lists without losing the user's place or their scroll position.
- Sequence numbers make out-of-order and duplicate events harmless.
- Buffer inserts; never move content under someone who's reading.
- Batch renders per frame — the UI is the bottleneck, not the socket.
-
10.14YouTube Live Stream Chat UI
Hundreds of messages a second into a fixed-size window — buffer, cap, virtualize, and pin to bottom carefully.
- Buffer in a ref, flush on a tick — one render per frame, not per message.
- Bound the window; memory must not scale with stream duration.
- Auto-scroll is conditional on the user already being at the bottom.
-
10.15Autocomplete & Search Bar
Debounce, cancel, cache, and keyboard-navigate — the most-asked LLD question, and the most detail-rich.
- Debounce, minimum length, abort, and discard stale responses — all four.
- Cache by query so backspace is free.
- It's a combobox: arrows move the active option, focus never leaves the input.
Capstone
Build any three of these in 45 minutes each, out loud: state the API first, handle loading/empty/error, then optimise.