Files
aitbc/apps/governance-service
aitbc c80aa7c0c0
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Successful in 11s
Security Scanning / security-scan (push) Waiting to run
Deploy to Testnet / deploy-testnet (push) Successful in 1m36s
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
Deploy to Testnet / notify-deployment (push) Successful in 11s
Update governance and trading DATABASE_URL to point to aitbc1 PostgreSQL
2026-05-02 10:15:51 +02:00
..

AITBC Governance Service

Manages governance operations.

Installation

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

Database Setup

Create a separate database for the governance service:

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

Or manually:

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

Running

# Development
python -m governance_service.main

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

Endpoints

  • GET /health - Health check
  • GET /governance/status - Get governance status
  • GET /v1/governance/profiles - Get governance profiles
  • GET /v1/governance/profiles/{profile_id} - Get specific profile
  • POST /v1/governance/profiles - Create new profile
  • GET /v1/governance/proposals - Get proposals
  • GET /v1/governance/proposals/{proposal_id} - Get specific proposal
  • POST /v1/governance/proposals - Create new proposal
  • GET /v1/governance/votes - Get votes
  • POST /v1/governance/votes - Create new vote
  • GET /v1/governance/treasury - Get DAO treasury
  • GET /v1/governance/analytics - Get governance analytics

Testing

Prerequisites

  • PostgreSQL running and aitbc_governance database created
  • Poetry dependencies installed

Database Setup

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

Start Service (Development)

python -m governance_service.main

Health Check

curl http://localhost:8105/health

Expected response:

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

Governance Status

curl http://localhost:8105/governance/status

Expected response:

{
  "status": "operational",
  "service": "governance-service",
  "message": "Governance service is running"
}

Get Governance Proposals

curl http://localhost:8105/v1/governance/proposals

Expected response:

[]

Create Governance Proposal

curl -X POST http://localhost:8105/v1/governance/proposals \
  -H "Content-Type: application/json" \
  -d '{
    "proposer_id": "test_proposer",
    "title": "Test Proposal",
    "description": "Test description",
    "category": "general",
    "voting_starts": "2026-05-01T00:00:00Z",
    "voting_ends": "2026-05-08T00:00:00Z"
  }'

Test Through Gateway

  1. Start the API gateway:

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

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

For comprehensive testing procedures, see MICROSERVICES_TESTING_GUIDE.md.

Service Configuration

  • Port: 8105
  • Database: aitbc_governance
  • Gateway route: /governance/*

Migration Status

Completed:

  • Extracted governance domain models (GovernanceProfile, Proposal, Vote, DaoTreasury, TransparencyReport)
  • Extracted governance services (GovernanceService with CRUD operations)
  • Set up database session management
  • Extracted governance router endpoints
  • Created systemd service configuration
  • Created database setup script

Remaining:

  • Remove governance routers from coordinator-api
  • Remove governance services from coordinator-api
  • Remove governance domain models from coordinator-api
  • Run database migration script to create aitbc_governance database
  • Install and enable systemd service
  • End-to-end testing with gateway

Note: The governance service is ~50K lines, so full removal from coordinator-api requires careful coordination to avoid breaking existing functionality. The foundation is in place for gradual migration.