GoChat App
Realtime messaging built on a Go WebSocket hub
GoChat App
Next.js 15TypeScriptshadcn/uiRadix UIGoWebSocketDockerJWT




Description
GoChat is a production-grade realtime chat system powered by a Go WebSocket hub and a Next.js frontend. The hub uses lightweight goroutines and channels for efficient fanout and backpressure control, while the frontend (App Router + TypeScript + shadcn/ui) provides accessible components and responsive UX. Design choices prioritize correctness (ordering, ACKs), resilience (reconnect/heartbeats), and scale-out via stateless nodes and pub/sub.
Key Features
- Channels & DMs — structured conversations with role/permission checks so teams mirror Slack/WhatsApp mental models and ramp quickly.
- Presence — online/offline and typing indicators derived from heartbeats and ephemeral maps for accurate, low-latency status.
- Message lifecycle — server assigns sequence IDs; clients ACK and persist, enabling delivery/read receipts and deterministic ordering.
- Media — uploads with size/type validation and server-side sanitization to keep the hub safe and performant under load.
- Auth — JWT-secured endpoints with refresh; WebSocket re-auth is stateless to simplify reconnect flows.
- Storage — durable history with pagination and search; indexes sized for large rooms and fast scrollback retrieval.
- Safety — per-connection rate limits and backpressure to prevent flood attacks and protect the event loop.
Challenges and Solutions
- Concurrency — goroutine-safe hubs with disciplined mutex usage and atomic counters to avoid races under broadcast pressure.
- Ordering & delivery — sequence IDs with at-least-once guarantees; client-side de-duplication preserves UX during reconnects.
- Scale-out — stateless nodes behind sticky sessions plus pub/sub (e.g., Redis) fanout, enabling horizontal scaling without cross-talk.
- Resilience — exponential backoff, heartbeat timeouts, and jittered retries to survive flaky networks gracefully.