0%
Frontend System Design Interviews: Components, Rendering, State, Caching and Performance
Component Architecture
Once requirements and a rough wireframe are on the board, the next step is the client architecture, and its centre is the component tree. A component tree is a hierarchy of interface pieces, each of which renders part of the screen and owns a clear responsibility. Interviewers use the tree to judge whether your client would actually work and whether a team could build it in parallel. A good tree is not the largest or most detailed one; it is the one where every box has a reason, every responsibility has an owner and one interaction can be traced through it from start to finish.
This lesson covers how to build and present the tree, how to split components by responsibility, how to design their interfaces, how shared components and design systems fit in and how large codebases are divided between teams. State management and rendering strategies each have their own lessons; here they appear only where they shape the tree.
From wireframe regions to a tree
The fastest way to a sensible tree is to start from the wireframe. Each major region becomes a top level component under an application root: a Header, a Feed, a Sidebar, a Composer. Inside each region, look for the repeated unit, such as a FeedItem for each post, and for interactive pieces that deserve their own component, such as a LikeButton, a CommentCount or an ImageGrid. Stop when the next level down would only describe styling.
For an interview, two or three levels are usually enough. The root and the routed page; the major regions; the repeated row and its most interesting children. Drawing every button would take time and tell the interviewer nothing new. Draw the levels where decisions happen: which component fetches, which holds state, which repeats hundreds of times.
What each component owns
For each component on the tree, be able to say in one sentence what it owns. Ownership has three parts: what it renders, what state it holds, if any, and what it talks to, such as the data layer, a router or a real time connection. The Feed owns the list of post IDs for the current view, asks the data layer for pages and decides when to request more. The FeedItem owns nothing but presentation of one post and the local state of whether its menu is open. The LikeButton owns the visual state of the button and reports clicks.
When two components seem to own the same thing, the design is unclear. If both the Feed and the FeedItem fetch post details, which one is the source of truth after a like? Settle it in the tree: the data layer owns post data, the Feed owns which posts are shown and the FeedItem reads one post by ID. Clear ownership is what makes the trace through the tree possible.
Breadth, depth and the cost of the tree shape
Tree shape has real costs. A very deep tree with many layers of wrappers makes data passing awkward, because props have to travel through components that do not use them, and it makes debugging harder because one visual element is the product of many files. A very flat tree with huge components mixes responsibilities, so a change to one feature risks breaking another, and the component re-renders as a whole when any of its many pieces changes.
A useful rule of thumb is that a component should fit on a screen or two of code, have one reason to change and be nameable with a noun the product team would recognise. When a component has several unrelated reasons to change, such as layout, data fetching and a complex form, split it. When a wrapper only passes props through and adds nothing, merge it into its parent.
Where state sits shapes what re-renders
In React and frameworks that follow its model, when a component's state changes, that component re-renders, and by default so do its children. Fine grained frameworks such as Solid, Svelte and Vue update more narrowly, but state placement still sets the scope. This means the position of state on the tree decides how much work each update causes. If the like state for every post lives at the top of the Feed, a single like can cause every row to re-render. If each row owns or subscribes to its own post's state, a like re-renders one row.
The general rule is to keep state as close as possible to the components that use it and lift it only as high as the nearest common parent of everything that needs it. Server data shared across screens is a special case handled by a data layer with fine grained subscriptions, which the state and data fetching lessons cover in detail. For the tree, the point is that you should be able to look at the drawing and say where each important piece of state lives and what a change to it re-renders.
Tracing an interaction through the tree
The strongest evidence for a tree is a trace. Pick the most important interaction, such as liking a post, and walk it through. The user taps the LikeButton. The button calls an onToggle callback it received from the FeedItem. The FeedItem calls the data layer's like action with the post ID. The data layer updates the cached post optimistically and sends the request. Every component subscribed to that post, the FeedItem in the feed and the detail page if it is mounted, re-renders with the new count. If the request fails, the data layer restores the previous value and the interface shows an error.
A trace like this takes about a minute. It proves that events reach the right owner, that data has one source of truth and that the update reaches every place that shows the post. It also often reveals a gap, such as a component that needs data but has no path to it, which you can fix on the spot.
Drawing the tree in the interview
Practical layout matters. Draw the root at the top and grow downward. Label each box with a component name and, underneath in smaller text, what it owns. Draw the data layer and other non visual modules, such as the router, an API client and a real time connection manager, as separate boxes to the side, and connect only the components that talk to them. Mark repeated components with a small note such as one per post, because repetition is where performance decisions live.
On a shared online whiteboard, an indented text outline is often faster than shapes and just as clear.
An outline like this is easy to edit as the conversation evolves, and it carries ownership notes that a box diagram often leaves out.
What the interviewer is checking
The interviewer checks whether each box has a clear job, whether state and data have obvious owners, whether repetition and heavy regions are identified and whether you can connect the tree to the requirements. A tree that cannot explain how a like on one screen appears on another is a drawing. A tree with ownership notes and a trace is a design.
Non visual modules on the diagram
Not everything in the client is a component. A complete architecture also shows the modules that have no pixels: the router that maps URLs to pages, the data layer that fetches and caches, an API client that adds authentication and retries, a real time connection manager and an analytics or logging module. Draw them beside the tree rather than inside it, and connect each one only to the components that use it. If every component connects to the data layer, the drawing is telling you that data access is scattered and should be gathered into a few feature level owners.
For every box on the tree, be ready to say what it renders, what state it holds and what it talks to. If you cannot say it in one sentence, the component probably has two jobs and should be split, or it has none and should be merged.