Files
aitbc/website/docs/coordinator-api.html
oib 07f3a87328 docs: restructure website, optimize HTML, gitignore private files
Website docs (website/docs/):
- Delete 6 stale -md.html duplicates
- Rename docs-clients/miners/developers → clients/miners/developers.html
- Unify header/nav across all 15 pages (new .site-header pattern)
- Fix 34 dead href=# links with real targets
- Upgrade Font Awesome v4→v6 in index.html
- Replace search stub with live client-side search (15-page index)
- Extract all inline CSS into shared docs.css (+630 lines)
- Extract inline theme JS into shared theme.js
- Strip inline style= attributes from 10+ pages
- Add .announce-banner, .source-links, .search-results CSS classes
- Add Markdown Source links to clients/miners/developers pages
- Update components.html title to Architecture & Components
- Move browser-wallet.html to website/wallet/, leave redirect
- Update all dates to February 2026

Website root:
- Delete 6 root-level duplicate HTML files (160KB saved)
- Rewire index.html and 404.html links

Root README.md:
- Fix 8 broken doc links to new numbered folder structure
- Update copyright to 2026

.gitignore + .example files:
- Gitignore private files: .aitbc.yaml, .env, deploy scripts,
  GPU scripts, service scripts, infra configs, .windsurf/, website README
- Create 7 .example files for GitHub users with sanitized templates
- Untrack 47 previously committed private files

Live server:
- Push all website files to aitbc-cascade:/var/www/html/
- Clean stale admin.html and index.nginx-debian.html
2026-02-13 23:18:52 +01:00

