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
82

Frontend System Design · Lesson 82 of 86 · 5 min

Data Fetching and Aggregation for Dashboards

This is where you show you can balance real-time needs with performance, moving beyond simple fetch calls.

When you design a dashboard, you’re not just arranging charts. You're designing a data pipeline. The most important decisions happen before a single pixel is rendered: how you get the data, and in what shape. Get this wrong, and you build a dashboard that’s slow, brittle, and a drain on the backend.

Choose Your Data Transport: Push vs. Pull

Your first decision is how the client gets updates. This choice dictates the "liveness" of your dashboard and its architectural complexity.

Polling is the simplest approach: setInterval calling a fetch. It's stateless and easy to implement. This is fine for data that only needs to be fresh every 30 seconds or more, like a daily sales summary.

The trap: Using polling for truly real-time data. If you poll every 250ms for stock prices, you're creating massive network noise and your data will still have noticeable latency. Most requests will return no new data, wasting resources on both client and server. For high-frequency updates, polling is an anti-pattern.

Persistent connections like WebSockets or Server-Sent Events (SSE) are for when "now" really means now. The server pushes data to the client the moment it's available. This is mandatory for things like live monitoring, trading platforms, or real-time collaboration tools.

WebSockets offer a two-way channel, while SSE is a simpler one-way street from server to client. If the client doesn't need to talk back over the same pipe, SSE is less complex. GraphQL Subscriptions are an abstraction, usually over WebSockets, that let you tie into a GraphQL schema for real-time updates.

In an interview, frame this as a trade-off. "For the live user count, I'd use WebSockets for immediate updates. For the 'top articles this week' widget, simple polling every five minutes is more than enough and avoids the overhead of managing a persistent connection."

Decide Where to Aggregate: Client vs. Server

Raw data is rarely useful for a dashboard. You need sums, averages, or counts. The question is, where do you perform these calculations?

Backend aggregation is the default for any significant amount of data. The server, with its proximity to the database and greater computational power, should do the heavy lifting. It processes millions of events and sends a tiny JSON payload to the client: {"daily_active_users": 10523}. This minimizes payload size and offloads CPU work from the user's device.

Frontend aggregation has its place, but it's a niche one. Use it for small datasets (think dozens or a few hundred records) or for highly interactive UIs where the user can dynamically change how the data is grouped or summarized. For example, letting a user pivot a small table of data that's already on the client.

The trap: Fetching thousands of rows of raw data and then looping over them in JavaScript to compute a simple sum. This is a common junior mistake. It crushes browser performance, drains batteries on mobile, and creates a sluggish UI. If the raw data is more than a few megabytes, it almost certainly shouldn't be aggregated on the client.

Prevent Wasted Work with Caching and Deduplication

A dashboard often has multiple widgets that rely on the same underlying data. For example, a "Total Users" chart and a "New Users Today" chart might both be derived from the same user dataset. Firing off separate, identical requests for this data is inefficient.

The correct flow is to intercept data requests and check two things before hitting the network:

  1. Is a valid, fresh copy of this data already in the client cache?
  2. Is there already a request for this exact data in flight?

If the answer to either is yes, you use the existing data or subscribe to the pending request. You only make a new network request if the data is missing, stale, and not already being fetched.

Modern data-fetching libraries like TanStack Query (React Query) and SWR handle this for you. But you need to understand the principle. The key is memoizing the promise, not just the result.

Here is the core logic, stripped of any framework. This is the pattern that prevents a dozen components from all firing the same fetch at once during an initial render.

const inFlightRequests = new Map<string, Promise<any>>();

async function fetchDeduplicated(key: string, fetcher: () => Promise<any>) {
  // If a request for this key is already happening, return its promise.
  if (inFlightRequests.has(key)) {
    return inFlightRequests.get(key);
  }

  // No request in flight. Start a new one and store the promise.
  const promise = fetcher();
  inFlightRequests.set(key, promise);

  try {
    // Wait for the fetch to complete.
    return await promise;
  } finally {
    // Once done (success or fail), remove it so subsequent requests trigger a new fetch.
    inFlightRequests.delete(key);
  }
}

Structure the API for Efficient Fetching

How you shape your API endpoints has a massive impact on dashboard performance. You want to avoid both over-fetching (getting more data than you need) and under-fetching (the "N+1" problem, where you make one request for a list, then N subsequent requests for details).

A single monolithic endpoint that returns all data for the entire dashboard is a bad idea. It's hard to cache, and a change to one small part of the data requires refetching everything.

One endpoint per widget is better, but can lead to a waterfall of requests, delaying the final render.

The best solutions usually involve one of two patterns:

  1. GraphQL: This is the canonical solution. It allows the frontend to declare exactly what data it needs for all visible widgets in a single query. The server then returns a response tailored to that query. No over-fetching.

  2. Backend for Frontend (BFF): If you're not using GraphQL, you can create a dedicated API endpoint (a BFF) that acts as an aggregator. The dashboard makes one call to this BFF endpoint, which then calls multiple downstream microservices in parallel on the server-side and stitches the data together into a single response. This moves the request orchestration from the client to your own network, which is much faster.

Try it

Sketch out the data flow for a dashboard with three widgets: 'Active Users' (real-time), 'Sales this Week' (updated every minute), and 'User Demographics' (updated daily). For each, specify the fetching strategy (push/pull), aggregation location (client/server), and caching policy.

Next: We'll look at how to manage feature releases and experiments with A/B Test Design and Rollout Strategies.

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

Interactive, Responsive Data Visualizations

Next

A/B Test Design and Rollout Strategies