Problem
Design the frontend of WhatsApp's chat as a web app, like WhatsApp Web: a chat list, one-to-one and group conversations, and messages that show whether they've been sent, delivered and read. People also see who is online or typing, share photos and videos, and keep using the app on a bad connection.
Interviewers use it to test real-time communication in both directions, how a message moves through its states without being lost, duplicated or shown out of order, offline support, rendering very long conversations, and what end-to-end encryption changes for the client.
Functional requirements
- A chat list sorted by latest activity, with unread counts, and conversations you can scroll back through.
- Send and receive text, photos, videos and documents in real time, with sent, delivered and read ticks.
- See who's online and who's typing, and get notified of new messages.
- Keep reading and writing while offline; messages go out when the connection returns.
Constraints
- Up to 2,000 chats per person, conversations with 100,000 messages, and groups of 1,000 people.
- Your own message shows on screen in under 100 ms; with both people online, a message and its ticks arrive within about 1 second.
- No message lost, duplicated or out of order, through refreshes, crashes, flaky networks and hours offline.
- End-to-end encrypted: the server never sees message text or media. Files up to 100 MB.
- Desktop browsers with several tabs open, 60 fps scrolling, and accessible to WCAG 2.2 AA: keyboard and screen reader.
Discussion areas
- Core entities and key actions: what chats, messages, receipts and media are, and which user actions shape the design.
- Architecture: rendering approach, the layers between UI components and the server, the component tree, and what happens when the app is open in several tabs.
- Data model: what lives in memory, what lives on the device, and how a message is identified before and after the server has seen it.
- Message lifecycle: how a message goes from "sending" to "sent", "delivered" and "read", and how to keep the order right in one-to-one and group chats.
- Real-time connection: choosing a transport, noticing a connection that died silently, reconnecting without overloading the server, and catching up on what was missed.
- Reliability and errors: duplicates, messages that arrive out of order, gaps, and which failed sends to retry or show to the user.
- Offline and media: writing messages without a connection, and uploading large photos and videos on a flaky network.
- Long chats: loading history while scrolling up, opening at the first unread message, rendering 100,000 messages, and searching them.
- Presence, typing and notifications: how often to send them, what to keep, and how to notify someone with no tab open.
- Privacy and accessibility: what end-to-end encryption changes for the client, announcing new messages to screen readers, and full keyboard use.
Follow-up questions interviewers ask
- Why WebSocket and not SSE?
- What if the server saved the message but the ack was lost?
- Asha sends from her phone. How does her browser show it?
- What if Ravi turns off read receipts?
- Why not one socket per tab?
- Why can't a push notification show the text?
- How can you trust a web client, if the server sends the code?
- How does a 1,000-person group stay fast?