The Question
FE DesignDesign a High-Performance Video Conferencing Platform
Design the frontend architecture for a real-time video conferencing application similar to Zoom or Microsoft Teams. Your solution must address the challenges of rendering dozens of concurrent video streams, managing complex WebRTC signaling states, and ensuring a responsive UI that remains performant under high CPU load. Detail your strategy for video grid optimization, active speaker detection, and the decoupling of media streams from the UI framework's render cycle. Additionally, explain how you would handle low-bandwidth scenarios and ensure accessibility for core controls like muting and screen sharing.
React
WebRTC
WebSockets
CSS Grid
Tailwind CSS
TypeScript
SFU Architecture
Questions & Insights
Clarifying Questions
Scale and Concurrency: How many maximum active participants should a single meeting support for the MVP?
Assumption: Support up to 50 participants with a "Gallery View" limited to 12-16 visible tiles at once to prioritize performance.
Platform Scope: Is this a cross-platform approach or web-first?
Assumption: Web-first (Desktop/Mobile browsers) using WebRTC, focusing on a responsive SPA.
Media Features: Are we including advanced features like virtual backgrounds or recording in the MVP?
Assumption: No. MVP focuses on core Audio/Video streaming, Screen Sharing, and Text Chat.
Network Constraints: How should the system behave in low-bandwidth scenarios?
Assumption: Implement basic adaptive bitrate (simulcast) where the client requests lower resolution streams if the downlink is congested.
Crash Strategy
Core Bottleneck: Managing multiple high-bandwidth MediaStreams without causing UI jank or excessive CPU/battery drain.
Question 1: How do we decouple the heavy MediaStream objects from the reactive UI state to prevent unnecessary re-renders?
Question 2: What is the strategy for the "Gallery View" to ensure 50+ participants don't crash the DOM?
Question 3: How do we synchronize the signaling state (who is in the room) with the actual peer-to-peer media tracks?
Question 4: How do we handle the "Active Speaker" logic efficiently to update the UI in real-time?
Elite Bonus Points
Media Stream Virtualization: Only attaching
srcObject to <video> elements that are currently in the viewport to save GPU/CPU cycles.Web Workers for Signaling: Offloading WebSocket/Signaling logic to a Worker to keep the Main Thread free for 60fps UI transitions.
Simulcast/SVC: Implementing Temporal Scalability so users with bad connections don't penalize the entire room's quality.
WASM for Audio Processing: Using Web Assembly for Echo Cancellation or Noise Suppression if the browser's native API is insufficient.
Design Breakdown
Requirements
Functional Requirements:
Join meeting via URL/ID.
Real-time Video/Audio streaming (Mute/Unmute toggles).
Gallery View and Speaker View.
Screen Sharing (Presenter mode).
In-meeting Text Chat.
Participant list with hand-raise/status.
Non-Functional Requirements:
Latency: Sub-200ms glass-to-glass latency for media.
Performance: Maintaining 60fps for UI overlays while rendering multiple video feeds.
Scalability: Ability to handle 50 participants per room.
Accessibility: Keyboard shortcuts for mute (Cmd+D/E) and screen-reader friendly participant updates.
Security: E2EE (End-to-End Encryption) markers and meeting passwords.
Design Summary
Concise Summary: A WebRTC-powered SPA utilizing a centralized Media Coordinator to manage streams, combined with a virtualized Grid component for the Presentation layer.
Major Components:
Media Coordinator: An Application-layer service that manages WebRTC PeerConnections and maps Stream IDs to Participant IDs.
Video Grid: A smart layout component that calculates tile dimensions based on participant count and viewport size.
Signaling Client: A WebSocket-based service for room state synchronization (Join/Leave/Mute status).
Control Bar: A floating UI overlay for session-persistent actions (Audio, Video, Share, Leave).
CUJ Walkthrough: A user joins via a link; the Signaling Client connects to the room; the Media Coordinator initiates WebRTC handshakes; the Video Grid receives a list of active streams and renders Video Tiles for each participant.
Simplicity Audit: This architecture avoids complex Canvas-based rendering in favor of native
<video> elements and CSS Grid, which is sufficient for 50 participants and easier to maintain.Architecture Decision Rationale:
Why this architecture is the best for this problem?: Separating the Media Layer from the UI state (Presentation) prevents React/Framework overhead from throttling the video decoding process. Using a "Coordinator" pattern allows for easier testing of WebRTC logic independent of the UI.
Requirement Satisfaction: Real-time requirements are met via WebRTC; scalability is handled by limiting visible tiles; functional requirements are encapsulated in modular Feature Containers.
System Diagram
Architecture Deep Dive
Presentation Layer
Component Hierarchy:
AppShell handles global providers (Auth, Theme). MeetingLayout defines the 16:9 aspect ratio container and Sidebar/Grid split. GalleryGrid calculates the optimal N x M layout using CSS Grid. VideoTile is the leaf component responsible for the <video> element and overlaying participant names/status.Interaction Layer: Debounced volume meters to prevent UI flickering. Keyboard listeners for "Spacebar to unmute." Optimistic UI updates for the chat.
Rendering Layer: Use
memo on VideoTile to prevent re-renders when other participants' metadata changes. Critical: Use ref for the <video> element's srcObject to avoid React reconciliation cycles for the stream itself.UI Frameworks: React for the UI, Tailwind CSS for the Grid system, and Headless UI for accessible modals (e.g., Settings).
Application Layer
Data Fetching Layer: REST for meeting metadata (Title, Scheduled Time); WebSockets for real-time signaling. No heavy client-side caching needed for meeting state as it's highly ephemeral.
State Management Layer:
Global Store: Participant list, Room metadata, Active Speaker ID.
Local Store: User's own Mute/Camera status.
Context API: To provide
StreamController instance to nested components.Routing & Navigation: URL-based routing (
/room/:id). Route guards check for "Join Permissions" or "Password" before mounting the MeetingPage.Domain Layer
Business Rules: "Only one person can share a screen at a time." "Host has the power to mute all." These rules are enforced in the
RoomService.Entities / Models:
Participant object containing id, streamId, isMuted, isSpeaking, role.Inter-layer Contracts: The
StreamController provides an Observable/Event-based interface (e.g., onStreamAdded, onStreamRemoved) that the Application Layer listens to.Infrastructure Layer
API / Network: WebRTC for Peer-to-Peer (or SFU - Selective Forwarding Unit if scaling beyond 5 users). WebSockets for the signaling plane (SDP exchange, ICE candidates).
Storage:
sessionStorage to persist the user's "Display Name" and "Camera Preferences" if they refresh the page.Wrap Up
Wrap-up
Evaluation: The design balances performance with developer velocity by using standard WebRTC and CSS.
Trade-offs: We chose a Mesh/SFU-client hybrid approach. For MVP, we assume an SFU architecture on the backend to reduce client-side upload bandwidth.
Optimization: To handle 50 participants, we implement "Grid Pagination" or "Priority Speakers." Only the top 6-12 most recent speakers get a high-res video stream; others are audio-only or low-res thumbnails until they speak.
Advanced: Future iterations would include WebWorker-based noise cancellation and Canvas-based background blur.