API Gateway for the Minisource microservices ecosystem. Provides unified entry point with authentication, rate limiting, circuit breaking, and request routing.
- π Reverse Proxy - Route requests to backend services
- π JWT Authentication - Validate and forward authentication tokens
- β‘ Rate Limiting - Redis-backed rate limiting per client
- π Circuit Breaker - Automatic failover and recovery
- π Tracing - OpenTelemetry distributed tracing
- π₯ Health Checks - Monitor backend service health
- π‘οΈ Security Headers - CORS, CSP, and security middleware
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Gateway (:8080) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββ βββββββββββ βββββββββββ βββββββββββ β
β β Auth β β Rate β β Circuit β β Tracing β β
β β Middle β β Limiter β β Breaker β β β β
β ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ β
β ββββββββββββββ΄βββββββββββββ΄βββββββββββββ β
β β β
β βββββββΌββββββ β
β β Proxy β β
β β Router β β
β βββββββ¬ββββββ β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Auth β β Notifier β β Other β
β :9001 β β :9002 β β Services β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
- Go 1.24+
- Redis 7+
- Docker & Docker Compose (optional)
# Clone repository
git clone https://github.com/minisource/gateway.git
cd gateway
# Copy environment file
cp .env.example .env
# Run with Docker Compose
make docker-up
# Or run locally
make run| Variable | Description | Default |
|---|---|---|
SERVER_PORT |
Gateway port | 8080 |
SERVER_HOST |
Bind address | 0.0.0.0 |
AUTH_SERVICE_URL |
Auth service URL | http://localhost:9001 |
NOTIFIER_SERVICE_URL |
Notifier service URL | http://localhost:9002 |
REDIS_HOST |
Redis host | localhost |
REDIS_PORT |
Redis port | 6379 |
JWT_SECRET |
JWT signing secret | Required |
RATE_LIMIT_ENABLED |
Enable rate limiting | true |
RATE_LIMIT_RPS |
Requests per second | 100 |
CIRCUIT_ENABLED |
Enable circuit breaker | true |
TRACING_ENABLED |
Enable OpenTelemetry | true |
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/auth/register |
User registration |
| POST | /api/v1/auth/login |
User login |
| POST | /api/v1/auth/refresh |
Refresh token |
| POST | /api/v1/auth/logout |
User logout |
| GET | /api/v1/auth/me |
Get current user |
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/notifications/send |
Send notification |
| GET | /api/v1/notifications |
List notifications |
| Method | Path | Description |
|---|---|---|
| GET | /health |
Gateway health check |
| GET | /metrics |
Prometheus metrics |
make build # Build binary
make run # Run locally
make test # Run tests
make lint # Run linter
make docker-build # Build Docker image
make docker-up # Start with docker-compose
make docker-down # Stop containers- Add service configuration in
config/config.go - Create handler in
internal/handler/ - Add proxy configuration in
internal/proxy/ - Register routes in
internal/router/router.go
- Recovery - Panic recovery
- Request ID - Add unique request ID
- Logger - Request logging
- CORS - Cross-origin resource sharing
- Rate Limiter - Request rate limiting
- Auth - JWT validation (protected routes)
- Circuit Breaker - Failure isolation
# Build image
docker build -t minisource/gateway .
# Run container
docker run -p 8080:8080 --env-file .env minisource/gateway.env.example- Template configuration.env- Local development (git ignored).env.production- Production settings
gateway/
βββ cmd/
β βββ main.go # Entry point
βββ config/
β βββ config.go # Configuration loading
βββ internal/
β βββ handler/ # Request handlers
β βββ middleware/ # Custom middleware
β βββ proxy/ # Reverse proxy logic
β βββ router/ # Route definitions
βββ docker-compose.yml # Base compose
βββ docker-compose.dev.yml # Development compose
βββ docker-compose.prod.yml # Production compose
βββ Dockerfile # Container build
βββ Makefile # Build commands
MIT