Distributed real-time chat application built with Go microservices architecture using gRPC for inter-service communication. Features Centrifugo for WebSocket-based real-time messaging, PostgreSQL for persistent data storage, and Fiber for high-performance HTTP routing. Containerized all services with Docker and orchestrated deployments using Docker Compose for development and testing.
- Real-time messaging with WebSocket connections powered by Centrifugo for instant message delivery
- Microservices architecture with independent, scalable services for authentication and chat functionality
- gRPC communication for fast, efficient, and type-safe inter-service messaging between microservices
- RESTful API Gateway using Fiber framework for high-performance HTTP routing and request handling
- JWT-based authentication service for secure user management, registration, and token validation
- Room-based chat system supporting multiple chat rooms with membership management
- Message persistence with full chat history storage and retrieval capabilities
- PostgreSQL as the primary relational database for user data, rooms, and message storage
- Centrifugo as the real-time engine for WebSocket connections and publish-subscribe messaging
- Docker containerization for all microservices ensuring isolated and reproducible environments
- Docker Compose for orchestration and management of all containerized services
- Fiber framework for building high-performance HTTP APIs with minimal memory footprint
- GORM as the ORM for database operations with PostgreSQL
- Protocol Buffers for defining service contracts and generating gRPC client/server code
cd to the project directory and run this command:
docker-compose up --build -dto stop all services:
docker-compose downto stop services and remove database volumes:
docker-compose down -vcurl -X POST http://localhost:8080/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "john_doe",
"email": "john@example.com",
"password": "password123"
}'curl -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "john@example.com",
"password": "password123"
}'curl -X POST http://localhost:8080/api/v1/auth/validate \
-H "Content-Type: application/json" \
-d '{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}'curl -X GET http://localhost:8080/api/v1/auth/profile \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."curl -X POST http://localhost:8080/api/v1/chat/rooms \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-d '{
"name": "General Chat",
"description": "General discussion room for everyone"
}'curl -X GET http://localhost:8080/api/v1/chat/rooms \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."curl -X POST http://localhost:8080/api/v1/chat/rooms/join \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-d '{
"room_id": "room-1234-5678-90ab-cdef12345678"
}'curl -X POST http://localhost:8080/api/v1/chat/messages \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-d '{
"room_id": "room-1234-5678-90ab-cdef12345678",
"content": "Hello everyone! How are you doing today?"
}'curl -X GET "http://localhost:8080/api/v1/chat/rooms/room-1234-5678-90ab-cdef12345678/messages?limit=20" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."curl -X GET http://localhost:8080/api/v1/health