Skip to content

Volynskyi-Kirill/go-messanger

Repository files navigation

Go Messenger Microservices

A modern, scalable chat application built with Go, leveraging a microservices architecture. This project is currently under active development.

🏗 Architecture Overview

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
Loading

Services

  • 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-ID headers 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.

🛠 Tech Stack

🚀 Getting Started

Prerequisites

  • Go 1.22+
  • Docker & Docker Compose
  • Task (optional, but recommended)

Installation

  1. Clone the repository:

    git clone https://github.com/StradaOne/public-go-msg.git
    cd public-go-msg
  2. 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
  3. Start infrastructure (DB & RabbitMQ):

    task docker-compose-up
  4. Run migrations:

    # Make sure you have golang-migrate installed
    go run gateway/cmd/migrate-cli/main.go up

Running the Services

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-up

Using 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.go

📋 Available Commands

We 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

🧪 Testing

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages