All categories

Category

System Design

Frontend architecture for scale, micro-frontends, modular apps.

99 questions

99 of 99
System Design
Easy
What does the term scalable web applications mean in your experience?

Scalability has three axes: (1) traffic — handling more concurrent users without degrading latency; (2) code — keeping a growing codebase maintainable as teams and features multiply; (3) operational — debugging, deploying, and observing the system without heroics. Scalable apps invest in module boundaries, code splitting, caching layers, telemetry, and CI gates well before they're 'needed'.

8 min
System Design
Hard
What are the fundamentals of frontend system design covering components, state, and performance?

Component structure: composition over inheritance, props down + events up, small focused components, design system primitives + domain compositions. State: local first (useState), lift only when shared, server state lives in a cache (React Query), global UI state in context or Zustand. Performance: SSR/SSG for first paint, code split per route, virtualize long lists, memoize on profiled-slow paths, lazy-load below fold, CDN + cache aggressively. Measure with RUM, set budgets in CI.

9 min
System Design
Hard
How do you approach a frontend whiteboard round covering APIs, data modeling, scalability, and trade offs?

A whiteboard architecture round tests structured design thinking under ambiguity. Approach: clarify scope and constraints, sketch a high-level architecture, drill into APIs and data model, name scaling bottlenecks, and discuss trade-offs explicitly. Stay at the right altitude, use the whiteboard as an anchor, and invite the interviewer to drive depth. The goal is to show how you think, not to ship a perfect design in 45 minutes.

8 min
System Design
Easy
What are the SOLID principles and how do they apply to frontend code?

Five OOP design principles: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion. They aim for maintainable, decoupled code. In frontend they map to: focused components/hooks, extension via props/composition, consistent contracts, minimal prop interfaces, and depending on abstractions.

5 min
System Design
Hard
How do pure functions help you write testable frontend code?

Pure functions are deterministic and side-effect-free: same inputs → same output, no I/O, no mutation of external state. They are trivially testable because they need no mocks, fixtures, or setup. Architecturally, the goal is to push impure code (fetch, DOM, time, randomness) to the edges and keep the core logic pure. This is the 'functional core, imperative shell' pattern that makes UIs predictable and refactorable.

7 min
System Design
Hard
What is component driven architecture and when would you use it?

Component-driven architecture builds UIs as compositions of small, independently developed, documented, and tested components. Build bottom-up: atoms → molecules → organisms → pages. Tools: Storybook for isolation + docs, design tokens for theming, a shared component library or design system. Benefits: reuse, consistency, parallel development, isolated testing. Costs: governance overhead, design-system maintenance, version coordination.

7 min
System Design
Easy
How do you design components for scalability and reuse across teams?

Scalability: code that survives growth in features, contributors, and data. Patterns: feature-folder structure, typed contracts at boundaries, small modules with single responsibilities, dependency direction (UI → domain → infra), monitoring, perf budgets, design-system tokens. Reuse: compose, don't configure; ship primitives + presets; document; favor narrow APIs over deep config.

5 min
System Design
Medium
How would you build a component library used by multiple teams?

Tree-shakable package with TypeScript types, accessible primitives (Radix-style headless + variants), tokens via CSS vars, semver + Changesets, Storybook + Chromatic, a11y + visual regression in CI, bundle-size budgets per component, and codemods for breaking changes. Ship ESM + types; consumers control styling via slots or className overrides.

5 min
System Design
Hard
How do you scale a design system across multiple teams?

Design tokens + accessible primitives + clear ownership. Single source of truth for tokens (JSON → CSS vars + platform exports), unopinionated headless primitives, contribution model with RFCs + versioning, governance (a small core team), Storybook + visual regression, and automated migration codemods. Treat the DS as a product with its own roadmap, not a side project.

5 min
System Design
Hard
What design decisions should you consider when building a library API?

