Skip to main content

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

  1. JWT Validation: All protected routes require valid JWT
  2. Rate Limiting: Prevents abuse and DDoS
  3. HTTPS: Use TLS in production
  4. CORS: Configure allow_origins appropriately
  5. Secrets: Change SECRET_KEY in 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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

api_gateway_byom-1.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file api_gateway_byom-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for api_gateway_byom-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d79d42c7fc983315ca5fbaa4b41f4bd4edca62db0aaf8b8dddb2c67051633f67
MD5 7603018c123ce3146283c80fd84e35a4
BLAKE2b-256 282469c8c16a1bff76df81745c2b08fafe8ab0516333c4194a87c0aed8a63c4b

See more details on using hashes here.

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-

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page