Zena (ዜና) Chat
LiveFault-tolerant real-time messaging engine built for patchy networks, featuring offline IndexedDB outbox, Redis pub/sub clustering, and optimistic receipts.
Live Application: zena-chat.vercel.app
Source Repository: github.com/PROFESSOR-ADNAN/zena-chat
The problem
Standard real-time chat apps assume low-latency, stable broadband connections. When deployed across East Africa, mobile users frequently move between fluctuating 3G, 4G, and dead zones. Under these conditions, traditional socket connections drop packets, leave users staring at spinning loaders, duplicate messages on retry, or drop outgoing messages entirely.
The solution
Zena (ዜና, "news" or "message" in Amharic) is a resilient, low-latency messaging engine engineered specifically for unstable networks. It combines an offline-first IndexedDB outbox on the client with horizontal Redis Pub/Sub clustering on the backend to deliver seamless messaging with zero packet loss.
Engineering highlights
- Offline-first outbox & automatic reconciliation: Messages composed while offline are stored immediately in client-side IndexedDB storage with a local UUID. Once connectivity is restored, an outbox sync worker drains pending messages in chronological order, deduplicating messages via idempotent server keys.
- Horizontal WebSocket scaling via Redis Pub/Sub: Multiple Node.js / Socket.IO instances run behind an Nginx load balancer. Socket broadcast events are coordinated across instances using Redis 7 Pub/Sub, allowing users connected to different replicas to exchange instant messages seamlessly.
- Optimistic message rendering & state progression: Messages appear in the feed instantaneously in an "outgoing" state, transitioning through a precise receipt lifecycle:
queued→sent→delivered→readwith acknowledgment callbacks. - Ephemeral presence heartbeats: Ephemeral user presence (online, offline, last seen) is maintained in Redis using TTL keys refreshed via lightweight WebSocket pings, automatically expiring ghost connections if a device loses power or signal abruptly.
Review & architectural takeaways
Designing for real-world network conditions requires moving away from naive client-server assumptions. Treating the local client database as the primary source of truth for outgoing messages eliminated the UI freezes and lost state that plague chat applications operating on intermittent cellular data.
Next up
Qelem (ቀለም) →