Selected work / Communication / Distributed systems
Real-time Chat Service
Room-based messaging through WebSockets, Kafka, and PostgreSQL.
From one message.To a shared conversation.
A message crosses several boundaries before it becomes a conversation. This project explores those boundaries explicitly.
Follow the story- Built for
- Exploring a real engineering problem
- Format
- Repository-based architecture study
- Evidence
- Source reviewed / demo not published here
01 / The problem
Instant has a sequence behind it.
Authentication, room membership, delivery, and message history have to work together. A queue separates message submission from consumer work, but the exact broadcast order determines what users experience when storage slows down.
From the friction → to the system02 / Architecture
Trace what happens before delivery.
Follow one journey through the system.
- 01WebSocketAuthenticated room message
- 02KafkaKeyed by roomId
- 03PostgreSQLConsumer saves message
- 04BroadcastConsumer sends to room
Not a product screenshot
WebSocket
An authenticated user sends a message to a room over WebSocket.
Kafka
The producer publishes the event to Kafka, using roomId as its key.
PostgreSQL
The consumer awaits the PostgreSQL write. This is an important boundary: slow storage still affects delivery.
Broadcast
Only after saving does the consumer broadcast to the room. Recovery and multi-instance delivery remain verification work.
The Turborepo contains backend, frontend, and ws apps. The current consumer awaits the database write before broadcasting. Therefore delivery still depends on storage, even though the WebSocket handler publishes through Kafka.
Inside the implementation
The details
make the difference.
A closer look at the decisions, boundaries, and work still ahead.
Engineering notes / 01
The implemented path
JWT authentication and room management support WebSocket messaging. The producer sends chat-messages events using roomId as the Kafka key. The consumer creates a database message, then broadcasts chat:new to the room.
Using a room key groups that room's messages by partition under a stable partitioning setup. It does not by itself prove ordering across changes to partitions, consumers, or application instances.
Engineering notes / 02
What still needs hardening
The producer catches and logs Kafka send failures; the consumer catches processing errors. These paths do not substantiate a no-message-loss guarantee. Consumer downtime, replay, failed writes, and duplicate processing need explicit tests.
Room membership is held by the WebSocket process. A multi-instance broadcast strategy has not been demonstrated here. History pagination, offline catch-up, and token handling also belong in the verification plan.
Engineering notes / 03
Evidence to collect next
A two-browser room demo would establish the visible messaging flow. A reproducible test should then record concurrent connections, messages sent and received, duplicate counts, and behavior during consumer or database failure.
Scope & evidence
What this page establishes.
Source reviewed; no concurrent-connection benchmark, zero-loss test, or storage-independent delivery claim is made.