Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Frontend System Design Roadmap
  1. 1.HTTP/1.1 vs HTTP/2 vs HTTP/3 (QUIC)
  2. 2.TCP and TLS Handshakes: Connection Setup Costs
  3. 3.Browser Network Stack and Connection Pooling
  4. 4.GET vs POST and Idempotency in HTTP
  5. 5.The Critical Rendering Path (CRP)
  6. 6.DOM, CSSOM and the Render Tree
  7. 7.Layout, Paint and Compositing
  8. 8.Reflows and Repaints Explained
  9. 9.Event Loop: Call Stack, Task and Microtask Queues
  10. 10.Async JavaScript: Promises and async/await
  11. 11.Web Workers: Multi-threading in the Browser
  12. 12.Browser Storage: Cookies, Web Storage, IndexedDB
  13. 13.Client-Side Storage: Limits and Security Risks
  14. 14.Choosing the Right Client-Side Storage
  15. 15.HTTP Caching: Cache-Control, ETag, Last-Modified
  16. 16.Browser-Level Caching Mechanisms
  17. 17.Cache Invalidation for Frontend Apps
  18. 18.Structuring a Large Single-Page App
  19. 19.Component-Based Architecture Principles
  20. 20.Props, State and Component Lifecycle
  21. 21.Module Bundling Basics
  22. 22.Core Web Vitals: LCP, INP and CLS
  23. 23.FCP and Time to Interactive (TTI) Explained
  24. 24.Measuring Performance: Lighthouse and WebPageTest
  25. 25.Asset Compression and Minification Basics
  26. 26.What Is a CDN and How Does It Work?
  27. 27.CDN Benefits: Latency, Availability, Offload
  28. 28.CDN Cache Behavior and Invalidation
  29. 29.Global State vs Local Component State
  30. 30.State Patterns: Redux, Zustand and Context
  31. 31.Data Fetching: React Query and SWR
  32. 32.Immutable Data in Frontend State
  33. 33.SSR vs CSR: Rendering Trade-offs
  34. 34.Hydration and Time to First Byte (TTFB)
  35. 35.Static Site Generation (SSG) for Speed and SEO
  36. 36.Incremental Static Regeneration (ISR)
  37. 37.Micro-Frontends: Core Principles
  38. 38.Micro-Frontend Integration Strategies
  39. 39.Communication Between Micro-Frontends
  40. 40.Micro-Frontends: Pros and Cons for Large Teams
  41. 41.Real-Time: Polling, SSE and WebSockets
  42. 42.Real-Time Use Cases: Chat, Alerts, Live Data
  43. 43.Designing a Real-Time Data Flow
  44. 44.Scaling WebSocket Connections
  45. 45.Responsive Images: srcset, sizes and picture
  46. 46.Modern Image Formats: WebP, AVIF, JPEG XL
  47. 47.Lazy Loading Images and Videos
  48. 48.Video Streaming: HLS, DASH, Adaptive Bitrate
  49. 49.REST and GraphQL for Frontend Engineers
  50. 50.Batching, Throttling and Debouncing API Calls
  51. 51.Handling API Errors in the Frontend
  52. 52.Authentication Flows: OAuth and JWT
  53. 53.Global Error Boundaries in React
  54. 54.Error Reporting: Sentry and LogRocket
  55. 55.Graceful Degradation and Fallback UIs
  56. 56.Real User Monitoring (RUM)
  57. 57.CORS: Cross-Origin Resource Sharing
  58. 58.Preventing XSS (Cross-Site Scripting)
  59. 59.CSRF Protection for Frontend Apps
  60. 60.Content Security Policy (CSP)
  61. 61.Storing Auth Tokens: Cookies vs localStorage
  62. 62.PWA Manifest and Installability
  63. 63.Service Workers: Lifecycle and Caching Strategies
  64. 64.Offline Support and Background Sync
  65. 65.Push Notifications for Web Apps
  66. 66.Webpack vs Vite vs Parcel
  67. 67.Code Splitting, Tree Shaking, Asset Optimization
  68. 68.Module Resolution and Hot Module Replacement
  69. 69.Monorepo Tooling: Nx and Lerna
  70. 70.Atomic Design for Component Libraries
  71. 71.Theming and Customization in Design Systems
  72. 72.Accessibility in Component Libraries
  73. 73.Component Library Docs, Testing and Versioning
  74. 74.Publishing and Consuming a Component Library
  75. 75.Full-Text Search: Levenshtein and Fuzzy Matching
  76. 76.Indexing Large Datasets in the Browser
  77. 77.Search Performance: Debouncing and Web Workers
  78. 78.Integrating Backend Search Services
  79. 79.Choosing a Chart Library: D3, Chart.js, Recharts
  80. 80.Rendering Large Datasets: Canvas vs SVG
  81. 81.Interactive, Responsive Data Visualizations
  82. 82.Data Fetching and Aggregation for Dashboards
  83. 83.A/B Test Design and Rollout Strategies
  84. 84.Client-Side vs Server-Side A/B Testing
  85. 85.Feature Flags and Remote Configuration
  86. 86.Experiment Data Collection and Analytics
