Design a Video Call App – Frontend System Design

We’ll walk through the frontend system design for a browser-based video conferencing app like Zoom or Google Meet. Our goal is a meeting room that a user can join from a URL, preview camera and mic, then sit in a grid that grows from a 1:1 view into a tiled stage as people arrive. We’ll keep signaling, media, and REST on separate paths, and we’ll treat the tile grid as a subscription problem — not a “mount every remote video” problem. Put simply, the task is to design a video call app whose UI stays responsive as people join and leave.
Interviewers want to see that you know why mesh falls over, how an SFU plus simulcast keeps 25 cameras watchable, and how the UI stays up when ICE fails or a tab goes to the background. You’ll see estimates for one room, the component split, the join workflow, and the edge cases that separate a demo from a product.
Problem Statement
Build the frontend for a browser-based video conferencing app like Zoom or Google Meet.
Requirements:
- A meeting room with a grid of participants
- Mute, camera on/off, screen share, and in-meeting chat
- The layout switches from a 1:1 view to a grid as people join
- It has to work in Chrome, Firefox, and Safari without a plugin
Describe WebRTC, the signaling path, the tile grid, and how you stay smooth when 20 cameras are on.
Clarifying Questions
| # | Question | Interviewer’s Answer |
|---|---|---|
| 1 | Max participants on screen? | Design for 25 in-grid. Larger meetings use pagination or “speaker only.” |
| 2 | SFU or mesh? | Your call. Explain it. |
| 3 | Recording, breakout rooms, reactions? | Out of scope. |
| 4 | Waiting room and auth? | Yes, a meeting link plus optional password. |
Ask these before you draw boxes. The 25-tile cap is the whole layout problem. “Your call” on SFU vs mesh is the interviewer checking whether you can kill mesh at 10+ peers with a bandwidth argument, not a brand preference. Recording and breakouts would add another media consumer and a second room roster — park them. Auth is a join token, not a full identity product.
Requirements
- Join by URL, camera/mic permissions, preview
- WebRTC audio + video + screen share
- Tile grid with pin / speaker view
- Chat and a participants list
- Graceful permission-denied and reconnect states
The functional list is short on purpose. A strong answer also names what the client must do after join: pick a capture device, publish one uplink, subscribe only to visible tiles, render a layout that can flip between speaker and grid, and keep chat available while media reconnects.
Non-Functional Requirements
- First remote video in a few seconds after join, not after every peer connects
- Audio stays up even if video subscriptions drop
- Works in Chrome, Firefox, and Safari with
playsInlineand a user-gesture join - Tab-hidden meetings must not keep decoding 25 videos
- Meeting tokens expire; signaling is
wss - A reconnect banner, not a kick back to the lobby, on ICE failure
Napkin Math
| Metric | Estimate |
|---|---|
| 720p camera | ~1.5 Mbps uplink |
| Mesh of 10 people | 9 incoming videos. Phones will melt. |
| SFU | 1 uplink, N downlinks. The server forwards. This is the default. |
Scalability Estimates
These numbers are interview napkin math for one meeting, not product telemetry. The frontend does not “scale to millions of users” by itself — it scales one room. Use the clarifying cap of 25 in-grid tiles and the existing 720p uplink figure.
| Metric | Estimate | Calculation | Notes |
|---|---|---|---|
| In-grid participants | 25 | From the clarifying answer | Beyond 25: paginate or speaker-only |
| Local camera uplink | ~1.5 Mbps | One 720p encode to the SFU | Same number as the napkin table |
| Mesh downlink, 10 people | ~13.5 Mbps | 9 × 1.5 Mbps | Plus 9 decodes. Phones will melt. |
| Mesh downlink, 25 people | ~36 Mbps | 24 × 1.5 Mbps | This is why mesh is wrong at 10+ |
| SFU downlink, mixed layers | ~7–8 Mbps | 1 × 1.5 Mbps speaker + 24 × ~250 kbps 180p | Simulcast. Subscribe to what you can see. |
| Chat payload | ~100 KB / meeting | 25 people × 20 messages × ~200 bytes | Not the bottleneck. Late join via REST. |
| Signaling rate | ~1–5 events/s | join, mute, speak, share, leave | WebSocket. Keep it off the media path. |
The interview move is to put mesh and SFU on the same whiteboard and let the arithmetic end the debate. One uplink plus layer-selected downlinks is the design. Chat and signaling are rounding error next to video.
Architecture

