API Gateway
Central entry point for all API requests, providing request routing, TLS termination, rate limiting, and JWT validation for the issue tracker platform.
Service Structure
├── main.py # FastAPI application entrypoint
├── config/
│ ├── traefik.yml # Traefik static configuration
│ └── dynamic.yml # Traefik dynamic configuration
└── requirements.txt # Python dependencies (httpx)
Features
Request Routing
- Path-based routing: Routes requests to appropriate backend services
- Service discovery: Automatic service endpoint resolution
- Load balancing: Round-robin load distribution
Security
- JWT Validation: Validates JWT tokens before forwarding requests
- Rate Limiting: Per-client rate limiting
- CORS: Configurable Cross-Origin Resource Sharing
- TLS Termination: Handles HTTPS termination
Observability
- Request Logging: Structured logging for all requests
- Health Checks: Service health endpoints
- Metrics: Request latency, error rates, throughput
Service Mapping
| Path Prefix | Backend Service | Port |
|---|---|---|
| /api/v1/auth | auth-service | 8001 |
| /api/v1/users | user-service | 8002 |
| /api/v1/projects | project-service | 8003 |
| /api/v1/issues | issue-service | 8004 |
| /api/v1/comments | comment-service | 8005 |
| /api/v1/notifications | notification-service | 8006 |
| /api/v1/search | search-service | 8007 |
| /api/v1/audit | audit-service | 8008 |
API Endpoints
Health Check
GET /health
Response:
{
"status": "healthy",
"service": "api-gateway",
"version": "1.0.0"
}
Ping (Traefik)
GET /ping
Response: 200 OK
Configuration
Environment variables (in .env):
# Service
SERVICE_NAME=api-gateway
SERVICE_VERSION=1.0.0
ENVIRONMENT=development
# Backend Services
AUTH_SERVICE_URL=http://auth-service:8000
USER_SERVICE_URL=http://user-service:8000
PROJECT_SERVICE_URL=http://project-service:8000
ISSUE_SERVICE_URL=http://issue-service:8000
COMMENT_SERVICE_URL=http://comment-service:8000
NOTIFICATION_SERVICE_URL=http://notification-service:8000
SEARCH_SERVICE_URL=http://search-service:8000
AUDIT_SERVICE_URL=http://audit-service:8000
# Security
SECRET_KEY=your-secret-key-change-in-production
ALGORITHM=HS256
# Rate Limiting
RATE_LIMIT_REQUESTS=100
RATE_LIMIT_WINDOW=60
Traefik Configuration
The gateway uses Traefik v2.10 as a reverse proxy:
Static Configuration (config/traefik.yml)
- Entry points (HTTP/HTTPS)
- API dashboard
- Providers (file-based)
Dynamic Configuration (config/dynamic.yml)
- Routers with path matching
- Middleware (rate limiting, auth)
- Services (load balancers)
- TLS certificates
Development
Running the Service
# Install dependencies
pip install -r requirements.txt
# Run with uvicorn
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Or using Docker
docker build -f Dockerfile -t api-gateway .
docker run -p 8000:8000 --env-file .env api-gateway
Testing
# Health check
curl http://localhost:8000/health
# Test routing
curl -H "Authorization: Bearer <token>" http://localhost:8000/api/v1/auth/me
Security Considerations
- JWT Validation: All protected routes require valid JWT
- Rate Limiting: Prevents abuse and DDoS
- HTTPS: Use TLS in production
- CORS: Configure
allow_originsappropriately - Secrets: Change
SECRET_KEYin production
Future Enhancements
- WebSocket support for real-time features
- Request/response transformation
- Circuit breaker pattern
- Advanced rate limiting (token bucket)
- API versioning support
- Request caching
- GraphQL gateway support
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file api_gateway_byom-1.0.1-py3-none-any.whl.
File metadata
- Download URL: api_gateway_byom-1.0.1-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d79d42c7fc983315ca5fbaa4b41f4bd4edca62db0aaf8b8dddb2c67051633f67
|
|
| MD5 |
7603018c123ce3146283c80fd84e35a4
|
|
| BLAKE2b-256 |
282469c8c16a1bff76df81745c2b08fafe8ab0516333c4194a87c0aed8a63c4b
|
Provenance
The following attestation bundles were made for api_gateway_byom-1.0.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on omkumar01/Distributed-Issue-Tracker-FastAPI-Microservices-
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
api_gateway_byom-1.0.1-py3-none-any.whl -
Subject digest:
d79d42c7fc983315ca5fbaa4b41f4bd4edca62db0aaf8b8dddb2c67051633f67 - Sigstore transparency entry: 2348691761
- Sigstore integration time:
-
Permalink:
omkumar01/Distributed-Issue-Tracker-FastAPI-Microservices-@7b0b4b9513bd00de03ac9844ffefab576e71f274 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/omkumar01
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7b0b4b9513bd00de03ac9844ffefab576e71f274 -
Trigger Event:
push
-
Statement type: