GoChat is a mobile‑first real‑time chat backend built with Go. The project is designed for learning purpose with clean architecture, domain‑driven principles, and scalability in mind.
- Real‑time messaging support
- JWT‑based authentication
- Clean architecture (domain‑first design)
- Versioned REST APIs
- WebSocket support for live messaging
- MySQL‑backed persistence
- Production deployment on Railway
- Mobile‑friendly API contracts (Android & iOS)
GoChat exposes a fully documented REST API using Swagger (OpenAPI).
The latest API documentation is available here:
🔗 https://gochat-production-0f79.up.railway.app/swagger/index.html
This UI provides:
- Complete endpoint listings
- Request/response schemas
- Authentication details
- Ability to try APIs directly from the browser
When running the server locally, Swagger UI is available at: http://localhost:8080/swagger/index.html
Note: The Swagger documentation is generated from code annotations and always reflects the current API implementation.
GoChat follows Clean Architecture, ensuring that business logic is independent of frameworks, databases, and delivery mechanisms.
-
Domain Core business entities, value objects, and repository contracts. No external dependencies.
-
Use Cases (Application Layer) Application‑specific business rules. Orchestrates domain logic and enforces workflows.
-
Infrastructure Database implementations, external services, persistence models, and framework integrations.
-
Delivery (HTTP / WebSocket) REST APIs, WebSocket handlers, middleware, and request/response mapping.
- API Gateway / HTTP layer
- Authentication flow (JWT)
- WebSocket real‑time messaging
- Use case orchestration
- Database interactions (MySQL)
/api/v1/health
/api/v1/auth/*
/api/v1/conversations
/api/v1/messages
/api/v1/ws
GET /api/v1/healthReturns service status and is used for deployment health checks.
- JWT‑based access tokens
- Refresh token support (TODO)
- Token validation middleware
- Designed for mobile‑first usage
The backend is deployed on Railway using GitHub Actions.
- Automatic deployment on push to
main - Environment‑based configuration
- Secure secret management via GitHub Secrets
- Android: Jetpack Compose, MVI, Offline‑first
- iOS: SwiftUI or Kotlin Multiplatform (TBD)
The backend API contracts are designed to support both platforms consistently.
- Language: Go
- Framework: Gin
- Database: MySQL
- ORM: GORM
- Auth: JWT
- Real‑time: WebSockets
- Deployment: Railway
- swaggo/swag Swagger Docs
internal/
auth/
chat/
domain/
usecase/
repository/
handler/
infrastructure/
cmd/
- Unit tests for domain and use cases
- Repository tests with test containers
- API contract tests
MIT License