Files
aitbc/apps/api-gateway
aitbc 8602732d46
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Deploy to Testnet / notify-deployment (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
Documentation Validation / validate-policies-strict (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
API Endpoint Tests / test-api-endpoints (push) Successful in 1m55s
Blockchain Synchronization Verification / sync-verification (push) Failing after 11s
CLI Tests / test-cli (push) Failing after 8s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Failing after 12s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 13s
Cross-Chain Functionality Tests / test-cross-chain-bridge (push) Has been skipped
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Failing after 13s
Cross-Chain Functionality Tests / aggregate-results (push) Has been skipped
P2P Network Verification / p2p-verification (push) Successful in 6s
Package Tests / Python package - aitbc-agent-sdk (push) Failing after 32s
Package Tests / Python package - aitbc-core (push) Successful in 15s
Package Tests / Python package - aitbc-crypto (push) Successful in 11s
Package Tests / Python package - aitbc-sdk (push) Successful in 11s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 26s
Package Tests / JavaScript package - aitbc-token (push) Successful in 25s
Production Tests / Production Integration Tests (push) Failing after 1m15s
Smart Contract Tests / test-solidity (map[name:aitbc-contracts path:contracts]) (push) Failing after 2m5s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 31s
Smart Contract Tests / test-foundry (push) Failing after 19s
Smart Contract Tests / lint-solidity (push) Successful in 17s
Smart Contract Tests / deploy-contracts (push) Successful in 1m24s
Staking Tests / test-staking-service (push) Failing after 14s
Staking Tests / test-staking-integration (push) Has been skipped
Staking Tests / test-staking-contract (push) Has been skipped
Staking Tests / run-staking-test-runner (push) Has been skipped
Systemd Sync / sync-systemd (push) Successful in 22s
Multi-Node Blockchain Health Monitoring / health-check (push) Failing after 14m13s
Convert API gateway to old Poetry format and add service routing for new microservices
- Convert api-gateway pyproject.toml to old Poetry format for workspace compatibility
- Add routing configuration for AI service (port 8106)
- Add routing configuration for Monitoring service (port 8107)
- Add routing configuration for OpenClaw service (port 8108)
- Add routing configuration for Plugin service (port 8109)
- Remove duplicate middleware implementations from coordinator-api (app_logging.py, error
2026-04-30 16:15:05 +02:00
..

AITBC API Gateway

Routes requests to AITBC microservices.

Service Registry

The gateway routes requests to the following services:

  • GPU Service (port 8101): /gpu/* → GPU resource management
  • Marketplace Service (port 8102): /marketplace/* → GPU marketplace
  • Agent Service (port 8103): /agent/* → Agent operations
  • Trading Service (port 8104): /trading/* → Trading operations
  • Governance Service (port 8105): /governance/* → Governance operations
  • Coordinator API (port 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

Testing

Prerequisites

  • All microservices installed via Poetry
  • At least one microservice running (e.g., GPU service)
  • Microservice database created (if testing that service)

Start Gateway (Development)

python -m api_gateway.main

Health Check

curl http://localhost:8080/health

Expected response:

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

Service Registry

curl http://localhost:8080/services

Expected response:

{
  "services": [
    {
      "name": "gpu",
      "url": "http://localhost:8101",
      "health_check": "/health",
      "routes": ["/gpu/*"]
    },
    {
      "name": "marketplace",
      "url": "http://localhost:8102",
      "health_check": "/health",
      "routes": ["/marketplace/*"]
    },
    {
      "name": "trading",
      "url": "http://localhost:8104",
      "health_check": "/health",
      "routes": ["/trading/*"]
    },
    {
      "name": "governance",
      "url": "http://localhost:8105",
      "health_check": "/health",
      "routes": ["/governance/*"]
    }
  ]
}

Test Routing to GPU Service

  1. Start GPU service in another terminal:

    python -m gpu_service.main
    
  2. Test through gateway:

    curl http://localhost:8080/gpu/health
    

Expected response:

{"status": "healthy", "service": "gpu-service"}

Test Routing to Marketplace Service

  1. Start Marketplace service in another terminal:

    python -m marketplace_service.main
    
  2. Test through gateway:

    curl http://localhost:8080/marketplace/health
    

Expected response:

{"status": "healthy", "service": "marketplace-service"}

Test Routing to Trading Service

  1. Start Trading service in another terminal:

    python -m trading_service.main
    
  2. Test through gateway:

    curl http://localhost:8080/trading/health
    

Expected response:

{"status": "healthy", "service": "trading-service"}

Test Routing to Governance Service

  1. Start Governance service in another terminal:

    python -m governance_service.main
    
  2. Test through gateway:

    curl http://localhost:8080/governance/health
    

Expected response:

{"status": "healthy", "service": "governance-service"}

For comprehensive testing procedures, see MICROSERVICES_TESTING_GUIDE.md.

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.