A modern, scalable chat application built with Go, leveraging a microservices architecture. This project is currently under active development.
The system follows a microservices pattern where each service is responsible for a specific domain. Communication happens via synchronous REST APIs (through the Gateway) and asynchronous events (via RabbitMQ).
graph TD
Client[Mobile/Web Client] --> Gateway[API Gateway :8080]
Gateway --> |Auth & Proxy| ChatService[Chat Service]
Gateway --> |Auth & Proxy| MessageService[Message Service]
Gateway --> |Real-time| WSGateway[WS Gateway WIP]
ChatService <--> RabbitMQ((RabbitMQ))
MessageService <--> RabbitMQ
WSGateway <--> RabbitMQ
Gateway --- DB[(PostgreSQL)]
ChatService --- DB
MessageService --- DB
- API Gateway: The entry point for all client requests.
- Handles Authentication (Registration, Login, JWT).
- Manages User Profiles and Search.
- Acts as a Reverse Proxy, injecting
X-User-IDheaders into requests for internal services.
- Chat Service: Manages the lifecycle of chats and group conversations.
- Chat creation and deletion.
- Member management (invite, leave, promote to admin).
- Unread message counters.
- Message Service: Dedicated to handling high-volume message data.
- Message CRUD operations.
- Chat history retrieval.
- Message search.
- WS Gateway (WIP): Handles persistent WebSocket connections for real-time message delivery and notifications.
- Language: Go (Golang)
- Framework: Gin Gonic (HTTP Web Framework)
- Database: PostgreSQL with GORM
- Messaging: RabbitMQ for asynchronous events
- Auth: JWT (JSON Web Tokens)
- Infrastructure: Docker & Docker Compose
- Task Management: Taskfile
- Go 1.22+
- Docker & Docker Compose
- Task (optional, but recommended)
-
Clone the repository:
git clone https://github.com/StradaOne/public-go-msg.git cd public-go-msg -
Set up environment variables: Each service has its own
.env.template. Copy them to.env:cp gateway/.env.template gateway/.env cp chat-service/.env.template chat-service/.env cp message-service/.env.template message-service/.env
-
Start infrastructure (DB & RabbitMQ):
task docker-compose-up
-
Run migrations:
# Make sure you have golang-migrate installed go run gateway/cmd/migrate-cli/main.go up
You can run services individually using go run or all at once using Docker:
Using Docker (Development Mode with Hot Reload):
task docker-compose-dev-upUsing Go directly:
# In separate terminals:
go run gateway/cmd/server/main.go
go run chat-service/cmd/server/main.go
go run message-service/cmd/server/main.goWe use Taskfile to simplify common operations:
| Command | Description |
|---|---|
task dcu |
Start infrastructure containers |
task dcdd |
Stop infrastructure containers |
task dcc |
Clean database (remove volumes) |
task te |
Run E2E tests |
task tu |
Run unit tests |
task cm -- name |
Create a new database migration |
The project includes unit and E2E tests. E2E tests automatically spin up a test database and RabbitMQ instance.
# Run all tests
task test-all
# Run E2E tests specifically
task test-e2e