You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
API Gateway for the Minisource microservices ecosystem. Provides unified entry point with authentication, rate limiting, circuit breaking, and request routing.
Features
π 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
# 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
Configuration
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
API Routes
Authentication Routes (Proxied to Auth Service)
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
Notification Routes (Proxied to Notifier Service)
Method
Path
Description
POST
/api/v1/notifications/send
Send notification
GET
/api/v1/notifications
List notifications
Gateway Routes
Method
Path
Description
GET
/health
Gateway health check
GET
/metrics
Prometheus metrics
Makefile Commands
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
Adding New Routes
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
Middleware Stack
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
Docker
# Build image
docker build -t minisource/gateway .# Run container
docker run -p 8080:8080 --env-file .env minisource/gateway