techdiagrams.net
← All templates

Chat that never loses a message

WhatsApp-shaped messaging: a connection registry finds the recipient's gateway, delivery is at-least-once with client-side dedup, and offline users fall back to push.

Open in editor — free, no login Download JSON
AT-LEAST-ONCE INSIDE — EXACTLY-ONCE IS THE CLIENT'S DEDUPmsg · client-id 8812persist BEFORE ackenqueue deliverywhere is Bob?push over socketheartbeatsno socket → notifyAlicesends: client msg-id 8812Gateway A1M held socketsPresenceonline · typing · last-seenChat Servicepersist FIRST, then ackMessage Storeconversation-shardedDelivery Queueper-recipient · at-least-onceConnection Registrybob → gateway BDelivery Workerscompeting consumersGateway Bholds Bob's socketBobdedupes by msg-idAPNs / FCMoffline fallbackthe reliability chain:1. persisted before Alice sees ✓2. redelivery allowed end-to-end3. Bob renders msg-id 8812 once, however many times it arrives

What this design does

Chat feels simple until you hold a million sockets: the sender's gateway isn't the recipient's, 'delivered' must survive crashes between the two, and phones vanish mid-conversation. This design persists before acking (a message the server said 'sent' about can never be lost), routes through a connection registry that knows which gateway holds which user, delivers at-least-once, and lets the client's message-id dedup turn that into exactly-once on screen. No socket? The same delivery worker falls back to push.

The patterns it composes

Import it, attach your own numbers, and verify the design against failures — or read the engineering notes.