Files
aitbc/docs/apps/infrastructure/api-gateway.md
aitbc ccd936a3b6
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
Documentation Validation / validate-policies-strict (push) Has been cancelled
docs: update port 8000 references to 8011 in infrastructure docs
- Update infrastructure/migration/microservices-migration-status.md: coordinator URL 8000 → 8011
- Update apps/infrastructure/api-gateway.md: coordinator URL 8000 → 8011
- More documentation files still need port 8000 → 8011 updates
2026-05-08 21:45:35 +02:00

3.4 KiB

API Gateway

Level: Intermediate
Prerequisites: Familiarity with AITBC microservices architecture
Estimated Time: 10 minutes
Last Updated: 2026-05-03
Version: 1.0

🧭 Navigation Path:

🏠 Documentation Home📦 Apps🏗️ InfrastructureYou are here

breadcrumb: Home → Apps → Infrastructure → API Gateway


🎯 See Also:


Overview

The AITBC API Gateway is a central routing service that directs requests to appropriate microservices. It provides a unified entry point for all AITBC services, simplifying client integration and enabling service discovery.

Service Registry

The gateway routes requests to the following services:

Service Port Routes Description
GPU Service 8101 /gpu/* GPU resource management
Marketplace Service 8102 /marketplace/* GPU marketplace
Agent Service 8103 /agent/* Agent operations
Trading Service 8104 /trading/* Trading operations
Governance Service 8105 /governance/* Governance operations
Coordinator API 8000 /coordinator/* Coordinator API (default)

Installation

cd /opt/aitbc
poetry install --with api-gateway

Running

Development

python -m api_gateway.main

Production (systemd)

sudo systemctl start api-gateway
sudo systemctl enable api-gateway

Endpoints

  • GET /health - Health check
  • GET /services - List registered services
  • /* - Proxy all other requests to appropriate microservice

Configuration

Service URLs are configured in main.py under the SERVICES dictionary.

Testing

Health Check

curl http://localhost:8011/health

Expected response:

{"status": "healthy", "service": "api-gateway"}

Service Registry

curl http://localhost:8011/services

Test Routing

# Route to GPU service
curl http://localhost:8011/gpu/health

# Route to Marketplace service
curl http://localhost:8011/marketplace/health

# Route to Trading service
curl http://localhost:8011/trading/health

# Route to Governance service
curl http://localhost:8011/governance/health

Architecture

The API Gateway implements:

  • Request Routing: Directs requests to appropriate microservices based on URL patterns
  • Service Discovery: Maintains a registry of available services
  • Health Monitoring: Checks service health before routing
  • Load Balancing: Distributes requests across service instances (future enhancement)

Security

  • TLS termination at gateway (future)
  • Rate limiting (future)
  • Authentication/Authorization (future)

Troubleshooting

Service Not Responding

  1. Check if target microservice is running
  2. Verify service URL configuration
  3. Check gateway logs for routing errors

Health Check Failing

  1. Verify gateway is running on port 8080
  2. Check systemd service status: systemctl status api-gateway
  3. Review logs: journalctl -u api-gateway -f

Last updated: 2026-05-03
Version: 1.0
Status: Active service
Tags: api-gateway, infrastructure, routing, microservices