A fully-featured chat API built with Golang, GIN, Redis, PostgreSQL, Prometheus, Grafana, and OpenTelemetry for observability and monitoring.
- User Authentication with JWT
 - Real-time Chat with WebSockets
 - PostgreSQL for persistent data storage
 - Redis for caching and WebSocket connection management
 - Prometheus for collecting metrics
 - Grafana for visualizing metrics and logs
 - OpenTelemetry for tracing and observability
 - Rate Limiting Middleware
 
- Docker and Docker Compose
 - Golang 
v1.22.6 - Make (for running database migrations)
 
Create a .env file in the project root with the following configuration:
# App configuration
PORT=8080
# PostgreSQL database configuration
DB_HOST=postgres
DB_PORT=5432
DB_USER=postgres
DB_PASS=yourpassword
DB_NAME=chatdb
# Redis configuration
REDIS_HOST=redis
REDIS_PORT=6379Clone the repository:
git clone https://github.com/joshbarros/golang-chat-api.git
cd golang-chat-apiStart the services with Docker Compose:
docker-compose up -dThe API will be available at http://localhost:8080.
Access Grafana at http://localhost:3000 with credentials admin/admin.
Prometheus metrics will be available at http://localhost:9090.
Chat API metrics are exposed at /metrics.
You can use Make to easily manage database migrations.
- Apply migrations (migrate-up):
 
 make migrate-up- Rollback migrations (migrate-down):
 
make migrate-down- 
User Registration: POST /register
{ "username": "testuser", "password": "password123" } - 
User Login: POST /login
{ "username": "testuser", "password": "password123" } 
ws://localhost:8080/ws/{roomID}Prometheus scrapes metrics from the chat API at /metrics. Grafana provides visual dashboards for performance and monitoring data.
This project is licensed under the MIT License.