Files
aitbc/docs/apps/infrastructure/api-gateway.md
aitbc 19d415a235
Some checks failed
Blockchain Synchronization Verification / sync-verification (push) Failing after 3s
CLI Tests / test-cli (push) Failing after 3s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Successful in 2s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 3s
Cross-Chain Functionality Tests / test-cross-chain-bridge (push) Has been skipped
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Successful in 2s
Cross-Chain Functionality Tests / aggregate-results (push) Has been skipped
Deploy to Testnet / deploy-testnet (push) Successful in 1m12s
Documentation Validation / validate-docs (push) Failing after 8s
Documentation Validation / validate-policies-strict (push) Successful in 3s
Integration Tests / test-service-integration (push) Successful in 2m6s
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Successful in 2s
Multi-Node Blockchain Health Monitoring / health-check (push) Failing after 4s
P2P Network Verification / p2p-verification (push) Successful in 4s
Package Tests / Python package - aitbc-agent-sdk (push) Successful in 32s
Package Tests / Python package - aitbc-core (push) Successful in 14s
Package Tests / Python package - aitbc-crypto (push) Successful in 12s
Package Tests / Python package - aitbc-sdk (push) Successful in 9s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 8s
Package Tests / JavaScript package - aitbc-token (push) Successful in 17s
Python Tests / test-python (push) Successful in 15s
Security Scanning / security-scan (push) Successful in 27s
Node Failover Simulation / failover-test (push) Successful in 7s
Multi-Node Stress Testing / stress-test (push) Successful in 6s
Cross-Node Transaction Testing / transaction-test (push) Successful in 4s
feat: add SQLCipher database encryption support and consolidate agent documentation
- Add SQLCipher encryption for ait-mainnet database with configurable flag
- Add db_encryption_enabled and db_encryption_key_path config settings
- Implement encryption key loading and PRAGMA key setup via connection events
- Add shutdown_db function for proper database cleanup
- Export middleware classes in aitbc/__init__.py
- Fix import path in sync.py for settings
- Remove duplicate agent documentation from docs
2026-05-03 12:00:38 +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:8080/health

Expected response:

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

Service Registry

curl http://localhost:8080/services

Test Routing

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

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

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

# Route to Governance service
curl http://localhost:8080/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