Key decisions: a small, intuitive surface; sensible defaults with progressive disclosure; consistency and naming; controlled vs uncontrolled; composition over configuration; TypeScript types as the contract; semver discipline; tree-shakability; minimal peer deps; good errors; and docs. Optimize for the consumer, and for change.

5 min
System Design
Hard
How do you design a tree shakable JavaScript library?

Ship ESM with named exports, mark `sideEffects: false` (or list the files that have them), avoid import-time side effects, prefer many small pure modules over barrels that pull everything, don't re-export huge namespaces, and keep modules pure so bundlers can drop what consumers don't use.

4 min
System Design
Medium
How would you build and publish your own npm package?

Scaffold with package.json, build to ESM (+ CJS) with TypeScript declarations, set exports/main/module/types fields and the files allowlist, version with semver, test and lint, then npm publish (with CI, provenance, and a changelog). Keep the API small and well-documented.

7 min
System Design
Easy
How should a published JavaScript library handle ESM versus CJS output?

ESM (import/export) is statically analyzable → tree-shakable, the modern standard, works in browsers/bundlers. CJS (require/module.exports) is dynamic, the legacy Node format, not tree-shakable. Best practice: ship BOTH via package.json `exports` conditional exports, plus type declarations.

4 min
System Design
Easy
How would you design a release strategy for a JavaScript library using semver and changesets?

Semver strictly: breaking → major, additive → minor, fixes → patch. Use **Changesets** so every contributor's PR articulates the impact; CI consumes changesets to bump versions + write changelog. Pre-release channels (`next`, `canary`) for risky changes. Two-week stabilization. Maintain prior major branches with security patches. Codemods for breaking migrations.

4 min
System Design
Easy
How do you maintain backward compatibility for a published JavaScript package?

Strict semver: breaking change → major. Use Changesets for changelog discipline. Mark APIs experimental with `@experimental` JSDoc. Deprecate with console.warn (or peer-dep typing) for one minor cycle before removing. Ship codemods for non-trivial migrations. Maintain release branches for the last 1–2 majors. Type-test with `tsd` / `expect-type` to catch unintended type changes.

4 min
System Design
Medium
When and how should you use peerDependencies in a JavaScript package?

A peerDependency declares 'I need this, but the host app provides it' — used for shared singletons (React, a router) where multiple copies break things. The host installs one shared version; you don't bundle it. Use a wide version range; the host is responsible for satisfying it.

4 min
System Design
Hard
How do you structure a large scale React application?

Feature-folder structure (one folder per business domain) with explicit public APIs via index.ts barrel files. Layered concerns: app shell (routing, providers), features (business logic), shared (UI library, utilities). Boundaries enforced by lint plugins. Server state in React Query. Design system as a separate package or shared/ui folder. Tests, types, and styles colocated with components.

9 min
System Design
Medium
How would you structure and optimize a large scale React codebase for scalability and readability?

Feature-folder structure with UI → features → shared → lib dependency direction. Server state in React Query; client state in Zustand/RTK with selectors. Design system with accessible primitives. Per-route code splitting + RSC where applicable. CI gates: types, tests, bundle size, web-vitals, visual regression. ADRs for decisions. Codeowners per feature. Migrate incrementally with codemods.

5 min
System Design
Hard
How would you structure a modular frontend application that scales across teams?

Organize by feature domains, not by file type. Each module owns its UI, state, API calls, and types — and exposes a small public API. Enforce boundaries with lint rules (import restrictions), shared primitives only via a `core` package, and avoid cross-feature imports. Use TS path aliases, codeowners, and dependency-cruiser to keep the graph from collapsing.

9 min
System Design
Hard
How would you design a scalable React application for a dashboard with more than one hundred pages?