<MeetingContainer>
useMeeting()
<PreviewGate />
<Stage>
<VideoTile />
</Stage>
<ControlBar />
<ChatDrawer />
</MeetingContainer>
Three networks, don’t mix them:
- Signaling (WebSocket): join, mute, chat, “Alice started sharing.”
- Media (WebRTC): the actual audio/video via an SFU (mediasoup, LiveKit, Twilio).
- REST: meeting metadata, auth, chat history on late join.
Mesh (every peer to every peer) is fine to mention for 2–3 people and wrong at 10+.
The shell is a single meeting session. MeetingContainer owns the session hook and never remounts tiles just because chat opened. Views stay presentational. Media attachment, signaling, and layout policy live in a meeting client, not inside each <video>.
Component Structure and Responsibilities
- MeetingContainer: Root of the room. Holds
useMeeting(), auth state, and the reconnect banner. Renders preview or stage, never both as competing sources of truth. - PreviewGate: Pre-join. Enumerates devices with
enumerateDevices(), callsgetUserMedia, shows a mirrored local preview, and blocks join until the user accepts the meeting password if one is set. - Stage: Layout engine. Picks 1:1, speaker+filmstrip, or an N-tile grid from the roster and the pin. Computes which participant IDs are on screen. That visible set is the subscription set.
- VideoTile: One visible participant. Binds a
MediaStreamto<video autoPlay playsInline>, draws name, mute badge, and a speaking ring. Does not own the PeerConnection. - ControlBar: Mute, camera, share, leave, layout toggle, chat toggle. These are commands into the meeting client. The buttons reflect published state, not a guess from the local preview.
- ChatDrawer: In-meeting messages. Optimistic append on send. Hydrates history over REST when someone joins late so chat does not depend on having been on the WebSocket the whole time.
- ParticipantsList: Roster with mute/cam badges and a host “mute all” if the role allows it. Not a second video grid.
Network Layer and Data Management
A MeetingClient sits under the hook and owns the three networks. UI components never open a RTCPeerConnection or a socket themselves.
- SignalingManager: One
wssconnection. Sends join, mute, chat, pin, and share. Receives roster diffs, active-speaker events, and “Alice started sharing.” Reconnects with the last applied event id so a blip does not replay the whole meeting. - MediaSession: Creates the PeerConnection to the SFU, publishes the local camera/mic (or a screen track), and calls subscribe/unsubscribe as the Stage’s visible set changes. Device switches go through
replaceTrackso you do not tear the connection down. - RestClient:
POST /joinfor the token and signaling URL,GETmeeting metadata,GETchat history. TURN credentials are fetched here at join, not baked into the bundle. - MeetingStore: Roster, local publish flags, layout mode, chat, connection state. Tiles subscribe to one participant. The Stage subscribes to the visible-id list. Chat subscribes to messages. A mute event does not re-render every tile’s
<video>.
State is a meeting document plus ephemeral media handles. The document (who is here, who is muted, who is sharing) is serializable and can be snapshotted after reconnect. MediaStream objects are not serializable — they live in the MediaSession and are attached by participant id.
Join and Media Workflow
- User opens
/m/:id. REST loads meeting metadata (title, requires password, scheduled start). PreviewGate mounts and requests camera/mic. - User confirms devices and optional password.
POST /api/meetings/:id/joinreturns{ signalingUrl, token, role }. - SignalingManager opens the socket, authenticates with the token, and sends join. The server returns the current roster.
- MediaSession creates the PeerConnection, finishes offer/answer/ICE with the SFU, and publishes the local tracks.
- Stage computes the visible set (1 tile if you are alone, 2 for a 1:1, up to 25 in grid). MediaSession subscribes to those ids at the layer the tile size needs.
- Remote
MediaStreams attach to the matchingVideoTile. Active-speaker events update a speaking ring and, in speaker view, promote that tile. - If the user pins, shares, or scrolls a paged grid, the visible set changes and subscriptions follow. Tiles that leave the viewport unsubscribe. You do not keep 200 hidden videos mounted.
- Leave calls unsubscribe-all, stops local tracks, closes the socket, and returns to a post-meeting screen. Closing the tab must stop tracks in
pagehideso the camera light goes off.
This is the story interviewers want: preview is local, join is REST, presence is signaling, pixels are WebRTC, and the grid is a viewport over the roster.
WebRTC in the UI
type Participant = {
id: string;
name: string;
micOn: boolean;
camOn: boolean;
isScreen: boolean;
speaking: boolean;
};
// useMeeting()
// 1. getUserMedia({ audio: true, video: true })
// 2. open signaling socket, send join
// 3. SFU returns offer / answer / ice
// 4. attach remote MediaStreams to <video autoPlay playsInline />
Building the tile stage

