learn

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.

FilePurpose
frontend/src/pages/ChatPage.jsxConversations, thread, typing, receipts.
frontend/src/services/socketService.jsSocket wiring and event mapping.
frontend/src/services/messageService.jsHistory and conversation REST calls.
backend/utils/socket.jsRooms, events, presence, adapter.
backend/controllers/messageController.jsHistory, REST send, conversations.
backend/models/Chat.jsParticipants with embedded messages.
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)

On this page