Design a Chat Application
Deliver live messages without losing them by separating durable messages from fan-out, presence and offline notifications.
Chat separates durable conversation storage from WebSocket fan-out, presence and offline push paths
Persist a message before acknowledging it, then publish a durable event for recipients. A client idempotency key makes reconnect/retry safe. Order messages by conversation key, not globally.
Presence is temporary state with TTL heartbeats; delivery and read receipts are durable state transitions. Offline push comes from the durable event, not an in-memory gateway.