Design a Real-Time Chat Application
System design for Slack/WhatsApp-style chat: WebSocket management, message ordering, offline support, typing indicators, read receipts, search, and file uploads.
Designing a real-time chat application is a classic frontend system design question. It combines WebSocket management, message ordering, optimistic updates, and offline resilience. Here's a structured approach.
Requirements Clarification
Functional Requirements
- Display messages in a conversation (chronological order).
- Send text messages with real-time delivery.
- Support file uploads (images, documents).
- Typing indicators when others are typing.
- Read receipts (seen/delivered).
- Message search within a conversation or across conversations.
- Optional: edit/delete, reactions, threads.
- Offline: queue messages when disconnected; sync when back online.
Non-Functional Requirements
- Latency: Messages appear within ~100ms of send/receive.
- Reliability: Reconnection with exponential backoff; no duplicate messages.
- Ordering: Messages displayed in deterministic order (server timestamp or sequence).
- Scalability: Handle long conversations (10k+ messages) without full load.
High-Level Architecture
┌─────────────────────────────────────────────────────────────────┐
│ ChatLayout │
│ ┌─────────────┐ ┌────────────────────────────────────────────┐│
│ │ Conversation│ │ ChatView ││
│ │ List │ │ ┌──────────────────────────────────────┐ ││
│ └─────────────┘ │ │ VirtualizedMessageList │ ││
│ │ │ MessageBubble (text, media, status) │ ││
│ │ └──────────────────────────────────────┘ ││
│ │ ┌──────────────────────────────────────┐ ││
│ │ │ MessageInput (text, file picker) │ ││
Continue reading Design a Real-Time Chat Application
Sign in or create a free account to read the rest of this article and all premium content.
Sign in to continue readingRelated articles
- System DesignDesign a Comments Thread
System design for nested comments: replies, pagination, real-time updates, and moderation. Frontend architecture and data shape.
Read article - System DesignDesign a Frontend Notification System
System design for toasts, badges, and notification center: queue management, auto-dismiss, priority, read/unread, real-time delivery (SSE/WebSocket), filtering, push notifications, and overflow behavior.
Read article - System DesignDesign a Search Results Page
System design for a search results page: filters, sorting, facets, infinite scroll vs pagination, and performance at scale.
Read article - System DesignDesign Autocomplete / Typeahead Search
System design for building a Google-like autocomplete search component: debouncing, caching, keyboard navigation, race conditions, and mobile considerations.
Read article