Real-time chat
Rooms, messages, receipts, typing, and presence.
Chat has two doors that stay in sync: socket events for live exchange and REST for history and sending from cold state. Every message is stored with a delivery state — sent when the peer is offline, delivered when present, read when the thread opens. Typing and presence are ephemeral broadcasts; only chat content is durable. The Redis adapter lets any instance reach any user room, so the design survives more than one server.
What it owns
- Personal rooms plus secret pair rooms
- Gated sending: connections or active job pairs only
- Sent, delivered, and read message states
- Typing indicators and online presence
- History over REST with pagination
Files
File list and purposes from the folder README.
| File | Purpose |
|---|---|
frontend/src/pages/ChatPage.jsx | Conversations, thread, typing, receipts. |
frontend/src/services/socketService.js | Socket wiring and event mapping. |
frontend/src/services/messageService.js | History and conversation REST calls. |
backend/utils/socket.js | Rooms, events, presence, adapter. |
backend/controllers/messageController.js | History, REST send, conversations. |
backend/models/Chat.js | Participants with embedded messages. |
Laying out Real-time chat slice…
BrowserAPIRealtimeCacheDatabaseShareddurableephemeral
Talks to
Sources: frontend/src/pages/ChatPage.jsx, frontend/src/services/socketService.js, backend/utils/socket.js, backend/models/Chat.js (documented at commit cdef8af)