A production-inspired distributed real-time messaging backend β 6 independent Go microservices communicating through WebSockets, Redis Pub/Sub, and Kafka. Built to demonstrate strong system design and backend engineering skills.
- ποΈ 6 Independent Microservices β each fault-isolated with its own DB connection, config, and entry point
- π‘ WebSocket Real-Time Delivery β persistent bi-directional connections for instant messaging
- β‘ Redis Pub/Sub β low-latency message fan-out across service instances
- π¨ Kafka Event Streaming β durable async processing, guaranteed message delivery
- πΎ MongoDB β flexible document storage for chats and messages
- π JWT Authentication β access + refresh token flow across all services
- π³ Fully Dockerized β all 6 services + infrastructure via Docker Compose
- π§± Clean Architecture β handler β service β repository layering in every service
βββββββββββββββββββ
β API Gateway β
ββββββββββ¬βββββββββ
β
ββββββββββββββββββββββββΌβββββββββββββββββββββββ
β β β
ββββββββΌβββββββ ββββββββββΌββββββββ ββββββββββΌββββββββ
β Auth Serviceβ β User Service β β Chat Service β
β JWT tokens β β Profile mgmt β β Groups/1-on-1 β
βββββββββββββββ ββββββββββββββββββ ββββββββββββββββββ
βββββββββββββββ ββββββββββββββββββ ββββββββββββββββββ
β Message β β Notification β β WebSocket β
β Service β β Service β β Service β
β Send/Edit β β Kafka-driven β β Real-time hub β
ββββββββ¬βββββββ βββββββββ¬βββββββββ βββββββββ¬βββββββββ
β β β
βββββββββββββββββββββββΌββββββββββββββββββββββ
β
βββββββββββββββββββΌββββββββββββββββββ
β β β
ββββββββΌβββββββ βββββββββΌβββββββ ββββββββΌβββββββ
β MongoDB β β Kafka β β Redis β
β Messages β β Events β β Pub/Sub β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
Client β WebSocket Service β Redis Pub/Sub β Kafka β Message Service β MongoDB β Broadcast
| Layer | Technology |
|---|---|
| Language | Go 1.21+ |
| HTTP Framework | Fiber |
| Real-Time | WebSockets (gorilla/websocket) |
| Event Streaming | Kafka |
| Pub/Sub | Redis |
| Database | MongoDB |
| Authentication | JWT (access + refresh tokens) |
| Containerization | Docker + Docker Compose |
- User registration and login
- JWT access token + refresh token issuance
- Token validation middleware
- Fetch and update user profile
- Delete account
- User search
- Create 1-on-1 chats
- Create and manage group chats
- Add/remove group members
- Send, receive, edit, delete messages
- Mark messages as read
- Message history with pagination
- Kafka-driven async notification processing
- User notification delivery
- Event-based triggers
- Maintains persistent WebSocket connections
- Publishes events to Redis Pub/Sub for real-time fan-out
- Forwards durable message events to Kafka
chat-app/
βββ backend/
β βββ api-gateway/ # Request routing
β βββ services/
β βββ auth-service/
β β βββ cmd/ # Entry point
β β βββ internal/ # Handler Β· Service Β· Repository
β β βββ configs/ # Environment config
β β βββ .env.example
β βββ user-service/
β βββ chat-service/
β βββ message-service/
β βββ notification-service/
β βββ websocket-service/
βββ docs/ # Architecture diagrams
βββ postman/ # API collection
βββ docker-compose.yaml # Full stack orchestration
βββ dockerfile
Each service follows Clean Architecture:
cmd/ β entry point, dependency wiring
internal/ β handler β service β repository
configs/ β environment-based config
- Go 1.21+
- Docker & Docker Compose
git clone https://github.com/fathimasithara01/chat-app.git
cd chat-app/backend# For each service
cp services/auth-service/.env.example services/auth-service/.env
cp services/user-service/.env.example services/user-service/.env
# ... repeat for other servicesdocker-compose up --buildThis starts all 6 microservices + MongoDB + Redis + Kafka together.
| Method | Path | Description |
|---|---|---|
| POST | /auth/register |
Register new user |
| POST | /auth/login |
Login β returns JWT pair |
| POST | /auth/refresh |
Refresh access token |
| POST | /auth/logout |
Logout |
| Method | Path | Description |
|---|---|---|
| GET | /users/:id |
Get user profile |
| PATCH | /users/:id |
Update profile |
| DELETE | /users/:id |
Delete account |
| Method | Path | Description |
|---|---|---|
| POST | /chats |
Create 1-on-1 chat |
| POST | /chats/group |
Create group chat |
| PATCH | /chats/:id/members |
Add/remove members |
| GET | /chats |
List user's chats |
| Method | Path | Description |
|---|---|---|
| POST | /messages |
Send message |
| GET | /messages/:chatId |
Get message history |
| PATCH | /messages/:id |
Edit message |
| DELETE | /messages/:id |
Delete message |
ws://localhost:PORT/ws?token=<jwt>
Why Redis Pub/Sub + Kafka together? Redis handles low-latency real-time fan-out β messages reach online users instantly. Kafka provides durability β events are persisted and processed asynchronously even if a service is temporarily down.
Why separate WebSocket service? Isolating WebSocket connections in their own service means connection state is independent of business logic. Other services simply publish to Redis β they don't need to know which users are connected.
Why Fiber? Fiber's fasthttp foundation handles high concurrency well β important for a chat backend where many connections are open simultaneously.
Import postman/ collection into Postman to test all services. Set base_url per service and use Auth endpoints to get your JWT token automatically.
Fathima Sithara β Backend Engineer (Go Β· Distributed Systems)
Also check out:
- π¦ MultiTrade Platform β Production-grade trading backend in Go
- π E-Commerce Platform β Next.js + Node.js full-stack app
β If this project helped you, please give it a star!