Frontend System Design Roadmap
19

Frontend System Design · Lesson 19 of 86 · 4 min

Component-Based Architecture Principles

This is how you explain breaking down a UI without sounding like you just read a textbook.

In a frontend system design interview, you will be asked to break down a complex UI into smaller pieces. Your ability to justify where you draw the lines between components reveals your seniority. This lesson is about drawing those lines effectively.

How to Decompose a UI

Your first move is always to partition the interface. Look at the mock or the requirements and draw boxes. Each box is a potential component. The guiding rule for drawing these boxes is the Single Responsibility Principle (SRP).

A component should do one thing. "One thing" means one primary job or reason to change. A DatePicker component's job is to select a date. A UserAvatar component's job is to display a user's image. If you find yourself naming a component UserProfileAndSettingsForm, it's doing too much. Split it.

This decomposition creates a component tree, a hierarchy with a single root component (often called App) at the top.

The trap: Candidates often draw too few boxes. They'll describe a "feed page" as one giant component that fetches data, renders a list, handles infinite scroll, and manages the state for each item. This is a red flag. A senior engineer sees a FeedPage container, which holds a FeedList, which renders multiple FeedItem components, each of which might use an Avatar, LikeButton, and CommentInput. Show that you can see the smaller, reusable parts.

Defining a Component's Public API

Once you've identified a component, you must define its contract with the outside world. This contract is its public API, consisting of its inputs and outputs. Everything else is an implementation detail.

Inputs are how a parent component passes data and configuration down. In React, these are props. In Angular, @Input() decorators.

Outputs are how a component communicates events up to its parent. This is typically done with function props or callbacks (onClick in React) or event emitters (@Output() in Angular).

A well-defined API makes a component reusable and predictable. You can swap out its internal logic or styling, and as long as the API remains the same, the rest of the application won't break. This is encapsulation.

This Button component has a clear API. Its inputs are label, onClick, and an optional variant. Its output is the call to the onClick function. The internal class name logic is a private detail.

// components/Button.tsx
import React from 'react';

interface ButtonProps {
  label: string;
  onClick: () => void;
  variant?: 'primary' | 'secondary';
}

const Button: React.FC<ButtonProps> = ({ label, onClick, variant = 'primary' }) => {
  const buttonClasses = `px-4 py-2 rounded ${
    variant === 'primary' ? 'bg-blue-500 text-white' : 'bg-gray-200 text-gray-800'
  }`;

  return (
    <button className={buttonClasses} onClick={onClick}>
      {label}
    </button>
  );
};

export default Button;

Prefer Composition to Configuration

A common junior pattern is to create components with dozens of boolean props for configuration: showIcon, isRound, hasBorder, useDangerColor. This creates a rigid component that is hard to extend.

A better approach is composition. Instead of adding more props, design components to accept and render other components. In React, the children prop is the primary mechanism for this.

Configuration (brittle): A Card component with props like withHeader, withImage, imagePosition. What happens when you need a video instead of an image? You add another prop, withVideo. This is not scalable.

Composition (flexible): A Card component that simply renders whatever you pass to it.

// components/Card.tsx
import React from 'react';

interface CardProps {
  children: React.ReactNode;
}

const Card: React.FC<CardProps> = ({ children }) => {
  return <div className="border rounded-lg shadow p-4">{children}</div>;
};

// Usage:
// <Card>
//   <img src="..." alt="..." />
//   <h2>Card Title</h2>
//   <p>Some descriptive text.</p>
//   <Button label="Click Me" onClick={() => {}} />
// </Card>

The parent component now has full control over the card's content and layout, using other standard components. The Card itself does one thing: it provides a styled container.

In an interview, suggesting a compositional API for a component like a Modal, Card, or Layout demonstrates a mature understanding of building flexible design systems.

The Trade-offs of Granularity

How small is too small? The answer depends on reusability and complexity.

Over-atomization is a common mistake. If you break components down too far, you end up with a mess of tiny files that do almost nothing, and you spend all your time wiring them together. This often leads to "prop drilling," where you pass a prop through five layers of components just to get it to a deeply nested child that needs it.

Under-atomization results in monolithic "god components" that are impossible to test, reuse, or reason about.

A good heuristic: if a piece of UI has its own distinct state, has a complex internal structure, or is used in more than two places, it's a strong candidate for its own component. If it's just a div with a class name, it's probably not.

Prop drilling isn't always a mistake, but it's a signal. If you're passing the same prop through more than two or three layers, you should question your component boundaries. It might be a sign that a child component needs to be pulled up a level, or that you need a state management solution.

Try it

Take a screenshot of a complex UI, like the Twitter/X feed or the Amazon product detail page. Open it in an image editor and draw boxes around the elements you would break into components. Name each component and draw arrows to show the parent-child hierarchy. Spend 15 minutes justifying your decisions based on the principles of SRP, reusability, and composition.

Next: We'll look at the data that flows through these components in Props, State and Component Lifecycle.

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

Structuring a Large Single-Page App

Next

Props, State and Component Lifecycle