Feature-folder structure (not type-based), route-level code splitting (one chunk per page), a design system shared across pages, server-state in React Query (per-page caching), client-state minimized and scoped, lazy-loaded heavy widgets, a strict module boundary (pages can't reach into siblings), CODEOWNERS per area, and bundle budgets enforced in CI. The hard part is organizational, not technical.

9 min
System Design
Hard
How do you choose a routing strategy for a large frontend application?

Routing strategy covers: URL → view mapping, code-splitting boundaries, data fetching (waterfalls vs parallel vs streaming), nested layouts, transitions and preloading, auth-gating, and history/scroll restoration. Modern frameworks (Next App Router, Remix, TanStack Router) ship opinionated answers; vanilla React Router needs explicit choices for each. Key trade-off: file-based routing (convention, instant DX) vs config-based (flexibility, explicit).

8 min
System Design
Medium
How would you architect an application to support multiple device form factors?

Responsive, mobile-first design with fluid layouts and breakpoints; a shared component library; adaptive (not just responsive) where capability differs; progressive enhancement; touch + pointer + keyboard input; performance budgets for low-end devices; and decide native vs web vs PWA per requirements.

5 min
System Design
Hard
How do you approach code splitting in a large frontend application?

Per-route (automatic in frameworks), per-heavy-widget (modals, editors, charts), per-locale, per-feature-flag. Vendor chunking by stability + usage (not one mega chunk). Prefetch likely-next routes on hover/viewport. Budget in CI (size-limit). Avoid waterfalls (chunk → loads → another chunk). RSC where possible (server-only code doesn't ship). Watch for over-splitting (HTTP overhead) and the loading-flash UX cost on the critical path.

8 min
System Design
Hard
How do performance, SSR, and SEO factor into frontend system design?

Three intertwined concerns. SSR ships fully rendered HTML so first paint is fast (LCP wins) and crawlers see real content (SEO wins). SSG goes further by precomputing at build for static cacheable HTML. CSR alone leaves crawlers with an empty shell and pushes first paint past JS bundle download. Pick per page: SSG for marketing/blog, SSR/ISR for dynamic-but-shared content, CSR for authenticated dashboards. Layer in metadata (title, description, OG, JSON-LD), sitemap, canonical URLs.

9 min
System Design
Hard
How would you design an offline first frontend application?

Treat the local store as the source of truth; the network is an eventual-consistency partner. Cache shell assets via a Service Worker, persist data in IndexedDB (Dexie), queue mutations for replay on reconnect, and resolve merge conflicts via versioning or CRDTs. Surface offline state in the UI; never block the user on a request. Plan for partial connectivity (slow, flaky, captive portal), not just on/off.

10 min
System Design
Hard
What problems do Web Workers actually solve in a frontend application?

Web Workers run JavaScript on a separate thread, off the main thread. They solve one core problem: CPU-bound work that would otherwise block paint, input, and animation. They do NOT solve I/O latency (fetch is already async) or render-blocking layout. Real wins: parsing large JSON, image/audio processing, crypto, search indexing, syntax highlighting. Communication is postMessage (structured clone or transferable), so picking the boundary is the hard part.

8 min
System Design
Hard
How would you layer state management across local, URL, server, and shared client state?

Five layers, each with its own home. Local UI state → useState. Form → React Hook Form. URL state → router params (shareable, back-button-friendly). Server data → React Query/RTKQ/SWR (cache, dedup, invalidation). Shared client state → Context for rarely-changing, Zustand/Jotai for frequently-changing slices. Persistent → localStorage + small store. Keep boundaries explicit; don't put server data in Redux or theme in Zustand if not needed.

9 min
System Design
Easy
How would you build a priority based data fetching system on the frontend?

Above-the-fold + critical data: high priority, fetched immediately. Below-the-fold: low priority, fetched on idle / when visible. Use `priority` flag on requests, leverage `fetchpriority` attribute for resources, a queue that releases high before low, IntersectionObserver to upgrade priority when a component nears viewport, AbortController to cancel low-priority work when high-priority arrives.

5 min
System Design
Hard
How would you design a system to handle client side caching, API retries, and error boundaries gracefully?

Three layers. Cache: a data-fetching lib (React Query / RTKQ / SWR) with TTL, stale-while-revalidate, tag-based invalidation, and dedup. Retries: exponential backoff with jitter, only for idempotent methods, capped at 2-3 attempts; circuit-break after consecutive failures. Error boundaries: route-level and feature-level boundaries with fallback UIs, plus a global handler for unhandled rejections, plus log to monitoring (Sentry). Tie them together with a single fetch wrapper.

10 min
System Design
Medium
How would you implement dynamic theming such as light and dark mode in a large web application without performance issues?

Use CSS custom properties (variables) on :root, swap via a data-theme attribute. Apply theme on the server (or via an inline script BEFORE first paint) using a cookie/localStorage value to avoid flash. Provide system-default with prefers-color-scheme media query. Keep variable count manageable, organize semantic tokens (color-bg, color-text) over raw colors. Avoid JS-driven style mutation for performance.

8 min
System Design
Easy
How do you manage feature flags at scale across a frontend organization?

Use a flag service (LaunchDarkly/Unleash/Flagsmith or in-house) with typed flag definitions, evaluate flags with sensible defaults, support targeting/gradual rollout/kill switches, evaluate server-side where possible to avoid flicker, and enforce flag lifecycle hygiene so they don't become permanent tech debt.

7 min
System Design
Hard
How would you design a frontend feature flag system?

Two flag types: release flags (kill-switch, gradual rollout — short-lived) and experiment flags (A/B with variants and metrics — bounded life). Evaluate server-side when possible to avoid bundle-time flicker; deliver to the client via a context provider and a stable hashing rule on user/session id. Bake in: targeting rules, percentage rollouts, sticky assignment, defaults that fail safe, dashboards, and a process to remove dead flags.

10 min
System Design
Medium
How do you set up CI/CD for an app with multiple environments?

A pipeline: on push → lint/test/build; on merge → deploy. Multiple environments (dev/staging/prod) each with its own config via env vars (not baked secrets). Branch/tag-based promotion, build-once-deploy-many, preview deploys per PR, and prod gated by approvals/checks.

5 min
System Design
Medium
How do you manage shared dependencies in a frontend monorepo?

Shared deps in a monorepo are managed by hoisting (single version at the root), workspace protocols (pnpm/yarn workspaces with workspace:* for internal packages), and version pinning via a single source of truth (single-version policy or syncpack). Tooling: pnpm/yarn/npm workspaces, Turborepo or Nx for task orchestration, changesets for versioning. Key tension: avoiding version drift across packages vs giving teams autonomy.

8 min
System Design
Easy
How would you migrate a legacy app to a modern frontend stack?

Strangler-fig pattern: strangle the legacy app route by route or feature by feature, not big-bang. Run old and new side-by-side behind a reverse proxy or feature flag; share auth/session via cookies; migrate the highest-value pages first; back the migration with metrics (perf, bug rate, conversion); kill the legacy code path only when usage is zero.

5 min
System Design
Easy
How do you design a monitoring and error tracking strategy for a frontend application?

Layer it: error tracking (Sentry) for exceptions + source maps, RUM for real-user performance (Core Web Vitals), product analytics for behavior, and synthetic/uptime checks. Add error boundaries, global handlers, alerting with thresholds, release tracking, and PII scrubbing. The goal: know it broke before users tell you.

5 min
System Design
Medium
How would you implement a robust frontend monitoring and logging system?

Capture errors (window handlers + boundaries), performance (Core Web Vitals via RUM), and structured logs/breadcrumbs; enrich with context (user, route, release, session); sample and rate-limit; route to a backend (Sentry/Datadog); add session replay and alerting on SLOs. Mind privacy.

7 min
System Design
Hard
What is micro frontend architecture and when would you use it?

Microfrontends extend microservice ideas to the UI: a single app is composed at runtime (or build time) from independently developed, deployed, and owned pieces. Each team ships their slice end-to-end. Composition via iframes, Module Federation, web components, or server-side includes. Trade-off: team autonomy and independent deploys vs. bundle duplication, version drift, and harder cross-team UX consistency.

8 min
System Design
Hard
How do independent deploys work in a micro frontend setup?

Split the UI into apps owned by different teams that deploy independently. Composition: server-side stitching, build-time integration, runtime (Module Federation), or iframes. Independent deploys solve org coordination, not technical performance. The costs — bundle duplication, shared-state coupling, cross-app navigation, design consistency — are real; only adopt when org structure demands it.

10 min
System Design
Medium
How do you share common functions or libraries across a micro frontend application?

Options: Module Federation shared dependencies (share React etc. as singletons), a versioned internal npm package / monorepo workspace, or import maps. Trade-offs: avoid duplicate bundles and version conflicts vs. coupling. Singletons matter for stateful libs like React; design-system and utils are good share candidates.

5 min
System Design
Medium
How would you build a real time order tracker using WebSockets?

Open a WebSocket scoped to the order, render status from a server-pushed event stream, handle reconnection with backoff and state resync, fall back to SSE/polling, and keep the UI optimistic but reconcilable. Clean up the socket on unmount.

7 min
System Design
Hard
How would you build a real time order tracker using WebSockets?

WebSocket connection authenticated at handshake, subscribed to a per-order channel. Server pushes status events; client merges into local state (TanStack Query cache or a simple reducer). Handle reconnection with backoff + resubscription, request a snapshot on connect to fill missed events, dedupe by event id, and fall back to polling on persistent failure. Consider SSE for one-way streams — simpler infrastructure, automatic reconnect.

10 min
System Design
Hard
How would you design a real time collaborative text editor like Google Docs?

The core problem is conflict resolution on concurrent edits: OT (Operational Transformation) or CRDTs. Plus: a sync server (WebSockets), local-first optimistic edits, presence/cursors, document model + persistence, offline support, and undo/redo per-user. CRDTs (e.g. Yjs) are the modern go-to.

6 min
System Design
Medium
How do you stream AI responses to the UI in real time?

The API returns a streaming response (SSE or chunked fetch). Read the ReadableStream from response.body, decode chunks, parse the token deltas, and append to state as they arrive. Handle partial chunks, abort/cancel, errors mid-stream, auto-scroll, and a 'stop generating' control.

5 min
System Design
Medium
How would you build a scalable chat UI for an LLM powered product?

Scalable LLM chat UI requires: streaming via SSE or fetch streams, optimistic message rendering, virtualized long conversation lists, persistent thread storage (server + optimistic local), abort/regenerate semantics, markdown + code-block rendering with syntax highlighting, tool-call / structured-output UI, multi-modal attachments, and careful state ownership (server is source of truth for history; client buffers active stream). Performance hot spots: re-rendering during token stream, scrolling pinned to bottom, markdown parsing on every token.

10 min
System Design
Easy
How would you design 2D data structures for grids, matrices, or sparse maps?

Designing and building 2D data structures (grids, matrices, sparse maps) involves choosing storage (dense array-of-arrays vs flat typed array vs sparse Map keyed by 'r,c'), defining mutation API, and reasoning about access patterns. Trade-off: dense storage is cache-friendly and indexable but wastes memory if sparse; sparse Maps save memory for empty cells but lose locality. Pick based on density and access pattern (random vs sequential, row-major vs column-major).

8 min
System Design
Hard
How would you design a poll widget that can be embedded in any app?

Embeddable widget showing a question + options; user picks one, sees results with percentages and bar visuals. Optimistic UI on vote; idempotent vote (one per user/session, server-enforced); show results after voting or after deadline; real-time updates via polling or WebSocket; handle anonymous vs authed users; rate limit; embed via iframe or script.

4 min
System Design
Hard
How would you design the frontend for a product listing page including components, state, data flow, and scalability?

Page composes `<Filters>`, `<ProductGrid>`, `<Pagination>`. URL is the source of truth for filters/sort/page (shareable, back-button safe). Server-side fetch + SSR/streaming for SEO; React Query handles client refetches on filter change. Skeleton states, optimistic UI on add-to-cart, image lazy-load + responsive srcset. A11y: filter region landmarks, announce result count.

5 min
System Design
Hard
How would you design the data model for a chat application UI in React?

Normalize: `messages: Map<id, Message>`, `channels: Map<id, Channel>`, `participants: Map<id, User>`, ordered `messageIdsByChannel: Map<channelId, id[]>`. Per-channel pagination cursors. Pending outbox keyed by tempId. Drafts per channel. Realtime updates merge into the normalized stores. UI selectors compute lists on demand. React Query for fetch + WebSocket for push.

5 min
System Design
Hard
How would you design a chat application like Facebook Messenger?

WebSocket for real-time messaging; optimistic send with idempotency keys and per-message status (sending/sent/delivered/read); virtualized message list with cursor pagination (load older on scroll up); typing indicators via throttled events; presence via heartbeat; attachments uploaded separately and referenced by id; service worker for offline send queue; push notifications; e2e encryption optional but increasingly expected.

6 min
System Design
Hard
How would you design WhatsApp Web at a high level?

Real-time messaging UI: WebSocket connection for live messages, a normalized client store of chats/messages, optimistic sending with delivery states, virtualized message lists, offline queue + local persistence (IndexedDB), pagination of history, presence/typing, and reconnection handling.

6 min
System Design
Hard
How would you design a news feed for a product like Facebook?

Infinite-scroll feed with cursor pagination; virtualized list for large scrolls; per-post components with mixed media; optimistic likes/comments; ranking served by backend; client caches via React Query keyed on cursor; image/video lazy-load; offline / poor-network resilience; accessibility for the post structure and live updates.

5 min
System Design
Hard
How would you design a Facebook style social media feed?

Covered in depth at [[frontend-system-design-design-a-news-feed-facebook]]. The headline architecture: cursor-paginated server-ranked feed, virtualized list, memoized post components, optimistic likes/comments with idempotency keys, lazy + responsive media, real-time updates via WebSocket or polling, SSR/SSG for first paint and SEO, service worker shell for offline-friendly repeat loads.

4 min
System Design
Hard
How would you design an Instagram style feed page?

Vertical infinite-scroll feed of posts (image/video, caption, likes, comments). Cursor-paginated, virtualized for memory; aggressive image/video lazy-load with placeholders and autoplay-on-visible; optimistic likes/comments; stories carousel above feed; pull-to-refresh; double-tap-to-like; SSR/SSG home for SEO; service worker for offline shell.

6 min
System Design
Hard
How would you design a photo sharing app like Instagram?

Photo-first social product: feed (see [[design-an-instagram-like-feed-page]]) + upload flow + profile + explore. Upload: client crops/filters → direct-to-S3 pre-signed URL → post-process server-side → create post referencing uploaded media. Heavy image optimization (responsive srcset, modern formats, blurhash). Stories (24h ephemeral), DMs, search/explore powered by server.

6 min
System Design
Hard
How would you design a product like Pinterest?

Masonry-grid pinboard with infinite scroll over cursor-paginated server feed; variable-height tiles requiring a packing algorithm (CSS columns or JS positioning); virtualization for long boards; aggressive image optimization with placeholders; pin/save interactions optimistic; SSR/SSG for SEO; accessible grid + keyboard nav.

5 min
System Design
Hard
How would you design a calendar application like Google Calendar?

Day/week/month views with virtualized scrolling; events as positioned blocks computed by collision/layout algorithm; offline-capable via IndexedDB + sync queue; recurring events expanded client-side per visible range; drag-to-create and drag-to-move with optimistic updates; timezone-aware; keyboard + accessibility; real-time updates for shared calendars.

6 min
System Design
Hard
How would you design a video streaming service like Netflix?

HLS/DASH adaptive bitrate streaming via a player (Shaka/Video.js) sourced from a CDN; manifest + segmented chunks; ABR algorithm picks quality based on bandwidth + buffer; preload posters and metadata; SSR/SSG the catalog pages for SEO and fast LCP; per-row carousels; auth-gated playback; accessibility (captions, focus, keyboard).

5 min
System Design
Hard
How would you design a delivery system UI from a driver's perspective, with real time tracking and ETA (low level design)?

Mobile-first driver app: live route on a map (GPS subscription, Map SDK), current/next stop card with ETA, multi-order queue, status transitions (assigned → picked → delivered) with optimistic updates and offline queue, navigation handoff to Google/Apple Maps, push notifications, background location, low-battery considerations, accessible large-touch UI.

6 min
System Design
Hard
How would you design and implement an ATM machine in low level design?

OOP LLD with clear responsibilities: `ATM` (state machine: idle → authenticated → operating), `Card` (number, expiry, validate), `BankAccount` (balance, withdraw, deposit, transactions), `Transaction` (type, amount, status, ts), `CashDispenser` (inventory by denomination, dispense algorithm), plus a bank service for auth/balance. State machine on the ATM and transactional consistency are the depth pieces.

6 min
System Design
Medium
How would you build a maps application like Google Maps with tile loading and a responsive UI?

Tile-based map: world is divided into z/x/y tiles per zoom level (~256x256 px). Load only visible tiles + small overscan. Use HTTP/2 multiplexing for parallel tile fetches; long-cache hashed tile URLs at the edge. Off-main-thread tile decode via OffscreenCanvas or web worker. Render via Canvas/WebGL — DOM doesn't scale. Pan/zoom via CSS transforms + RAF, not per-event DOM mutations. Predict next-likely tiles (direction of pan) and prefetch. Vector tiles + WebGL for richer interactions.

10 min
System Design
Hard
How would you design a dynamic pagination system for infinite scrolling?

Cursor-based pagination + an IntersectionObserver sentinel that triggers loading the next page. Accumulate pages, track hasMore/nextCursor and loading state, virtualize the list, handle errors with retry, and address scroll restoration. Cursor (not offset) keeps it stable under inserts.

5 min
System Design
Hard
How would you design infinite scroll for a list with millions of items?

Combine cursor-based pagination (fetch in pages as the user nears the end) with virtualization (render only the visible window). Use IntersectionObserver to trigger loads, cache pages, handle loading/error/end states, and preserve scroll position. Never hold all items in the DOM or in one fetch.

7 min
System Design
Hard
How would you design a real time, scalable gaming dashboard?

A realtime gaming dashboard needs sub-second latency for game state, leaderboards, and player stats. Architecture: WebSocket for live state, SSE or polling for slower updates, edge pub/sub fan-out (Redis / NATS), CDN-cached snapshots for cold loads, virtualized leaderboard rendering. Critical concerns: backpressure, reconnect, last-write-wins ordering, fairness during partial outages, anti-cheat read paths. Trade-off: WebSocket fan-out scales horizontally but adds infra; SSE is simpler but one-way.

10 min
System Design
Hard
How would you design a frontend architecture that supports one million daily users?

Edge-first: static assets + ideally HTML on CDN (Cloudflare/Fastly/Vercel Edge). SSG for content, SSR/ISR for personalized. Aggressive caching with hashed assets + tag-based invalidation. Service worker for repeat-visit speed. Per-route code splitting + bundle budgets in CI. RUM (web-vitals) sampled, alerted on regression. Observability: error monitoring (Sentry), perf dashboard. Multi-region origin if SSR. Resilience: circuit breakers, retries, graceful degradation. Cost-aware: cap third-party tags, optimize images, lazy below-fold.

11 min