Files
aitbc/apps/marketplace-service
aitbc 83ca64f7b8
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Has been cancelled
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Production Tests / Production Integration Tests (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
CLI Tests / test-cli (push) Failing after 3s
feat: add /v1 API prefix to all business logic endpoints and create CLI test suite
- Added /v1 prefix to all business logic routers in coordinator-api (analytics, portfolio, reputation, rewards, staking)
- Updated agent-coordinator to include /v1 prefix for all routers
- Changed agent-management API prefix from /api/v1 to /v1
- Updated api-gateway service prefixes to include /v1 for all proxied services
- Fixed coordinator-api routers to use correct service imports (AgentServiceMarketplace instead
2026-05-19 12:46:59 +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.