API Gateway Configuration
Relevant source files
The following files were used as context for generating this wiki page:
- services/api-gateway/app.py
- k8s/api-gateway.yaml
- docker-compose.yml
- config/development.yaml (derived from setup-dev.sh)
- k8s/deployment.yaml
The API Gateway serves as the centralized entry point and traffic coordinator for the Aether-X Ultimate microservices architecture. It provides a unified interface for clients to interact with various backend services, including text generation, security, and data processing, while abstracting the underlying network complexity.
The gateway is responsible for request routing, load balancing, rate limiting, and logging. It ensures that incoming traffic is validated and directed to the appropriate service instance, providing a critical layer of security and observability for the entire platform.
Sources: services/api-gateway/app.py:1-15, IMPLEMENTATION_COMPLETE.md:16-24
Architecture and Routing
The API Gateway is implemented as a Flask-based service that acts as a reverse proxy. It maintains a registry of internal service endpoints and routes incoming HTTP requests to these services based on the URL path.
The diagram shows the centralized routing logic where the Gateway acts as a hub for all specialized microservices.
Sources: services/api-gateway/app.py:16-25, docker-compose.yml:144-159
Service Registry
The gateway maps internal service identifiers to their network locations within the cluster or container network.
| Service Key | Internal Endpoint | Port |
|---|---|---|
| text-generation | http://text-generation-service | 8000 |
| image-generation | http://image-generation-service | 8001 |
| video-generation | http://video-generation-service | 8002 |
| ai-models | http://ai-models-service | 8003 |
| no-code-development | http://no-code-development-service | 8004 |
| security | http://security-service | 8005 |
| data-processing | http://data-processing-service | 8006 |
Sources: services/api-gateway/app.py:17-25, config/development.yaml in setup-dev.sh:110-140
Traffic Management
Rate Limiting Logic
The gateway implements a custom rate-limiting decorator to prevent service abuse. It tracks request timestamps per client IP address within a rolling time window.
Sources: services/api-gateway/app.py:30-51
Load Balancing and Resilience
In production environments, the gateway is deployed with multiple replicas to ensure high availability. Kubernetes handles the distribution of traffic across these replicas using a LoadBalancer service type.
apiVersion: v1
kind: Service
metadata:
name: api-gateway-service
spec:
selector:
app: api-gateway
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
Sources: k8s/api-gateway.yaml:1-11, k8s/deployment.yaml:324-345
API Endpoints
The gateway provides both a generic proxy endpoint and versioned, service-specific endpoints.
Core Endpoints Table
| Method | Path | Target Service | Rate Limit (req/min) |
|---|---|---|---|
| GET | /health | API Gateway (Self) | N/A |
| ANY | /api/<service>/<path> | Dynamic Proxy | 200 |
| POST | /api/v1/text/generate | text-generation | 100 |
| POST | /api/v1/image/generate | image-generation | 50 |
| POST | /api/v1/user/login | security | 50 |
| POST | /api/v1/data/ingest | data-processing | 200 |
Sources: services/api-gateway/app.py:72-180
Request Lifecycle
When a request hits the gateway, it undergoes a series of transformations and checks before reaching the target service.
Deployment Configuration
Kubernetes Specification
The gateway is configured with specific resource constraints and health probes to maintain cluster stability.
- Replicas: 2 (Default)
- Resources:
- Requests: 100m CPU, 256Mi Memory
- Limits: 200m CPU, 512Mi Memory
- Liveness Probe: HTTP GET
/healthon port 80, 30s initial delay.
Sources: k8s/api-gateway.yaml:13-53
Environment Variables
| Variable | Value | Description |
|---|---|---|
| FLASK_ENV | production | Sets the Flask execution environment |
| PORT | 80 | The port on which the gateway listens |
Sources: docker-compose.yml:151-152, k8s/api-gateway.yaml:30-33
Conclusion
The API Gateway Configuration is a vital component of the Aether-X Ultimate infrastructure, providing the necessary routing and protection layers for microservices. By centralizing rate limiting and request logging, it allows backend services to focus on their core AI and data processing logic while ensuring the system remains resilient under load.