How theproject24/nexus_chat works
Nexus Chat is a Go multi-room WebSocket gateway. A browser or other WebSocket client connects through the HTTP entrypoint; the client lifecycle parses join, leave, ping and room-event frames, and the hub serializes membership, history replay and pub/sub fan-out. Redis-compatible storage handles room publication and the last 50 messages; HTTP endpoints expose health and room summaries. The README also documents a browser tester. Architecture links reflect the sampled Go source and documented behavior; Titan KV is external and its implementation is not in this repository.
Main entry points: hub.go Hub event loop · client.go Client lifecycle · main.go HTTP gateway · tester.html Browser tester
Components 17
Gateway entry
- HTTP gateway
cmd/server/main.go - WebSocket endpoint
cmd/server/main.go
WebSocket clients
- Client lifecycle
internal/client/client.go - Frame reader
internal/client/client.go - Frame writer
internal/client/client.go
Room routing
- Hub event loop
internal/client/hub.go - Room membership
internal/client/hub.go - Room dispatch
internal/client/hub.go - History replay
internal/client/hub.go - Room subscriber
internal/client/hub.go
Message backend
- Room pub/sub
internal/client/hub.go - Room history
internal/client/hub.go
Status inspection
- Health endpoint
internal/client/hub.go - Room summary endpoint
internal/client/hub.go
Other components
- Browser client
- Redis-compatible service
- Browser tester
tester.html
Connections 29
- Browser client → HTTP gateway: HTTP requests
- HTTP gateway → Redis-compatible service: pings
- HTTP gateway → Hub event loop: starts loop
- HTTP gateway → WebSocket endpoint: routes /ws
- Browser client → WebSocket endpoint: opens WebSocket
- WebSocket endpoint → Client lifecycle: creates client
- Client lifecycle → Frame reader: starts read pump
- Client lifecycle → Frame writer: starts write pump
- Frame reader → Hub event loop: queues room events
- Hub event loop → Room membership: handles membership
- Hub event loop → Room dispatch: handles broadcasts
- Hub event loop → History replay: loads on join
- Hub event loop → Room subscriber: starts per room
- Room membership → Client lifecycle: queues outbound
- Room dispatch → Redis-compatible service: publishes and stores
- Room dispatch → Room pub/sub: publishes room event
- Room dispatch → Room history: appends and trims
- Room subscriber → Room pub/sub: subscribes
- Room pub/sub → Hub event loop: queues received event
- Hub event loop → Client lifecycle: fans out payload
- History replay → Room history: reads recent messages
- History replay → Client lifecycle: queues replay
- Hub event loop → Health endpoint: serves stats
- Hub event loop → Room summary endpoint: serves room counts
- Health endpoint → Redis-compatible service: checks reachability
- Health endpoint → Hub event loop: queries counts
- Room summary endpoint → Hub event loop: queries membership
- Client lifecycle → Frame writer: sends queued frames
- Browser tester → WebSocket endpoint: connects manually