Collab is a multilingual real-time chat app built as a monorepo with a microservice-style architecture. Services communicate over HTTP, WebSocket, gRPC, and Redis — each one scoped to a single responsibility.
Next.js · WebSocket · gRPC · Redis Pub/Sub + Streams · PostgreSQL · Prisma
The idea is simple: split the work across focused services so each piece stays small, testable, and independently scalable.
web— Next.js frontend. Auth, room listing, chat UI.http-service— REST APIs for users and rooms. Also issues short-lived WebSocket tickets.ws-service— Holds WebSocket connections, validates tickets, pushes live updates to clients.chat-service— Handles message operations (create, edit, delete, fetch) and publishes events to Redis.db-service— Exposes gRPC APIs for rooms, users, and messages. Runs a background worker that drains Redis streams into PostgreSQL.
- Client calls
http-serviceto get a short-lived WebSocket ticket. - Client connects to
ws-serviceusing that ticket. - Client sends a message through
chat-service. chat-servicefetches room/member data fromdb-serviceover gRPC.chat-servicepublishes the message to Redis Pub/Sub.ws-servicepicks it up and pushes it to connected clients in real time.db-serviceconsumes from the Redis stream and persists the message to PostgreSQL.
Keeping services separate means the WebSocket layer can scale independently from the database layer. Redis handles fast fan-out so ws-service never has to know about storage, and db-service never has to know about live connections. Each service has one job and one reason to change.