A microservice-based IM system built with Go.
- 🚀 Private & Group Chat
- 📞 Audio/Video Calls
- 📁 File Transfer
- ✅ Message Read Receipts
- 🔄 Multi-device Sync
- 📱 Offline Push Notifications
- Language: Go 1.24.9+
- Database: PostgreSQL 18+
- Cache: Redis 7.0+
- Message Queue: NATS
- Object Storage: MinIO
- Audio/Video: LiveKit
- Monitoring: Prometheus + Grafana
- Tracing: Jaeger
- Build Tool: Mage
- Go 1.24.9+
- Docker 28.1.1+ & Docker Compose 2.35.1+
- protoc 3.12.4+ (for gRPC code generation, requires
--experimental_allow_proto3_optional) - Mage (build tool)
go install github.com/magefile/mage@latest# 1. Clone the repository
git clone https://github.com/yzhgit/anychat-server
cd server
# 2. Install dependencies
mage deps
# 3. Install development tools (optional)
mage install
# 4. Start infrastructure services
mage docker:up
# 5. Run database migrations
mage db:up
# 6. Start services
mage dev:auth
mage dev:gatewayanychat_server/
├── api/ # API definitions
│ └── proto/ # gRPC definitions
├── cmd/ # Application entry points
├── internal/ # Private code
├── pkg/ # Shared libraries
├── deployments/ # Deployment configurations
├── configs/ # Configuration files
├── migrations/ # Database migrations
├── docs/ # Documentation
│ └── api/swagger/ # OpenAPI specifications (auto-generated)
├── tests/ # Tests
└── magefile.go # Mage build scripts
# List all available commands
mage -l
# Build all services
mage build:all
# Build specific service
mage build:auth
mage build:gateway
# Build Docker images
mage docker:build# Run all tests
mage test:all
# Run unit tests
mage test:unit
# Generate coverage report
mage test:coverage
# Code linting
mage lint
# Code formatting
mage fmtmage build:all- Build all servicesmage build:auth- Build auth servicemage build:user- Build user servicemage build:gateway- Build gateway servicemage build:message- Build message service
mage dev:auth- Run auth servicemage dev:gateway- Run gateway servicemage dev:message- Run message servicemage proto- Generate protobuf code
mage docker:up- Start all containersmage docker:down- Stop all containersmage docker:build- Build Docker imagesmage docker:logs- View logsmage docker:ps- View container status
mage db:up- Run database migrationsmage db:down- Rollback database migrationsmage db:create <name>- Create new migration file
mage docs:generate- Generate API documentationmage docs:serve- Start documentation server (http://localhost:3000)mage docs:build- Build documentation sitemage docs:validate- Validate API documentation
mage deps- Install dependenciesmage install- Install development toolsmage clean- Clean build artifactsmage mock- Generate mock code
- Full Documentation Site: GitHub Pages (auto-deployed)
- Local Preview: Run
mage docs:serveand visit http://localhost:3000
- Getting Started - Beginner guide
- API Documentation - Interactive HTTP API documentation
- System Design - Architecture design document
- Writing API Documentation - How to write API documentation
# Generate API documentation
mage docs:serve
# Preview documentation site locally
mage docs:build- Trigger: Push to main branch or create Pull Request
- Deployment Target: GitHub Pages
- Documentation URL: https://yzhgit.github.io/anychat-server/
Documentation is automatically updated when:
- Gateway service code changes
- Documentation files change
- CI configuration changes
Add Swagger annotations for Gateway HTTP endpoints:
// Login user login
// @Summary User login
// @Description User login with username and password
// @Tags Authentication
// @Accept json
// @Produce json
// @Param request body LoginRequest true "Login information"
// @Success 200 {object} response.Response{data=AuthResponse} "Login successful"
// @Failure 400 {object} response.Response "Invalid parameters"
// @Router /auth/login [post]
func (h *AuthHandler) Login(c *gin.Context) {
// ...
}See Writing API Documentation Guide for details.
Pull Requests and Issues are welcome.
MIT License - See LICENSE file