The roster can be 200 people. The decoder budget is not. Chrome will start failing silently around tens of simultaneous <video> elements. You never mount a video per roster entry.
Subscribe to what you paint. The Stage component derives a window of visible participant ids from the layout (speaker + N filmstrip tiles, or a page of a 4×4 grid). MediaSession diffs that set against the current subscriptions and sends the SFU subscribe / unsubscribe for the delta. A participant who is on page 3 of the roster has a name in the list and no decoder.
Signaling is the Docs socket with different message types: join, offer/answer/ice, subscribe { id, layer }, mute, roster. Keep it one WebSocket. ICE and SDP are not React state. A mid-call reconnect re-sends join with the meeting id and last roster rev, then re-subscribes the current window — you do not renegotiate every peer from scratch if the SFU still has your publisher.
Simulcast / SVC layers. Each publisher sends 180p / 360p / 720p (or an SVC stack). Your subscribe message includes the layer. Rules you can say out loud:
- Active speaker or pinned: 720p
- Filmstrip / 3×3 cell: 180p or 360p
- Off-screen: unsubscribe, including the screen-share if it is not pinned
- Tab hidden (
document.visibilityState): drop everyone to the lowest layer or pause incoming video. Keep audio. On visible, restore.
Switching a layer is a signaling call, not a new PeerConnection. The same transceiver starts receiving a different encoding. There will be a short freeze; keep the last frame on the element until playing.
One <video> per visible tile, bound by id. Do not destroy the element when the stream renegotiates — set video.srcObject = newStream. Recreating the element is a black flash and a new autoplay check. Pool ~12 elements and reuse them as the window slides, same idea as a virtualized list.
function bindTile(el: HTMLVideoElement, stream: MediaStream | null) {
if (el.srcObject === stream) return;
el.srcObject = stream;
el.playsInline = true;
el.muted = false; // remote tiles; local preview stays muted
el.play().catch(() => { /* waiting for the join gesture */ });
}
Local preview is a separate <video muted autoPlay playsInline> bound to the getUserMedia stream. Mirror it with CSS (transform: scaleX(-1)). Never send the mirrored pixels — the SFU gets the raw track.
Do not composite everyone onto one canvas unless they ask you to record the meeting. A single canvas of 12 videos costs you per-frame drawImage, loses per-tile accessibility, and still needs the source <video>s attached (you cannot draw a MediaStream without an element). Layout as CSS grid of elements. Canvas compositing is for “export this call to a recording,” which is out of scope.
Mesh vs SFU vs MCU
Say this before you draw boxes.
| Mesh | SFU | MCU | |
|---|---|---|---|
| Upload | N−1 copies of your cam | One upstream (plus simulcast layers) | One upstream |
| Layout control | You | You (server forwards encodings) | Server mixes a single video |
| Use | 2–4 people | Interview default (~25) | When clients cannot decode many tiles |
Mesh dies at ~25 on bandwidth and decoders. MCU is easier on phones and worse for “pin Ada.” SFU is the answer.
Chat, mute, raise-hand, and roster stay on the signaling WebSocket. They need order, easy replay, and server fan-out. RTCDataChannel is a follow-up for in-call file drop, not for “Ada muted.” Media is WebRTC. Product state is the socket. Same split as a chat app, plus a specialized media path.
Do not put MediaStream in React state
RTCPeerConnection, MediaStream, and tracks are live browser objects. They mutate without your reducers. Store ids and flags (camOn, connection: "connected"). A peer-connection manager owns the objects. Putting a stream in Redux is how you get a black tile after a reconnect and a re-render storm on every ICE candidate.
Reconnect is core, not an edge case. A news feed retry is a spinner. A call retry is “I talked for ten seconds into a dead mic.” Adapt quality first (drop layers). If signaling or ICE dies, re-join, re-subscribe the current window, keep the last frame on each tile until playing. Persist device ids and the meeting id locally so a laptop wake does not ask for camera permission again.
Speaking detection: prefer an SFU “active speaker” event (it already has the audio levels and it does not run on the main thread). A local AnalyserNode on your own mic is fine for the green ring on your tile. Do not attach an analyser to every remote tile.
Safari will not autoplay unmuted remote audio without a user gesture. Join is that gesture — start audio in the same turn as the click. Put playsInline on every video; without it iOS goes fullscreen on play.
Screen share is a second published track, not a second PeerConnection. The SFU treats it as a participant with isScreen: true. Stage pins that tile. getDisplaySurface / display-surface constraints are a nice-to-have; the required path is getDisplayMedia, replace or add the video sender, and signal “started sharing” so everyone else’s layout updates before the track arrives.
When the camera is off, keep the audio sender and show an avatar tile. Do not remove the participant from the roster. When the mic is off, keep the video sender and stop sending audio frames (or send silence if you must hold the transceiver). The ControlBar reads micOn / camOn from the store so a failed mute does not flip the button.
State and Data Flow
A meeting has two clocks. Signaling events are discrete and ordered. Media is a live attachment. Mixing them is how you get a tile that says “camera on” with a frozen frame.
A typical flow:
- A user action (mute, pin, send chat, switch device) becomes a command on
useMeeting(). - Optimistic local state updates immediately so the button does not wait for the round trip.
- SignalingManager or MediaSession executes the command. Mute is a signaling event plus a track
enabledflip (or a real pause if you want the SFU to stop forwarding). - The store applies the server’s roster event as truth. If your optimistic mute lost a race with “host muted you,” the host wins.
- Stage derives the visible id list. MediaSession diffs subscriptions. Tiles bind streams by id.
- Errors land in connection state:
preview,connecting,connected,reconnecting,failed. The banner reads that enum. Tiles do not each show their own reconnect UI.
Chat is the same store, different channel. Messages go on the signaling socket for live delivery and on REST for history. Do not open a fourth WebSocket for chat in this interview — one signaling connection is enough.
Data Model
Keep the roster small and copyable. Media handles sit beside it, keyed by the same participant id.
type Participant = {
id: string;
name: string;
micOn: boolean;
camOn: boolean;
isScreen: boolean;
speaking: boolean;
};
type Role = "host" | "guest";
type ConnectionState =
| "preview"
| "connecting"
| "connected"
| "reconnecting"
| "failed";
type LayoutMode = "speaker" | "grid";
type ChatMessage = {
id: string;
senderId: string;
text: string;
ts: string; // ISO
};
type VideoLayer = "180p" | "360p" | "720p";
type Subscription = {
participantId: string;
layer: VideoLayer;
};
type Meeting = {
id: string;
title: string;
role: Role;
selfId: string;
participants: Record<string, Participant>;
layout: LayoutMode;
pinnedId: string | null;
visibleIds: string[];
chat: ChatMessage[];
connection: ConnectionState;
};
type SignalingEvent =
| { type: "roster"; participants: Participant[] }
| { type: "mute"; participantId: string; micOn: boolean }
| { type: "camera"; participantId: string; camOn: boolean }
| { type: "share"; participantId: string; isScreen: boolean }
| { type: "speak"; participantId: string; speaking: boolean }
| { type: "chat"; message: ChatMessage }
| { type: "left"; participantId: string };
visibleIds is derived from layout, pin, page, and roster order. Store it if you want tiles to render from one snapshot; recompute it if you want a single source. Either way, MediaSession should see a stable list so it can diff subscriptions instead of resubscribing every speak event.
API
// POST /api/meetings/:id/join -> { signalingUrl, token, role }
// WS signalingUrl
// { type: "mute", micOn: false }
// { type: "chat", text: "hello" }
// GET /api/meetings/:id/chat?after=
REST creates the session. The socket carries live room events. Chat history is a cursor so a late joiner does not ask the socket to replay.
| Action | Method & Endpoint | Description |
|---|---|---|
| Load meeting | GET /api/meetings/:id | Title, password required, host display name. No media. |
| Join | POST /api/meetings/:id/join | Body: { password?, deviceLabel }. Returns { signalingUrl, token, role, selfId }. |
| TURN / ICE | GET /api/meetings/:id/ice | Short-lived ICE servers. Called at join, not shipped in JS. |
| Signal | WS signalingUrl | Roster, mute, share, speak, chat. Auth via token on connect. |
| Chat history | GET /api/meetings/:id/chat?after= | Cursor page for late join. Returns { messages, next }. |
| Leave | POST /api/meetings/:id/leave | Best-effort. pagehide also stops tracks locally. |
Example: Consuming Signaling on the Frontend
function connectSignaling(url: string, token: string, store: MeetingStore) {
const ws = new WebSocket(url);
ws.addEventListener("open", () => {
ws.send(JSON.stringify({ type: "auth", token }));
});
ws.addEventListener("message", (ev) => {
const event = JSON.parse(String(ev.data)) as SignalingEvent;
store.apply(event);
});
ws.addEventListener("close", () => {
store.setConnection("reconnecting");
window.setTimeout(() => connectSignaling(url, token, store), 1000);
});
return ws;
}
Backoff belongs in the client, not in each tile. While reconnecting, keep the last roster on screen and show the banner. Do not dump users to the lobby.
Optimizations
- Simulcast + subscribe only to visible tiles
- Pause incoming video when the tab is hidden (
document.hidden) - Device switching without tearing down the PeerConnection (replaceTrack)
- Reconnect with ICE restart; show a banner, don’t dump users to the lobby
Those four are the interview bar. The implementation is specific APIs, not slogans.
async function switchCamera(
sender: RTCRtpSender,
local: MediaStream,
deviceId: string
) {
const next = await navigator.mediaDevices.getUserMedia({
video: { deviceId: { exact: deviceId } }
});
const track = next.getVideoTracks()[0];
if (!track) return;
await sender.replaceTrack(track);
local.getVideoTracks().forEach((old) => old.stop());
local.removeTrack(local.getVideoTracks()[0]);
local.addTrack(track);
}
function bindVisibility(media: MediaSession) {
const onVis = () => {
if (document.hidden) {
media.pauseIncomingVideo(); // keep audio subscribed
} else {
media.resumeVisibleTiles();
}
};
document.addEventListener("visibilitychange", onVis);
return () => document.removeEventListener("visibilitychange", onVis);
}
replaceTrack keeps ICE and the SFU publisher id stable, so nobody else sees you leave and rejoin. Visibility handling must not mute the meeting — people take notes in another window and still need audio.
If CPU climbs (watch getStats() for decode time or a dropped-frame count), drop small tiles to 180p or to avatar-only. That is a frontend policy on top of simulcast, not a new backend feature.
Handling User Edge Cases
| Case | Strategy |
|---|---|
| ❌ Camera / mic permission denied | Stay in PreviewGate. Show the browser’s permission instructions. Allow join as listen-only with avatar tiles. |
| ❌ Device unplugged mid-call | devicechange → fall back to the next input. If none, flip camOn/micOn and signal the roster. |
| 🔄 User reloads the tab | Join again with the same meeting URL. REST + signaling rebuild the roster. Do not expect MediaStreams to survive reload. |
| 📶 ICE failed / Wi-Fi flip | ICE restart on the existing PeerConnection. Banner in reconnecting. Keep chat input enabled on the socket if it is still up. |
| ⏳ Join token expired | Re-run POST /join, reconnect the socket, keep the local preview so it does not feel like a new meeting. |
| 🚫 26th person joins | Paginate the grid or force speaker-only. Never subscribe to 26 cameras “just for a minute.” |
| 🖥️ Safari autoplay block | Start playback in the join click. If a tile is added later, call video.play() and catch the rejection. |
| 🔇 Host mutes you | Server event wins. Disable the local mic sender and set aria-pressed from store state, not from the last click. |
Pro-Level Optimizations
| Area | Suggestion |
|---|---|
| Layer switching | Pin or speaker view requests 720p; filmstrip stays on 180p. Change the subscribe layer, do not remount the tile. |
| Audio first | Subscribe to audio for everyone in the meeting, video only for visibleIds. Talking in a 100-person call still works. |
| Decode budget | If getStats() shows the decoder falling behind, collapse non-speaker tiles to avatars. |
| Screen share | Treat the share as its own participant id. Pin it. Keep the camera published if you still want a self view. |
| Chat while reconnecting | Queue outgoing chat if the socket is down; flush on open. Media reconnect is independent. |
| Mobile keyboard / chrome | ControlBar is a safe-area footer. Do not put mute under the iOS home indicator. |
Accessibility and Security
- Mute / camera are toggle buttons with
aria-pressed - Live captions if you have them (Web Speech or a caption track from the SFU)
- Don’t autoplay unmuted remote audio without a user gesture — browsers will block it. Join is the gesture.
- Meeting tokens are short-lived. Signaling is wss. Don’t put TURN credentials in the JS bundle forever; fetch them at join.
Name every control. “Toggle microphone” is a name; a bare icon is not. The speaking tile can update a polite live region (“Alex is speaking”) at a low rate so a screen reader is not flooded by voice-activity flicker.
Keyboard: M mute, C camera, F pin focused tile if you add it — announce the shortcut next to the button. Chat is a separate tab stop from the stage. Do not trap focus inside the grid; tiles are not a spreadsheet.
Sanitize chat as text. If you ever render markdown, escape first. A meeting link plus password is not authorization to run HTML in the drawer.
Roles belong on the token. Guests cannot mute others. The client hides the control; the server rejects the event. Tokens expire in minutes, not days, because a leaked signaling URL should not be a standing invite to the media server.
Conclusion: How to Design a Video Call App
Zoom in the browser is WebRTC plus a layout engine. Use an SFU, subscribe to what you can see, and keep signaling off the media path. If you try to mesh 25 peers, the interview is over.
The rest of a senior answer is the session lifecycle. Preview before join, three networks that never share a socket, a roster store that tiles can bind without owning PeerConnections, and a reconnect path that keeps people in the room. Simulcast is how 25 cameras stay cheap: 180p on the filmstrip, 720p on the speaker, nothing mounted offscreen.
Build the ControlBar as commands, the Stage as a viewport, and the MeetingClient as the only thing that talks to getUserMedia and the SFU. That split is what keeps the UI smooth when the twentieth camera turns on.
