Chapter Eighteen · Problem Twelve
Chat
Real time is what everyone draws. The design rests on something quieter: a number on every message, which sets the order, finds a gap and brings a device back.
"Design a chat app for one-to-one and group conversations, delivered in real time and kept in history on all of a user's devices."
Say chat, and the room expects WebSockets within a minute. Real time takes all the attention, and it is the one part of this design allowed to fail. A push can be lost without harm, because a numbered history underneath it does the correctness: the order every phone shows, the gap a phone notices, the day a device spent away.
Most of the parts are already in your hands. Chapter 2's Stateless Services, Many Copies named a tier that is stateful by design, and the connection gateways are that tier. Chapter 3's Picking the Partition Key worked this very key. Chapter 4's Consistency Models That Come Up gave the promise that a reply never sits above what it answers. Chapter 5's Clocks and Ordering gave the owner that numbers events, and Chapter 6's Delivery Semantics at Scale gave the number that finds a gap.
So at senior level the judgement falls on whether those pieces come out as one answer about order and delivery. Three things separate this from a request and a response. Long-lived connections make a stateful tier, and a message has to find the server holding its recipient. Order and delivery need a number per conversation, acknowledgements, and a way for an absent device to catch up across all of a user's devices. And groups and presence each have a cost that only shows at scale.
Give yourself the whole round before reading further: a timer set to 45 minutes and a blank page. When it rings, test your sketch with one question: if every push in your design were lost, what would the user still see? The lessons keep the same clock, with Scope in minutes zero to ten, First Design in ten to twenty, Scaling It in twenty to thirty, and the deep dives and curveballs in the last fifteen.