Files
aitbc/apps/marketplace-service
aitbc 9609924d56
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 27s
Blockchain Synchronization Verification / sync-verification (push) Failing after 8s
CLI Tests / test-cli (push) Failing after 4s
Coverage Phase 1 (70% Target) / test-coverage-70 (push) Failing after 16s
Coverage Phase 2 (85% Target) / test-coverage-85 (push) Failing after 14s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Successful in 2s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 4s
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Successful in 2s
Cross-Node Transaction Testing / transaction-test (push) Successful in 2s
Deploy to Testnet / deploy-testnet (push) Failing after 5s
Integration Tests / test-service-integration (push) Successful in 1m24s
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Successful in 3s
Multi-Node Blockchain Health Monitoring / health-check (push) Failing after 2s
Multi-Node Stress Testing / stress-test (push) Successful in 2s
Node Failover Simulation / failover-test (push) Successful in 2s
P2P Network Verification / p2p-verification (push) Successful in 2s
Python Tests / test-python (push) Failing after 5s
Security Scanning / security-scan (push) Failing after 1m43s
Cross-Chain Functionality Tests / aggregate-results (push) Successful in 11s
fix: populate feature_flags.json and remove sys.path bootstrap inserts
- feature_flags.json: populated with 6 well-described flags reflecting
  current system state (DI migration, structlog, CORS enforcement,
  X-Wallet-Address trust, ZK proof, marketplace rate limiting)

- Remove sys.path.insert bootstrap from app main.py files:
  - apps/agent-management/src/app/main.py
  - apps/marketplace-service/src/marketplace_service/main.py
  - apps/wallet/src/app/main.py
  - apps/blockchain-node/src/aitbc_chain/combined_main.py
  PYTHONPATH is set correctly by the wrapper scripts in scripts/wrappers/
  so the inserts are redundant and misleading.

Wrapper scripts (scripts/wrappers/*.py) and lazy cross-app imports in
blockchain-event-bridge are intentionally left unchanged.
2026-05-25 10:18:14 +02:00
..

AITBC Marketplace Service

Manages GPU marketplace operations.

Installation

cd /opt/aitbc
poetry install --with marketplace-service

Database Setup

Create a separate database for the marketplace service:

sudo -u postgres psql -f apps/marketplace-service/scripts/setup-database.sql

Or manually:

CREATE DATABASE aitbc_marketplace;
CREATE USER aitbc_marketplace WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE aitbc_marketplace TO aitbc_marketplace;

Running

# Development
python -m marketplace_service.main

# Production (systemd)
sudo systemctl start marketplace-service
sudo systemctl enable marketplace-service

Endpoints

  • GET /health - Health check
  • GET /marketplace/status - Get marketplace status
  • GET /v1/marketplace/offers - Get marketplace offers
  • GET /v1/marketplace/offers/{offer_id} - Get specific offer
  • POST /v1/marketplace/offers - Create new offer
  • GET /v1/marketplace/bids - Get marketplace bids
  • POST /v1/marketplace/bids - Create new bid
  • GET /v1/marketplace/analytics - Get marketplace analytics

Testing

Prerequisites

  • PostgreSQL running and aitbc_marketplace database created
  • Poetry dependencies installed

Database Setup

sudo -u postgres psql -f scripts/setup-database.sql

Start Service (Development)

python -m marketplace_service.main

Health Check

curl http://localhost:8102/health

Expected response:

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

Marketplace Status

curl http://localhost:8102/marketplace/status

Expected response:

{
  "status": "operational",
  "service": "marketplace-service",
  "message": "Marketplace service is running"
}

Get Marketplace Offers

curl http://localhost:8102/v1/marketplace/offers

Expected response:

[]

Create Marketplace Offer

curl -X POST http://localhost:8102/v1/marketplace/offers \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "test_provider",
    "capacity": 100,
    "price": 0.5,
    "gpu_model": "NVIDIA A100"
  }'

Test Through Gateway

  1. Start the API gateway:

    python -m api_gateway.main
    
  2. Test marketplace endpoints through the gateway:

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

For comprehensive testing procedures, see MICROSERVICES_TESTING_GUIDE.md.

Service Configuration

  • Port: 8102
  • Database: aitbc_marketplace
  • Gateway route: /marketplace/*

Migration Status

Completed:

  • Extracted marketplace domain models (MarketplaceOffer, MarketplaceBid, GlobalMarketplaceOffer, GlobalMarketplaceTransaction, etc.)
  • Extracted marketplace services (MarketplaceService with CRUD operations)
  • Extracted marketplace data structures
  • Set up database session management
  • Extracted marketplace router endpoints
  • Created systemd service configuration
  • Created database setup script

Remaining:

  • Remove marketplace routers from coordinator-api (marketplace, marketplace_gpu, marketplace_offers, global_marketplace, global_marketplace_integration)
  • Remove marketplace services from coordinator-api
  • Remove marketplace domain models from coordinator-api
  • Run database migration script to create aitbc_marketplace database
  • Install and enable systemd service
  • End-to-end testing with gateway

Note: The marketplace service is very large (~130K lines), so full removal from coordinator-api requires careful coordination to avoid breaking existing functionality. The foundation is in place for gradual migration.