01Chapter 1: Clarifying requirements and scopeEvery chat system design starts with questions, not boxes and arrows. "Design a chat system" can mean a two-person messenger, a team workspace like Slack, or a global app with billions of users. Each one leads to a different architecture. This chapter shows how to turn a vague request into a short, 5 min read
02Chapter 2: Estimating traffic, connections, and storageThis chapter assumes you know basic client-server and HTTP concepts, can read short Python snippets, and know what a persistent connection is. You don't need prior estimation experience.6 min read
03Chapter 3: Polling, long polling, and WebSocketThis chapter assumes you know basic HTTP request and response behavior and what a TCP connection is. You should also be able to read short JavaScript and Python snippets. It covers how a chat client learns that a new message exists. Later chapters cover what the server does with the message once it 6 min read
04Chapter 4: High-level architecture: stateless APIs and stateful chat serversThis chapter assumes you know basic client-server and HTTP concepts, have used databases and key-value stores, and understand that a TCP connection can stay open. It also assumes you can read short JavaScript and Python snippets. Earlier chapters set the requirements, the traffic estimates, and the 6 min read
05Chapter 5: Modeling users, conversations, and messagesThis chapter assumes you know basic relational and key-value storage ideas, and can read short Python and JavaScript. The previous chapters set the requirements and the architecture. Here we define the data the system stores. Later chapters cover the message flow, ID generation, and the choice of da6 min read
06Chapter 6: Following a one-to-one message end to endThis chapter traces a single message from Alice's phone to Bob's screen. It builds on the high-level architecture and the message data model from earlier chapters. It leaves ID generation, retry details, and group fan-out to later chapters, and only points at them where the flow touches them.5 min read
07Chapter 7: Ordering messages and generating IDsThis chapter assumes you know how a one-to-one message travels from sender to receiver (the previous chapter) and that you can read short Python and JavaScript snippets. It covers how a chat system decides the order of messages and how it creates the IDs that carry that order.6 min read
08Chapter 8: Acknowledgements, retries, and deduplicationThis chapter covers how a chat system gets at-least-once delivery without showing duplicates to users. It assumes you know how a one-to-one message travels from sender to recipient, how a WebSocket connection works, and how per-chat sequence numbers order messages. You should also be able to read sh6 min read
09Chapter 9: Choosing storage for chat historyThis chapter assumes you know the message and conversation model from the earlier chapters, the difference between relational and key-value stores, and the basics of indexing. You should also be comfortable with the per-chat sequence numbers introduced in the ordering chapter.6 min read
10Chapter 10: Group chat and fan-out strategiesThis chapter assumes you know the one-to-one message flow from earlier chapters: a client sends over a persistent connection, the chat server assigns a per-chat sequence number, stores the message, and delivers it to the recipient. It also assumes you understand acknowledgements and idempotent write6 min read
11Chapter 11: Presence with heartbeatsPresence shows whether a user is online. This chapter covers how a chat system works out presence from periodic signals called heartbeats. It assumes you know how WebSocket connections work, have used a key-value store such as Redis, and can read short Python and JavaScript. It builds on the earlier6 min read
12Chapter 12: Notifying offline usersThis chapter assumes you have read the chapters on the one-to-one message flow, acknowledgements and idempotency, and presence with heartbeats. You should know that a message is persisted with a per-chat sequence number before delivery is attempted, and that presence is derived from heartbeats with 5 min read
13Chapter 13: Syncing multiple devices and loading historyThis chapter assumes you have read the chapters on message ordering and on storage for chat history. You should know that each chat has a server-assigned sequence number (seq) and that messages are stored by (chat_id, seq). You should also be comfortable reading short Python and JavaScript snipp6 min read
14Chapter 14: Scaling connection servers and routing messagesThis chapter assumes you know how a chat message flows between two users, as covered in the earlier chapters on the architecture and the one-to-one flow. You should also know that WebSocket connections are long-lived and stateful, and that a key-value store such as Redis can hold small records with 6 min read
15Chapter 15: Handling media and attachmentsThis chapter covers how a chat system sends images, video, voice notes, and files. It assumes you know HTTP, object storage basics, and the message model and delivery flow from earlier chapters. The main idea is simple: *the chat path carries small messages, and the media path carries large bytes.6 min read
16Chapter 16: Security, privacy, and rate limitingThis chapter covers how to protect a chat system from outsiders, from abusive users, and from its own operators. It assumes you have read the earlier chapters on the WebSocket connection layer, the message flow, and presence. You should be comfortable with HTTP headers, tokens, and basic Python.7 min read