262 lines
9.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Coordinator API - AITBC Documentation</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="stylesheet" href="css/docs.css">
</head>
<body>
<!-- Header -->
<header class="site-header">
<div class="container">
<div class="header-inner">
<a href="/" class="brand">
<i class="fas fa-cube"></i>
<span>AITBC</span>
</a>
<nav class="header-nav">
<a href="/">Home</a>
<a href="/explorer/">Explorer</a>
<a href="/Exchange/">Exchange</a>
<a href="/docs/index.html" class="active">Docs</a>
<button id="theme-toggle" class="theme-toggle" title="Toggle theme"><i class="fas fa-sun"></i></button>
</nav>
</div>
</div>
</header>
<!-- Main Content -->
<main>
<div class="container">
<!-- Breadcrumb -->
<div class="breadcrumb">
<a href="index.html">Documentation</a>
<span></span>
<a href="components.html">Components</a>
<span></span>
<span>Coordinator API</span>
</div>
<!-- Back Button -->
<a href="components.html" class="back-button">
<i class="fas fa-arrow-left"></i>
Back to Components
</a>
<!-- Header -->
<div class="doc-header">
<h1><i class="fas fa-server"></i> Coordinator API</h1>
<p>FastAPI service for job submission, miner registration, and receipt management with SQLite persistence</p>
<span class="status-badge live">● Live</span>
</div>
<!-- Overview -->
<section class="content-section">
<div class="alert alert-info">
<i class="fas fa-info-circle"></i>
<strong>System Flow:</strong> See the <a href="flowchart.html">complete system flow diagram</a> to understand how the coordinator API fits into the overall AITBC architecture.
</div>
<h2>Overview</h2>
<p>The Coordinator API is the central orchestration layer that manages job distribution between clients and miners in the AITBC network. It handles job submissions, miner registrations, and tracks all computation receipts.</p>
<h3>Key Features</h3>
<ul>
<li>Job submission and tracking</li>
<li>Miner registration and heartbeat monitoring</li>
<li>Receipt management and verification</li>
<li>User management with wallet-based authentication</li>
<li>SQLite persistence with SQLModel ORM</li>
<li>Comprehensive API documentation with OpenAPI</li>
</ul>
</section>
<!-- Architecture -->
<section class="content-section">
<h2>Architecture</h2>
<p>The Coordinator API follows a clean architecture with separation of concerns for domain models, API routes, and business logic.</p>
<div class="feature-grid">
<div class="feature-card">
<h4>API Layer</h4>
<p>FastAPI routers for clients, miners, admin, and users</p>
</div>
<div class="feature-card">
<h4>Domain Models</h4>
<p>SQLModel definitions for jobs, miners, receipts, users</p>
</div>
<div class="feature-card">
<h4>Business Logic</h4>
<p>Service layer handling job orchestration</p>
</div>
<div class="feature-card">
<h4>Persistence</h4>
<p>SQLite database with Alembic migrations</p>
</div>
</div>
</section>
<!-- API Reference -->
<section class="content-section">
<h2>API Reference</h2>
<p>The Coordinator API provides RESTful endpoints for all major operations.</p>
<h3>Client Endpoints</h3>
<div class="api-endpoint">
<code>POST /v1/client/jobs</code>
<p>Submit a new computation job</p>
</div>
<div class="api-endpoint">
<code>GET /v1/client/jobs/{job_id}/status</code>
<p>Get job status and progress</p>
</div>
<div class="api-endpoint">
<code>GET /v1/client/jobs/{job_id}/receipts</code>
<p>Retrieve computation receipts</p>
</div>
<h3>Miner Endpoints</h3>
<div class="api-endpoint">
<code>POST /v1/miner/register</code>
<p>Register as a compute provider</p>
</div>
<div class="api-endpoint">
<code>POST /v1/miner/heartbeat</code>
<p>Send miner heartbeat</p>
</div>
<div class="api-endpoint">
<code>GET /v1/miner/jobs</code>
<p>Fetch available jobs</p>
</div>
<div class="api-endpoint">
<code>POST /v1/miner/result</code>
<p>Submit job result</p>
</div>
<h3>User Management</h3>
<div class="api-endpoint">
<code>POST /v1/users/login</code>
<p>Login or register with wallet</p>
</div>
<div class="api-endpoint">
<code>GET /v1/users/me</code>
<p>Get current user profile</p>
</div>
<div class="api-endpoint">
<code>GET /v1/users/{user_id}/balance</code>
<p>Get user wallet balance</p>
</div>
<h3>Exchange Endpoints</h3>
<div class="api-endpoint">
<code>POST /v1/exchange/create-payment</code>
<p>Create Bitcoin payment request</p>
</div>
<div class="api-endpoint">
<code>GET /v1/exchange/payment-status/{id}</code>
<p>Check payment status</p>
</div>
</section>
<!-- Authentication -->
<section class="content-section">
<h2>Authentication</h2>
<p>The API uses API key authentication for clients and miners, and session-based authentication for users.</p>
<h3>API Keys</h3>
<pre><code>X-Api-Key: your-api-key-here</code></pre>
<h3>Session Tokens</h3>
<pre><code>X-Session-Token: sha256-token-here</code></pre>
<h3>Example Request</h3>
<pre><code>curl -X POST "https://aitbc.bubuit.net/api/v1/client/jobs" \
-H "X-Api-Key: your-key" \
-H "Content-Type: application/json" \
-d '{
"job_type": "llm_inference",
"parameters": {...}
}'</code></pre>
</section>
<!-- Configuration -->
<section class="content-section">
<h2>Configuration</h2>
<p>The Coordinator API can be configured via environment variables.</p>
<h3>Environment Variables</h3>
<pre><code># Database
DATABASE_URL=sqlite:///coordinator.db
# API Settings
API_HOST=0.0.0.0
API_PORT=8000
# Security
SECRET_KEY=your-secret-key
API_KEYS=key1,key2,key3
# Exchange
BITCOIN_ADDRESS=tb1qxy2...
BTC_TO_AITBC_RATE=100000</code></pre>
</section>
<!-- Deployment -->
<section class="content-section">
<h2>Deployment</h2>
<p>The Coordinator API runs in a Docker container with nginx proxy.</p>
<h3>Docker Deployment</h3>
<pre><code># Build image
docker build -t aitbc-coordinator .
# Run container
docker run -d \
--name aitbc-coordinator \
-p 8000:8000 \
-e DATABASE_URL=sqlite:///data/coordinator.db \
-v $(pwd)/data:/app/data \
aitbc-coordinator</code></pre>
<h3>Systemd Service</h3>
<pre><code># Start service
sudo systemctl start aitbc-coordinator
# Check status
sudo systemctl status aitbc-coordinator
# View logs
sudo journalctl -u aitbc-coordinator -f</code></pre>
</section>
<!-- API Documentation -->
<section class="content-section">
<h2>Interactive API Documentation</h2>
<p>Interactive API documentation is available via Swagger UI and ReDoc.</p>
<ul>
<li><a href="https://aitbc.bubuit.net/api/docs" target="_blank">Swagger UI</a></li>
<li><a href="https://aitbc.bubuit.net/api/redoc" target="_blank">ReDoc</a></li>
<li><a href="https://aitbc.bubuit.net/api/openapi.json" target="_blank">OpenAPI Spec</a></li>
</ul>
</section>
</div>
</main>
<script>
// Add any interactive functionality here
</script>
<script src="js/theme.js"></script>
</body>
</html>