Lesson 4 of 17
38. Design a Chat App (WhatsApp)

38.3 What are the doors?

3 min read+10 XP

Step 3: API and data model (10 minutes)

Chat runs over a WebSocket per device (Chapter 21), with small messages both ways:

client → server { "type": "send", "chat": "c1", "client_id": "a-002", "body": "<ciphertext>" } server → client { "type": "ack", "client_id": "a-002", "seq": 2 } ← one tick server → client { "type": "msg", "chat": "c1", "seq": 2, "from": "asha", "body": "<ciphertext>" } client → server { "type": "delivered", "chat": "c1", "upto": 2 } ← device has it client → server { "type": "read", "chat": "c1", "upto": 2 } ← user saw it client → server { "type": "sync", "chat": "c1", "after": 2 } ← after reconnecting

Plus HTTPS for login, contacts, group management, and media upload (presigned URLs, Chapter 11).