A good beginning is half the battle won. By using the RADIO framework to answer front end system design questions, you will already be much closer to acing your interview.
In the context of front end system design interviews, the systems you are asked to design tend to be products, so we'll refer to the system as "product" from here on. Start by understanding the Requirements, defining the high level Architecture and the Data Model. Then define the Interfaces between the components in the product and talk about any Optimizations or dive deep into specific areas which require special attention.
Objective: Understand the problem thoroughly and determine the scope by asking a number of clarifying questions.
Recommended Duration: Not more than 15% of the session.
System design interview questions are open-ended in nature and are usually vague and under-specified on purpose. You are required to dig deeper and clarify ambiguities in the problem by asking useful questions. Treat your interviewer as a product manager you are working with on a new project, ask enough questions so that you know what problems you are trying to solve and what you need to build. In reality, some problems can be solved without any engineering at all!
No two system design interview experiences are the same even though you can be asked the same question. Interviewers have different backgrounds and might prioritize different aspects of the system. Take this chance to find out what they are most interested in and plan your answers accordingly.
Some general questions you should get answers to before moving on to the next part of the interview:
Imagine you were asked to "Design Facebook". Facebook is a huge platform, there's news feed, profiles, friends, groups, stories, and more. Which parts of Facebook should you focus on? The interviewer has the answer in mind but wants you to find out by asking questions. Typically you should focus on the most unique aspects of the product, the features which define it. For Facebook, it would be the news feed, pagination of the feed, and creating new posts. For YouTube, it would be the video-watching experience. The important areas for other type of products be found in the types of questions.
For the rest of this page, we'll be using "Design Facebook" as the problem and apply the framework to it.
Let's assume you didn't clarify which parts of the product to focus on, assumed you should talk about the befriending flow and started talking about it. In the best case, good interviewers will steer you back in the direction the question was meant to proceed, but they will make a mental note that you didn't clarify the question. In the worst case, inexperienced interviewers will let you keep talking and politely try to find an opportunity to correct you, but you would have already wasted some precious minutes discussing an unimportant topic.
Firstly, what are functional and non-functional requirements?
There are two ways you can get the answer to this question:
At the very minimum, your design has to meet the functional requirements. After meeting all the function requirements, move on to talk about how to fulfill the non-functional requirements.
Even after you know the functional requirements, there can still be a ton of small features that make up the large feature. For example, when creating new Facebook posts, what kind of post formats should be supported? Besides the usual text-based posts, should the user be able to upload photos, upload videos, create polls, check in to a location, etc.
You should clarify the core features beforehand and design for them before moving on to the extra features.
The list above should give you a good starting list of questions but it is not an exhaustive list! Different problems will require you to ask domain-specific questions, which we will talk about in the case studies.
You are recommended to write down the agreed requirements somewhere so that you can refer to them throughout the interview and ensure that you've covered them.
Objective: Identify the key components of the product and how they are related to each other.
Recommended Duration: Roughly 20% of the session.
With the requirements in mind, we can move on to the architecture design proper. Your next task is to come up with a product/system architecture by identifying the key components of the product, how the components interact with each other, and how they are related. Remember to focus on the client-side architecture, not the back end.
Diagrams are your friends here. Each component can be represented using a rectangle and your high-level design usually ends up looking like a few rectangular boxes with arrows between them to demonstrate the flow of data. It is also possible to have components within components, in that case, draw the parent using bigger rectangles since they need to fit multiple subcomponents.
Examples of components/modules which are commonly found in a high-level front end design:
Other things to consider when defining the responsibilities of components:
It is important to realize that not every common component mentioned above will be relevant and needed for every question, it depends on the product.
After drawing out the architecture diagram, verbally describe the responsibilities of each component (box in the diagram).
Here's an example architecture diagram for the News Feed question drawn using Excalidraw.
Common free drawing tools that you might be asked to use include diagrams.net and Excalidraw. It'd be a good idea to familiarize yourself with these tools beforehand.
Objective: Describe the various data entities, the fields they contain and which component(s) they belong to.
Recommended Duration: Roughly 10% of the session.
We now have to think about what data fields are present in the client. There are two kinds of data on client applications:
Data that originates from the server, usually from a database and meant to be seen by multiple people or accessed from multiple different devices. Common examples include user data (name, profile picture) and user-generated data (feed posts, comments).
Client-only data, also commonly known as state, is data that only needs to live on the client and does not have to be sent to the server for writing into the database. Client data can be further broken down into two:
When listing the data fields, it'd be useful to identify what kind of data that field is, whether it's server-originated data or client-only data.
Here's a basic example of data model for the various entities using the News Feed question.
Source | Entity | Belongs To | Fields |
---|---|---|---|
Server | Post | Feed Post | id , created_time , content , image , author (a User ), reactions |
Server | Feed | Feed UI | posts (list of Post s), pagination (pagination metadata) |
Server | User | Client Store | id , name , profile_photo_url |
User input (client) | NewPost | Feed Composer UI | message , image |
Depending on how far you progress along in the question and how the requirements have evolved and grown during the interview, you might need to add more fields. It's a dynamic and iterative process.
You might want to write these fields near the components which owns them in your architecture diagram.
Objective: Define the interface between components in the product, functionality of the various APIs, their parameters and responses.
Recommended Duration: Roughly 15% of the session.
With the components and data within each components, we can move on to discuss the interface (APIs) between the components. API is an overloaded term and generally refer to the protocol which software components communicate and request/send data between components. Client and server communicate via network layer APIs (HTTP/WebSockets). Client components generally communicate via functions in the browser runtime. All APIs have three things in common whether they are between the server and the client or between client components:
Parts of an API | Server-Client | Client-Client |
---|---|---|
Name and functionality | HTTP path | JavaScript function |
Parameters | HTTP GET query and POST parameters | Function parameters |
Return Value | HTTP response, typically JSON format | Function return value |
Using the News Feed example yet again, we have a server API that allows the client to fetch the latest feed posts.
Field | Value |
---|---|
HTTP Method | GET |
Path | /feed |
Description | Fetches the feed results for a user. |
A feed response is a paginated list so the API expects pagination parameters.
{"size": 10,"cursor": "=dXNlcjpXMDdRQ1JQQTQ"}
{"pagination": {"size": 10,"next_cursor": "=dXNlcjpVMEc5V0ZYTlo"},"results": [{"id": "123","author": {"id": "456","name": "John Doe"},"content": "Hello world","image": "https://www.example.com/feed-images.jpg","reactions": {"likes": 20,"haha": 15},"created_time": 1620639583}// ... More posts.]}
The client-client API can be written in a similar fashion as the server-client API, main difference being they are JavaScript functions, or events that are being listened to. The most important parts to describe are the functionality of the API, the parameters and the return/response value.
If you're asked to design a UI component, for the "Interface" section, discuss about the customization options for the component, similar to the props for React components.
Objective: Discuss about possible optimization opportunities and specific areas of interest when building the product.
Recommended Duration: Roughly 40% of the session.
There's no fixed way to go about the optimization and deep dive section and you are free to focus on different areas of the product. There will not be sufficient time to cover every area, so select how you want to spend your time carefully according to these guidelines:
Here's a list of topics you can talk about for this section. Bear in mind that the importance of a topic depends on the question and some topics are entirely irrelevant to certain questions (possible but unlikely).
Refer to our Best Practices for Building User Interfaces Guide for details on each topic.
Step | Objective | Recommended Duration |
---|---|---|
Requirements Exploration | Understand the problem thoroughly and determine the scope by asking a number of clarifying questions. | <15% |
Architecture/High-level Design | Identify the key components of the product and how they are related to each other. | ~20% |
Data Model | Describe the various data entities, the fields they contain and which component(s) they belong to. | ~10% |
Interface Definition | Define the interface (API) between components in the product, functionality of each APIs, their parameters and responses. | ~15% |
Optimizations and Deep Dive | Discuss about possible optimization opportunities and specific areas of interest when building the product. | ~40% |