Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Frontend System Design Fundamentals
  1. 1.Introduction to Frontend System Design
  2. 2.Core Frontend Architecture Concepts
  3. 3.Client-Server Interaction Fundamentals
  4. 4.Basic Performance & Accessibility Considerations
  5. 5.State Management Basics & Data Flow
  6. 6.Advanced State Management & Global Stores
  7. 7.Component Libraries & Design Systems
  8. 8.Frontend Build Tools & Development Workflows
  9. 9.Advanced Performance Optimization Techniques
  10. 10.Data Fetching Strategies & Caching
  11. 11.Frontend Security Essentials
  12. 12.Micro-Frontend Architectures
  13. 13.Real-time Communication & WebSockets
  14. 14.Observability, Monitoring, & Logging
  15. 15.Offline-First & Progressive Web Apps (PWAs)
Frontend System Design Fundamentals
03

Frontend System Design · Lesson 3 of 15 · 3 min

Client-Server Interaction Fundamentals

How you explain the request-response cycle shows an interviewer if you understand the web.

In a system design interview, you will be asked to describe how the frontend talks to the backend. Your answer must be precise. This isn't about reciting definitions; it's about demonstrating you can build a reliable user interface on top of a network.

The Core Loop: Request and Response

Every dynamic web application is built on a simple loop: the client requests something, and the server responds. This is the request-response cycle.

The client is the browser. The server is a machine listening for requests. They speak a common language, a protocol, which is almost always HTTP (or its secure version, HTTPS).

A key feature of HTTP is that it's stateless. The server forgets everything about the client after each response. This is a good thing. It allows any server in a cluster to handle any request, which makes scaling much easier.

As a frontend engineer, this means the burden of maintaining user state falls to you. You'll use tokens in headers, cookies, or browser storage to remind the server who the user is with every single request. Being able to explain this trade-off—server scalability vs. client-side state management—is a sign of seniority.

Defining the Contract with an API

An API (Application Programming Interface) is the contract that defines how the client can talk to the server. For frontend, this usually means a web API that exposes data and functionality over HTTP.

You need to know the two dominant styles:

  1. REST (Representational State Transfer): An architectural style where you interact with resources at specific URLs (endpoints). You use standard HTTP methods like GET /users/123 to fetch data or POST /users to create a new one. It's predictable and leverages the web's existing infrastructure.

  2. GraphQL: A query language for your API. Instead of multiple endpoints, you typically have one (/graphql). The client sends a query specifying the exact data it needs, and the server returns a JSON object matching that shape. This solves the common REST problem of over-fetching (getting more data than needed) or under-fetching (needing to make multiple requests).

The trap: Don't just say "GraphQL is better because it prevents over-fetching." Acknowledge the trade-offs. GraphQL adds complexity to the server (resolving queries) and client (caching, tooling). REST is often simpler for basic CRUD applications. Show you know when to use which.

Writing Fetch Logic That Doesn't Break

Your code is how you prove you understand the theory. You must be able to write an API call that correctly handles success, server errors, and network failures. A "happy path" example is not enough.

This function to create a resource is what a robust implementation looks like. It handles headers, the request body, and two distinct types of errors.

async function createPost(postData: { title: string; body: string; userId: number }) {
  try {
    const response = await fetch('https://jsonplaceholder.typicode.com/posts', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(postData),
    });

    // This block handles HTTP errors (e.g., 404, 500).
    // The `fetch` promise only rejects on network failure.
    if (!response.ok) {
      // You might parse an error message from the body if the API provides one.
      throw new Error(`HTTP error! Status: ${response.status}`);
    }

    const createdPost = await response.json();
    console.log('Post created:', createdPost);
    return createdPost;
  } catch (error) {
    // This block handles network errors (e.g., DNS, no connection)
    // or the error thrown from the `!response.ok` check.
    console.error('Failed to create post:', error);
    // In a real app, you would update the UI to show an error state.
    throw error; // Re-throw to allow the caller to handle it.
  }
}

The trap: Forgetting that fetch does not reject on HTTP error statuses. A 404 Not Found or 500 Internal Server Error will still resolve the promise. You must check response.ok or the response.status to know if the request was successful from the server's perspective. Many candidates miss this.

Diagramming the Interaction

In a system design interview, you'll draw boxes and arrows. A sequence diagram is a clear way to show the client-server interaction over time. It makes abstract concepts concrete.

This diagram shows a common flow: the browser first requests the web page, then makes a separate API call to fetch dynamic data and render it.

This shows you understand the separation of concerns: a web server might serve the static assets (the application shell), while a distinct API server handles the data logic.

Try it

Use a public API like JSONPlaceholder to write a single function that updates a resource using a PUT or PATCH request. Your function must handle and log three distinct outcomes: a successful update, a "not found" (404) error, and a network failure.

Next: We'll cover what you need to know about performance and accessibility in Basic Performance & Accessibility Considerations.

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

Core Frontend Architecture Concepts

Next

Basic Performance & Accessibility Considerations