Basics

Architecture

Learn how to plan client-side architecture in frontend system design interviews

Building Scalable Frontend Systems

Welcome to the most crucial part of a frontend system design interview — laying out the architecture of your application.

This phase is your chance to show how you'd organize your components, manage data flow, and build a scalable, maintainable frontend system.

⏱Spend about 20–30% of your interview time here. Start with a high-level design early, then revisit and refine it as new features and edge cases come up.


What Does Architecture Mean Here?

When we talk about architecture in frontend interviews, we're usually referring to the client-side component structure, data flow, and how you separate concerns like UI, state, and business logic.

This isn't about database schemas or Kubernetes clusters — it's about how the UI is built and connected.


🔍 Step-by-Step Breakdown

Let's walk through how to approach this section clearly and confidently.

1. Identify Key Components

Start by identifying the main components of the UI based on the product's requirements. For example, in a booking app like Airbnb, you might have:

  • A navigation bar
  • A search form
  • A list of bookings
  • A booking detail card
  • A user profile dropdown

Think of components in terms of both containers (smart components that fetch data and manage state) and presentational components (dumb components that only render UI).


2. Plan the Data Flow

For each component, ask:

  • Where does the data come from?
  • Does it rely on global state or fetch its own data?
  • How does it communicate with other components?

Use techniques like:

  • Props for top-down communication
  • Context / Zustand / Redux for shared state
  • Event callbacks or custom hooks to bridge gaps

3. Define Your Layers (MVVM / MVC)

You don't need to commit to one rigid architecture, but having a clear mental model helps.

  • MVVM (Model-View-ViewModel) is great for React apps with hooks, contexts, and async logic.
  • MVC (Model-View-Controller) can work well if you prefer separating user input logic from rendering and data models.

The exact pattern matters less than your ability to explain why you chose it and how it helps with clarity, testability, and scaling.


Diagramming Your Architecture

Interviewers love visual thinking. Even if you're not drawing, describe your architecture as if you were sketching it on a whiteboard.

Here's what to include:

  • Component hierarchy
  • Data flow (who owns the state, where props go)
  • How components interact (hooks, context, lifting state, etc.)
  • Network/API calls (where they happen and who consumes them)

Tools to practice with:


Treat Backend as a Black Box

You can safely assume there's a backend exposing APIs. You don't need to design the backend, but you should:

  • Define what APIs you'll call and from where
  • Discuss handling loading/error states
  • Mention optimistic updates if relevant

Only go deeper into backend design if explicitly asked — or if you're in a full-stack round.


Layered Architecture Examples

Let's look at two common frontend architecture patterns through examples.


MVVM Pattern

  • Model (M):

    • Defines what your data is (structure, rules, validation).
    • Example: User { id, name, email }.
  • ViewModel (VM):

    • Middleman between Model & View.
    • Talks to Model (fetch API / DB).
    • Holds state (like useState, useReducer).
    • Formats data so View can consume it easily.
  • View (V):

    • Just UI.
    • Subscribes to ViewModel state.
    • Renders whatever ViewModel provides.

MVVM Example in React

// Model.js
export class UserModel {
  constructor(id, name, email) {
    this.id = id;
    this.name = name;
    this.email = email;
  }
}

// useUserViewModel.js (ViewModel)
import { useState, useEffect } from 'react';
import { UserModel } from './Model';

export function useUserViewModel() {
  const [user, setUser] = useState(null);

  useEffect(() => {
    async function fetchUser() {
      const res = await fetch("https://jsonplaceholder.typicode.com/users/1");
      const data = await res.json();
      setUser(new UserModel(data.id, data.name, data.email));
    }
    fetchUser();
  }, []);

  return { user };
}

// View.jsx
import React from 'react';
import { useUserViewModel } from './useUserViewModel';

export default function UserView() {
  const { user } = useUserViewModel();

  if (!user) return <p>Loading...</p>;

  return (
    <div>
      <h2>{user.name}</h2>
      <p>{user.email}</p>
    </div>
  );
}

Diagram of Flow

   [ Model ]  <-- raw data (API, DB, structure)

       │ fetch/transform

 [ ViewModel ] <-- manages state, formatting, logic

   [ View ]  <-- just shows data (UI)

Why it works:

  • Centralized logic
  • Clean separation of UI and behavior
  • Easy to test and scale

Key Architecture Decisions

1. Atomic Design

  • Atoms → basic UI (Button, Input)
  • Molecules → small groups (Form Field)
  • Organisms → sections (Navbar)
  • Templates / Pages → layout + content

2. Container / Presentational Pattern

  • Presentational → UI only (stateless, style-focused)
  • Container → handles state, data, logic
  • Widely used in React to separate logic from UI

3. Compound Components

  • Parent + Children → related components sharing state via context/props
  • Example: <Tabs> with <TabList> + <TabPanel>

🛠 Tips for Interviews

  • Don't freeze up if asked to revise your diagram. Iterate!
  • Be honest about tradeoffs. Every pattern has pros and cons.
  • Mention edge cases: loading states, error handling, retry logic.
  • Think aloud — show your reasoning process.

Practice Exercise

Try designing the following with either MVVM or MVC:

  • A YouTube-like video player page
  • A chat application
  • A calendar booking tool

Describe your high-level architecture, component hierarchy, data flow, and state management.


Up next, let's dive into Data Modeling — the "D" in R.A.D.I.O.

Next: Data Flow & State Management - Learn how to design efficient data flow patterns in your frontend application.