From 86e5c6f1a3abdbaa7cb4c4912ce13543e8458a2a Mon Sep 17 00:00:00 2001 From: oib Date: Thu, 29 Jan 2026 15:06:36 +0100 Subject: [PATCH] feat: Convert HTML documentation to markdown and add web format - Convert all HTML documentation files to markdown format in /docs folder - Add markdown links to HTML documentation pages - Update all aitbc.io references to aitbc.bubuit.net - Create HTML web format versions of key documentation files - Update documentation index to show both HTML and web format options - Add flowchart documentation explaining CLI job submission process --- docs/blockchain-node.md | 173 +++++++ docs/client-documentation.md | 305 +++++++++++ docs/components.md | 121 +++++ docs/coordinator-api.md | 254 ++++++++++ docs/developer-documentation.md | 259 ++++++++++ docs/flowchart.md | 336 +++++++++++++ docs/full-documentation.md | 392 +++++++++++++++ docs/marketplace-web.md | 410 +++++++++++++++ docs/miner-documentation.md | 317 ++++++++++++ docs/trade-exchange.md | 304 +++++++++++ docs/wallet-documentation.md | 118 +++++ website/docs/blockchain-node-md.html | 488 ++++++++++++++++++ website/docs/blockchain-node.html | 5 + website/docs/browser-wallet.html | 5 + website/docs/client-documentation-md.html | 586 ++++++++++++++++++++++ website/docs/components-md.html | 496 ++++++++++++++++++ website/docs/components.html | 7 +- website/docs/coordinator-api.html | 5 + website/docs/docs-clients.html | 11 +- website/docs/docs-developers.html | 5 + website/docs/docs-miners.html | 11 +- website/docs/full-documentation.html | 7 +- website/docs/index.html | 44 +- website/docs/marketplace-web.html | 9 +- website/docs/trade-exchange.html | 5 + 25 files changed, 4661 insertions(+), 12 deletions(-) create mode 100644 docs/blockchain-node.md create mode 100644 docs/client-documentation.md create mode 100644 docs/components.md create mode 100644 docs/coordinator-api.md create mode 100644 docs/developer-documentation.md create mode 100644 docs/flowchart.md create mode 100644 docs/full-documentation.md create mode 100644 docs/marketplace-web.md create mode 100644 docs/miner-documentation.md create mode 100644 docs/trade-exchange.md create mode 100644 docs/wallet-documentation.md create mode 100644 website/docs/blockchain-node-md.html create mode 100644 website/docs/client-documentation-md.html create mode 100644 website/docs/components-md.html diff --git a/docs/blockchain-node.md b/docs/blockchain-node.md new file mode 100644 index 00000000..b290e02f --- /dev/null +++ b/docs/blockchain-node.md @@ -0,0 +1,173 @@ +# Blockchain Node - AITBC Documentation + +PoA/PoS consensus blockchain with REST/WebSocket RPC, real-time gossip layer, and comprehensive observability + +● Live + +## Overview + +The AITBC Blockchain Node is the core infrastructure component that maintains the distributed ledger. It implements a hybrid Proof-of-Authority/Proof-of-Stake consensus mechanism with fast finality and supports high throughput for AI workload transactions. + +### Key Features + +- Hybrid PoA/PoS consensus with sub-second finality +- REST and WebSocket RPC APIs +- Real-time gossip protocol for block propagation +- Comprehensive observability with Prometheus metrics +- SQLModel-based data persistence +- Built-in devnet tooling and scripts + +## Architecture + +The blockchain node is built with a modular architecture separating concerns for consensus, storage, networking, and API layers. + +#### Consensus Engine +Hybrid PoA/PoS with proposer rotation and validator sets + +#### Storage Layer +SQLModel with SQLite/PostgreSQL support + +#### Networking +WebSocket gossip + REST API + +#### Observability +Prometheus metrics + structured logging + +## API Reference + +The blockchain node exposes both REST and WebSocket APIs for interaction. + +### REST Endpoints + +`GET /rpc/get_head` +Get the latest block header + +`POST /rpc/send_tx` +Submit a new transaction + +`GET /rpc/get_balance/{address}` +Get account balance + +`GET /rpc/get_block/{height}` +Get block by height + +### WebSocket Subscriptions + +- `new_blocks` - Real-time block notifications +- `new_transactions` - Transaction pool updates +- `consensus_events` - Consensus round updates + +## Configuration + +The node can be configured via environment variables or configuration file. + +### Key Settings + +```bash +# Database +DATABASE_URL=sqlite:///blockchain.db + +# Network +RPC_HOST=0.0.0.0 +RPC_PORT=9080 +WS_PORT=9081 + +# Consensus +CONSENSUS_MODE=poa +VALIDATOR_ADDRESS=0x... +BLOCK_TIME=1s + +# Observability +METRICS_PORT=9090 +LOG_LEVEL=info +``` + +## Running a Node + +### Development Mode + +```bash +# Initialize devnet +python -m blockchain.scripts.init_devnet + +# Start node +python -m blockchain.main --config devnet.yaml +``` + +### Production Mode + +```bash +# Using Docker +docker run -d \ + -v /data/blockchain:/data \ + -p 9080:9080 \ + -p 9081:9081 \ + -p 9090:9090 \ + aitbc/blockchain-node:latest +``` + +## Monitoring + +### Prometheus Metrics + +Available at `http://localhost:9090/metrics` + +Key metrics: +- `blockchain_blocks_total` - Total blocks produced +- `blockchain_transactions_total` - Total transactions processed +- `blockchain_consensus_rounds` - Consensus rounds completed +- `blockchain_network_peers` - Active peer connections + +### Health Checks + +```bash +# Node status +curl http://localhost:9080/health + +# Sync status +curl http://localhost:9080/sync_status +``` + +## Troubleshooting + +### Common Issues + +1. **Node not syncing** + - Check peer connections: `curl /rpc/peers` + - Verify network connectivity + - Check logs for consensus errors + +2. **High memory usage** + - Reduce `block_cache_size` in config + - Enable block pruning + +3. **RPC timeouts** + - Increase `rpc_timeout` setting + - Check system resources + +## Development + +### Building from Source + +```bash +git clone https://github.com/aitbc/blockchain +cd blockchain +pip install -e . +``` + +### Running Tests + +```bash +# Unit tests +pytest tests/ + +# Integration tests +pytest tests/integration/ +``` + +## Security Considerations + +- Validator keys should be kept secure +- Use HTTPS in production +- Implement rate limiting on RPC endpoints +- Regular security updates for dependencies diff --git a/docs/client-documentation.md b/docs/client-documentation.md new file mode 100644 index 00000000..c62723e1 --- /dev/null +++ b/docs/client-documentation.md @@ -0,0 +1,305 @@ +# Client Documentation - AITBC + +Use AITBC for AI/ML Workloads: Access secure, private, and verifiable AI/ML computation on the decentralized network + +> ✅ **Now Available: CLI Wrapper Tool** +> +> Submit jobs, check status, and verify receipts with our new bash CLI wrapper. Supporting 13+ Ollama models with real-time blockchain verification! + +## Key Features + +- **Privacy First** - Your data and models remain confidential with zero-knowledge proofs and secure enclaves +- **Verifiable Results** - Every computation is cryptographically verified on the blockchain for trust and transparency +- **Fast & Efficient** - Access thousands of GPUs worldwide with sub-second response times + +## Getting Started + +Start using AITBC in minutes with our simple client SDK or web interface. + +### Quick Start Options + +- **CLI Wrapper Tool**: ✅ NEW - Unified bash script for job management +- **Web Interface**: No installation required +- **Python SDK**: For AI/ML developers +- **JavaScript SDK**: For web applications +- **REST API**: For any platform + +### CLI Wrapper Tool (Recommended) + +#### Submit an Inference Job + +Use the bash CLI wrapper for easy job submission: + +```bash +# Submit job with CLI wrapper +./scripts/aitbc-cli.sh submit inference \ + --prompt "What is machine learning?" \ + --model llama3.2:latest + +# Check job status +./scripts/aitbc-cli.sh status + +# View receipt with payment details +./scripts/aitbc-cli.sh receipts --job-id +``` + +> **Available Models:** llama3.2, mistral, deepseek-r1:14b, gemma3, qwen2.5-coder, and 8+ more via Ollama integration. Processing time: 11-25 seconds. Rate: 0.02 AITBC per GPU second. + +### Web Interface (Fastest) + +1. **Visit the Marketplace** + - Go to [aitbc.bubuit.net/marketplace](https://gitea.bubuit.net/oib/aitbc) + +2. **Connect Your Wallet** + - Connect MetaMask or create a new AITBC wallet + +3. **Submit Your Job** + - Upload your data or model, select parameters, and submit + +4. **Get Results** + - Receive verified results with cryptographic proof + +## Popular Use Cases + +### AI Inference ✅ LIVE +Run inference on pre-trained models including LLama, Mistral, DeepSeek, and custom models via Ollama + +- Text generation (13+ models) +- Code generation (DeepSeek, Qwen) +- Translation (Qwen2.5-translator) +- Real-time processing (11-25s) + +### Model Training +Train and fine-tune models on your data with privacy guarantees + +- Fine-tuning LLMs +- Custom model training +- Federated learning +- Transfer learning + +### Data Analysis +Process large datasets with confidential computing + +- Statistical analysis +- Pattern recognition +- Predictive modeling +- Data visualization + +### Secure Computation +Run sensitive computations with end-to-end encryption + +- Financial modeling +- Healthcare analytics +- Legal document processing +- Proprietary algorithms + +## SDK Examples + +### Python SDK + +```python +# Install the SDK +pip install aitbc + +# Initialize client +from aitbc import AITBCClient + +client = AITBCClient(api_key="your-api-key") + +# Run inference +result = client.inference( + model="gpt-4", + prompt="Explain quantum computing", + max_tokens=500, + temperature=0.7 +) + +print(result.text) + +# Verify the receipt +is_valid = client.verify_receipt(result.receipt_id) +print(f"Verified: {is_valid}") +``` + +### JavaScript SDK + +```javascript +// Install the SDK +npm install @aitbc/client + +// Initialize client +import { AITBCClient } from '@aitbc/client'; + +const client = new AITBCClient({ + apiKey: 'your-api-key', + network: 'mainnet' +}); + +// Run inference +const result = await client.inference({ + model: 'stable-diffusion', + prompt: 'A futuristic city', + steps: 50, + cfg_scale: 7.5 +}); + +// Download the image +await client.downloadImage(result.imageId, './output.png'); + +// Verify computation +const verified = await client.verify(result.receiptId); +console.log('Computation verified:', verified); +``` + +### REST API + +```bash +# Submit a job +curl -X POST https://aitbc.bubuit.net/api/v1/jobs \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "type": "inference", + "model": "gpt-4", + "input": { + "prompt": "Hello, AITBC!", + "max_tokens": 100 + }, + "privacy": { + "confidential": true, + "zk_proof": true + } + }' + +# Check job status +curl -X GET https://aitbc.bubuit.net/api/v1/jobs/JOB_ID \ + -H "Authorization: Bearer YOUR_TOKEN" +``` + +## Pricing + +Flexible pricing options for every use case + +### Pay-per-use +- **$0.01/1K tokens** +- No minimum commitment +- Pay only for what you use +- All models available +- Basic support + +### Professional +- **$99/month** +- $500 included credits +- Priority processing +- Advanced models +- Email support +- API access + +### Enterprise +- **Custom** +- Unlimited usage +- Dedicated resources +- Custom models +- 24/7 support +- SLA guarantee + +## Privacy & Security + +> **Your data is never stored or exposed** - All computations are performed in secure enclaves with zero-knowledge proof verification. + +### Privacy Features + +- **End-to-end encryption** - Your data is encrypted before leaving your device +- **Zero-knowledge proofs** - Prove computation without revealing inputs +- **Secure enclaves** - Computations run in isolated, verified environments +- **No data retention** - Providers cannot access or store your data +- **Audit trails** - Full transparency on blockchain + +### Compliance + +- GDPR compliant +- SOC 2 Type II certified +- HIPAA eligible +- ISO 27001 certified + +## Best Practices + +### Optimizing Performance + +- Use appropriate model sizes for your task +- Batch requests when possible +- Enable caching for repeated queries +- Choose the right privacy level for your needs +- Monitor your usage and costs + +### Security Tips + +- Keep your API keys secure +- Use environment variables for credentials +- Enable two-factor authentication +- Regularly rotate your keys +- Use VPN for additional privacy + +### Cost Optimization + +- Start with smaller models for testing +- Use streaming for long responses +- Set appropriate limits and timeouts +- Monitor token usage +- Consider subscription plans for regular use + +## Support & Resources + +### Getting Help + +- **Documentation**: [Full API reference](full-documentation.html) +- **Community**: [Join our Discord](https://discord.gg/aitbc) +- **Email**: [aitbc@bubuit.net](mailto:aitbc@bubuit.net) +- **Status**: [System status](https://status.aitbc.bubuit.net) + +### Tutorials + +- [Getting Started with AI Inference](#) +- [Building a Chat Application](#) +- [Image Generation Guide](#) +- [Privacy-Preserving ML](#) +- [API Integration Best Practices](#) + +### Examples + +- [GitHub Repository](#) +- [Code Examples](#) +- [Sample Applications](#) +- [SDK Documentation](#) + +## Frequently Asked Questions + +> **Question not answered?** Contact us at [aitbc@bubuit.net](mailto:aitbc@bubuit.net) + +### General + +- **How do I get started?** - Sign up for an account, connect your wallet, and submit your first job through the web interface or API. +- **What models are available?** - We support GPT-3.5/4, Claude, Llama, Stable Diffusion, and many custom models. +- **Can I use my own model?** - Yes, you can upload and run private models with full confidentiality. + +### Privacy + +- **Is my data private?** - Absolutely. Your data is encrypted and never exposed to providers. +- **How do ZK proofs work?** - They prove computation was done correctly without revealing inputs. +- **Can you see my prompts?** - No, prompts are encrypted and processed in secure enclaves. + +### Technical + +- **What's the response time?** - Most jobs complete in 1-5 seconds depending on complexity. +- **Do you support streaming?** - Yes, streaming is available for real-time applications. +- **Can I run batch jobs?** - Yes, batch processing is supported for large workloads. + +### Billing + +- **How am I billed?** - Pay-per-use or monthly subscription options available. +- **Can I set spending limits?** - Yes, you can set daily/monthly limits in your dashboard. +- **Do you offer refunds?** - Yes, we offer refunds for service issues within 30 days. + +--- + +© 2025 AITBC. All rights reserved. diff --git a/docs/components.md b/docs/components.md new file mode 100644 index 00000000..9b391393 --- /dev/null +++ b/docs/components.md @@ -0,0 +1,121 @@ +# AITBC System Components + +Overview of all components in the AITBC platform, their status, and documentation links. + +## Core Components + +### Blockchain Node +● Live + +PoA/PoS consensus with REST/WebSocket RPC, real-time gossip layer, and comprehensive observability. Production-ready with devnet tooling. + +[Learn More →](blockchain-node.md) + +### Coordinator API +● Live + +FastAPI service for job submission, miner registration, and receipt management. SQLite persistence with comprehensive endpoints. + +[Learn More →](coordinator-api.md) + +### Marketplace Web +● Live + +Vite/TypeScript marketplace with offer/bid functionality, stats dashboard, and mock/live data toggle. Production UI ready. + +[Learn More →](marketplace-web.md) + +### Explorer Web +● Live + +Full-featured blockchain explorer with blocks, transactions, addresses, and receipts tracking. Responsive design with live data. + +[Learn More →](explorer-web.md) + +### Wallet Daemon +● Live + +Encrypted keystore with Argon2id + XChaCha20-Poly1305, REST/JSON-RPC APIs, and receipt verification capabilities. + +[Learn More →](wallet-daemon.md) + +### Trade Exchange +● Live + +Bitcoin-to-AITBC exchange with QR payments, user management, and real-time trading. Buy tokens with BTC instantly. + +[Learn More →](trade-exchange.md) + +### Pool Hub +● Live + +Miner registry with scoring engine, Redis/PostgreSQL backing, and comprehensive metrics. Live matching API deployed. + +[Learn More →](pool-hub.md) + +## Architecture Overview + +The AITBC platform consists of 7 core components working together to provide a complete AI blockchain computing solution: + +### Infrastructure Layer + +- **Blockchain Node** - Distributed ledger with PoA/PoS consensus +- **Coordinator API** - Job orchestration and management +- **Wallet Daemon** - Secure wallet management + +### Application Layer + +- **Marketplace Web** - GPU compute marketplace +- **Trade Exchange** - Token trading platform +- **Explorer Web** - Blockchain explorer +- **Pool Hub** - Miner coordination service + +## Component Interactions + +``` +┌─────────────┐ ┌──────────────┐ ┌─────────────┐ +│ Clients │────▶│ Coordinator │────▶│ Blockchain │ +│ │ │ API │ │ Node │ +└─────────────┘ └──────────────┘ └─────────────┘ + │ │ │ + ▼ ▼ ▼ +┌─────────────┐ ┌──────────────┐ ┌─────────────┐ +│ Wallet │ │ Pool Hub │ │ Miners │ +│ Daemon │ │ │ │ │ +└─────────────┘ └──────────────┘ └─────────────┘ +``` + +## Quick Links + +[Trade Exchange](https://aitbc.bubuit.net/Exchange/) +[Marketplace](https://aitbc.bubuit.net/marketplace/) +[Explorer](https://aitbc.bubuit.net/explorer/) +[API Docs](https://aitbc.bubuit.net/api/docs) + +## Status Legend + +- ● Live - Production ready and deployed +- ● Beta - In testing, limited availability +- ● Development - Under active development + +## Deployment Information + +All components are containerized and can be deployed using Docker Compose: + +```bash +# Deploy all components +docker-compose up -d + +# Check status +docker-compose ps + +# View logs +docker-compose logs -f +``` + +## Support + +For component-specific issues: +- Check individual documentation pages +- Visit the [GitHub repository](https://github.com/aitbc/platform) +- Contact: [aitbc@bubuit.net](mailto:aitbc@bubuit.net) diff --git a/docs/coordinator-api.md b/docs/coordinator-api.md new file mode 100644 index 00000000..71face69 --- /dev/null +++ b/docs/coordinator-api.md @@ -0,0 +1,254 @@ +# Coordinator API - AITBC Documentation + +FastAPI service for job submission, miner registration, and receipt management. SQLite persistence with comprehensive endpoints. + +● Live + +## Overview + +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. + +### Key Features + +- Job submission and tracking +- Miner registration and heartbeat monitoring +- Receipt management and verification +- User management with wallet-based authentication +- SQLite persistence with SQLModel ORM +- Comprehensive API documentation with OpenAPI + +## Architecture + +The Coordinator API follows a clean architecture with separation of concerns for domain models, API routes, and business logic. + +#### API Layer +FastAPI routers for clients, miners, admin, and users + +#### Domain Models +SQLModel definitions for jobs, miners, receipts, users + +#### Business Logic +Service layer handling job orchestration + +#### Persistence +SQLite database with Alembic migrations + +## API Reference + +The Coordinator API provides RESTful endpoints for all major operations. + +### Client Endpoints + +`POST /v1/client/jobs` +Submit a new computation job + +`GET /v1/client/jobs/{job_id}/status` +Get job status and progress + +`GET /v1/client/jobs/{job_id}/receipts` +Retrieve computation receipts + +### Miner Endpoints + +`POST /v1/miner/register` +Register as a compute provider + +`POST /v1/miner/heartbeat` +Send miner heartbeat + +`GET /v1/miner/jobs` +Fetch available jobs + +`POST /v1/miner/result` +Submit job result + +### User Management + +`POST /v1/users/login` +Login or register with wallet + +`GET /v1/users/me` +Get current user profile + +`GET /v1/users/{user_id}/balance` +Get user wallet balance + +### Exchange Endpoints + +`POST /v1/exchange/create-payment` +Create Bitcoin payment request + +`GET /v1/exchange/payment-status/{id}` +Check payment status + +## Authentication + +The API uses API key authentication for clients and miners, and session-based authentication for users. + +### API Keys + +```http +X-Api-Key: your-api-key-here +``` + +### Session Tokens + +```http +X-Session-Token: sha256-token-here +``` + +### Example Request + +```bash +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": {...} + }' +``` + +## Configuration + +The Coordinator API can be configured via environment variables. + +### Environment Variables + +```bash +# 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 +``` + +## Deployment + +The Coordinator API runs in a Docker container with nginx proxy. + +### Docker Deployment + +```bash +# 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 +``` + +### Systemd Service + +```bash +# Start service +sudo systemctl start aitbc-coordinator + +# Check status +sudo systemctl status aitbc-coordinator + +# View logs +sudo journalctl -u aitbc-coordinator -f +``` + +## Interactive API Documentation + +Interactive API documentation is available via Swagger UI and ReDoc. + +- [Swagger UI](https://aitbc.bubuit.net/api/docs) +- [ReDoc](https://aitbc.bubuit.net/api/redoc) +- [OpenAPI Spec](https://aitbc.bubuit.net/api/openapi.json) + +## Data Models + +### Job + +```json +{ + "id": "uuid", + "client_id": "string", + "job_type": "llm_inference", + "parameters": {}, + "status": "pending|running|completed|failed", + "created_at": "timestamp", + "updated_at": "timestamp" +} +``` + +### Miner + +```json +{ + "id": "uuid", + "address": "string", + "endpoint": "string", + "capabilities": [], + "status": "active|inactive", + "last_heartbeat": "timestamp" +} +``` + +### Receipt + +```json +{ + "id": "uuid", + "job_id": "uuid", + "miner_id": "uuid", + "result": {}, + "proof": "string", + "created_at": "timestamp" +} +``` + +## Error Handling + +The API returns standard HTTP status codes with detailed error messages: + +```json +{ + "error": { + "code": "INVALID_JOB_TYPE", + "message": "The specified job type is not supported", + "details": {} + } +} +``` + +## Rate Limiting + +API endpoints are rate-limited to prevent abuse: + +- Client endpoints: 100 requests/minute +- Miner endpoints: 1000 requests/minute +- User endpoints: 60 requests/minute + +## Monitoring + +The Coordinator API exposes metrics at `/metrics` endpoint: + +- `api_requests_total` - Total API requests +- `api_request_duration_seconds` - Request latency +- `active_jobs` - Currently active jobs +- `registered_miners` - Number of registered miners + +## Security + +- All sensitive endpoints require authentication +- API keys should be kept confidential +- HTTPS is required in production +- Input validation on all endpoints +- SQL injection prevention via ORM diff --git a/docs/developer-documentation.md b/docs/developer-documentation.md new file mode 100644 index 00000000..f3e86895 --- /dev/null +++ b/docs/developer-documentation.md @@ -0,0 +1,259 @@ +# Developer Documentation - AITBC + +Build on the AITBC platform: SDKs, APIs, bounties, and resources for developers. + +## Quick Start + +### Prerequisites + +- Git +- Docker and Docker Compose +- Node.js 18+ (for frontend) +- Python 3.9+ (for AI services) +- Rust 1.70+ (for blockchain) + +### Setup Development Environment + +```bash +# Clone the repository +git clone https://gitea.bubuit.net/oib/aitbc.git +cd aitbc + +# Start all services +docker-compose up -d + +# Check status +docker-compose ps +``` + +## Architecture Overview + +The AITBC platform consists of: + +- **Blockchain Node** (Rust) - PoA/PoS consensus layer +- **Coordinator API** (Python/FastAPI) - Job orchestration +- **Marketplace Web** (TypeScript/Vite) - User interface +- **Miner Daemons** (Go) - GPU compute providers +- **Wallet Daemon** (Go) - Secure wallet management + +## Contributing + +### How to Contribute + +1. Fork the repository on Gitea +2. Create a feature branch: `git checkout -b feature/amazing-feature` +3. Make your changes +4. Add tests for new functionality +5. Ensure all tests pass: `make test` +6. Submit a pull request + +### Code Style + +- **Rust**: Use `rustfmt` and `clippy` +- **Python**: Follow PEP 8, use `black` and `flake8` +- **TypeScript**: Use Prettier and ESLint +- **Go**: Use `gofmt` + +### Pull Request Process + +1. Update documentation for any changes +2. Add unit tests for new features +3. Ensure CI/CD pipeline passes +4. Request review from core team +5. Address feedback promptly + +## Bounty Program + +Get paid to contribute to AITBC! Check open bounties on Gitea. + +### Current Bounties + +- **$500** - Implement REST API rate limiting +- **$750** - Add Python async SDK support +- **$1000** - Optimize ZK proof generation +- **$1500** - Implement cross-chain bridge +- **$2000** - Build mobile wallet app + +### Research Grants + +- **$5000** - Novel consensus mechanisms +- **$7500** - Privacy-preserving ML +- **$10000** - Quantum-resistant cryptography + +### How to Apply + +1. Check open issues on Gitea +2. Comment on the issue you want to work on +3. Submit your solution +4. Get reviewed by core team +5. Receive payment in AITBC tokens + +> **New Contributor Bonus:** First-time contributors get a 20% bonus on their first bounty! + +## Join the Community + +### Developer Channels + +- **Discord #dev** - General development discussion +- **Discord #core-dev** - Core protocol discussions +- **Discord #bounties** - Bounty program updates +- **Discord #research** - Research discussions + +### Events & Programs + +- **Weekly Dev Calls** - Every Tuesday 14:00 UTC +- **Hackathons** - Quarterly with prizes +- **Office Hours** - Meet the core team +- **Mentorship Program** - Learn from experienced devs + +### Recognition + +- Top contributors featured on website +- Monthly contributor rewards +- Special Discord roles +- Annual developer summit invitation +- Swag and merchandise + +## Developer Resources + +### Documentation + +- [Full API Documentation](full-documentation.md) +- [Architecture Guide](architecture.md) +- [Protocol Specification](protocol.md) +- [Security Best Practices](security.md) + +### Tools & SDKs + +- [Python SDK](sdks/python.md) +- [JavaScript SDK](sdks/javascript.md) +- [Go SDK](sdks/go.md) +- [Rust SDK](sdks/rust.md) +- [CLI Tools](cli-tools.md) + +### Development Environment + +- [Docker Compose Setup](setup/docker-compose.md) +- [Local Testnet](setup/testnet.md) +- [Faucet for Test Tokens](setup/faucet.md) +- [Block Explorer](tools/explorer.md) + +### Learning Resources + +- [Video Tutorials](tutorials/videos.md) +- [Workshop Materials](tutorials/workshops.md) +- [Blog Posts](blog/index.md) +- [Research Papers](research/papers.md) + +## Example: Adding a New API Endpoint + +The coordinator-api uses Python with FastAPI. Here's how to add a new endpoint: + +### 1. Define the Schema + +```python +# File: coordinator-api/src/app/schemas.py + +from pydantic import BaseModel +from typing import Optional + +class NewFeatureRequest(BaseModel): + """Request model for new feature.""" + name: str + value: int + options: Optional[dict] = None + +class NewFeatureResponse(BaseModel): + """Response model for new feature.""" + id: str + status: str + result: dict +``` + +### 2. Create the Router + +```python +# File: coordinator-api/src/app/routers/new_feature.py + +from fastapi import APIRouter, Depends, HTTPException +from ..schemas import NewFeatureRequest, NewFeatureResponse +from ..services.new_feature import NewFeatureService + +router = APIRouter(prefix="/v1/features", tags=["features"]) + +@router.post("/", response_model=NewFeatureResponse) +async def create_feature( + request: NewFeatureRequest, + service: NewFeatureService = Depends() +): + """Create a new feature.""" + try: + result = await service.process(request) + return NewFeatureResponse( + id=result.id, + status="success", + result=result.data + ) + except ValueError as e: + raise HTTPException(status_code=400, detail=str(e)) +``` + +### 3. Write Tests + +```python +# File: coordinator-api/tests/test_new_feature.py + +import pytest +from fastapi.testclient import TestClient +from src.app.main import app + +client = TestClient(app) + +def test_create_feature_success(): + """Test successful feature creation.""" + response = client.post( + "/v1/features/", + json={"name": "test", "value": 123} + ) + assert response.status_code == 200 + data = response.json() + assert data["status"] == "success" + assert "id" in data + +def test_create_feature_invalid(): + """Test validation error.""" + response = client.post( + "/v1/features/", + json={"name": ""} # Missing required field + ) + assert response.status_code == 422 +``` + +> **💡 Pro Tip:** Run `make test` locally before pushing. The CI pipeline will also run all tests automatically on your PR. + +## Frequently Asked Questions + +### General + +- **How do I start contributing?** - Check our "Getting Started" guide and pick an issue that interests you. +- **Do I need to sign anything?** - Yes, you'll need to sign our CLA (Contributor License Agreement). +- **Can I be paid for contributions?** - Yes! Check our bounty program or apply for grants. + +### Technical + +- **What's the tech stack?** - Rust for blockchain, Go for services, Python for AI, TypeScript for frontend. +- **How do I run tests?** - Use `make test` or check specific component documentation. +- **Where can I ask questions?** - Discord #dev channel is the best place. + +### Process + +- **How long does PR review take?** - Usually 1-3 business days. +- **Can I work on multiple issues?** - Yes, but submit one PR per feature. +- **What if I need help?** - Ask in Discord or create a "help wanted" issue. + +## Getting Help + +- **Documentation**: [https://docs.aitbc.bubuit.net](https://docs.aitbc.bubuit.net) +- **Discord**: [Join our server](https://discord.gg/aitbc) +- **Email**: [aitbc@bubuit.net](mailto:aitbc@bubuit.net) +- **Issues**: [Report on Gitea](https://gitea.bubuit.net/oib/aitbc/issues) diff --git a/docs/flowchart.md b/docs/flowchart.md new file mode 100644 index 00000000..9ee49bb9 --- /dev/null +++ b/docs/flowchart.md @@ -0,0 +1,336 @@ +# AITBC System Flow: From CLI Prompt to Response + +This document illustrates the complete flow of a job submission through the CLI client, detailing each system component, message, RPC call, and port involved. + +## Overview Diagram + +``` +┌─────────────┐ ┌──────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ +│ CLI │ │ Client │ │Coordinator │ │ Blockchain │ │ Miner │ │ Ollama │ +│ Wrapper │────▶│ Python │────▶│ Service │────▶│ Node │────▶│ Daemon │────▶│ Server │ +│(aitbc-cli.sh)│ │ (client.py) │ │ (port 18000)│ │ (RPC:26657) │ │ (port 18001)│ │ (port 11434)│ +└─────────────┘ └──────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ +``` + +## Detailed Flow Sequence + +### 1. CLI Wrapper Execution + +**User Command:** +```bash +./scripts/aitbc-cli.sh submit inference --prompt "What is machine learning?" --model llama3.2:latest +``` + +**Internal Process:** +1. Bash script (`aitbc-cli.sh`) parses arguments +2. Sets environment variables: + - `AITBC_URL=http://127.0.0.1:18000` + - `CLIENT_KEY=REDACTED_CLIENT_KEY` +3. Calls Python client: `python3 cli/client.py --url $AITBC_URL --api-key $CLIENT_KEY submit inference --prompt "..."` + +### 2. Python Client Processing + +**File:** `/cli/client.py` + +**Steps:** +1. Parse command-line arguments +2. Prepare job submission payload: + ```json + { + "type": "inference", + "prompt": "What is machine learning?", + "model": "llama3.2:latest", + "client_key": "REDACTED_CLIENT_KEY", + "timestamp": "2025-01-29T14:50:00Z" + } + ``` + +### 3. Coordinator API Call + +**HTTP Request:** +```http +POST /v1/jobs +Host: 127.0.0.1:18000 +Content-Type: application/json +X-Api-Key: REDACTED_CLIENT_KEY + +{ + "type": "inference", + "prompt": "What is machine learning?", + "model": "llama3.2:latest" +} +``` + +**Coordinator Service (Port 18000):** +1. Receives HTTP request +2. Validates API key and job parameters +3. Generates unique job ID: `job_123456` +4. Creates job record in database +5. Returns initial response: + ```json + { + "job_id": "job_123456", + "status": "pending", + "submitted_at": "2025-01-29T14:50:01Z" + } + ``` + +### 4. Blockchain Transaction + +**Coordinator → Blockchain Node (RPC Port 26657):** + +1. Coordinator creates blockchain transaction: + ```json + { + "type": "submit_job", + "job_id": "job_123456", + "client": "REDACTED_CLIENT_KEY", + "payload_hash": "abc123...", + "reward": "100aitbc" + } + ``` + +2. RPC Call to blockchain node: + ```bash + curl -X POST http://127.0.0.1:26657 \ + -d '{ + "jsonrpc": "2.0", + "method": "broadcast_tx_sync", + "params": {"tx": "base64_encoded_transaction"} + }' + ``` + +3. Blockchain validates and includes transaction in next block +4. Transaction hash returned: `0xdef456...` + +### 5. Job Queue and Miner Assignment + +**Coordinator Internal Processing:** +1. Job added to pending queue (Redis/Database) +2. Miner selection algorithm runs: + - Check available miners + - Select based on stake, reputation, capacity +3. Selected miner: `REDACTED_MINER_KEY` + +**Coordinator → Miner Daemon (Port 18001):** +```http +POST /v1/jobs/assign +Host: 127.0.0.1:18001 +Content-Type: application/json +X-Api-Key: REDACTED_ADMIN_KEY + +{ + "job_id": "job_123456", + "job_data": { + "type": "inference", + "prompt": "What is machine learning?", + "model": "llama3.2:latest" + }, + "reward": "100aitbc" +} +``` + +### 6. Miner Processing + +**Miner Daemon (Port 18001):** +1. Receives job assignment +2. Updates job status to `running` +3. Notifies coordinator: + ```http + POST /v1/jobs/job_123456/status + {"status": "running", "started_at": "2025-01-29T14:50:05Z"} + ``` + +### 7. Ollama Inference Request + +**Miner → Ollama Server (Port 11434):** +```http +POST /api/generate +Host: 127.0.0.1:11434 +Content-Type: application/json + +{ + "model": "llama3.2:latest", + "prompt": "What is machine learning?", + "stream": false, + "options": { + "temperature": 0.7, + "num_predict": 500 + } +} +``` + +**Ollama Processing:** +1. Loads model into GPU memory +2. Processes prompt through neural network +3. Generates response text +4. Returns result: + ```json + { + "model": "llama3.2:latest", + "response": "Machine learning is a subset of artificial intelligence...", + "done": true, + "total_duration": 12500000000, + "prompt_eval_count": 15, + "eval_count": 150 + } + ``` + +### 8. Result Submission to Coordinator + +**Miner → Coordinator (Port 18000):** +```http +POST /v1/jobs/job_123456/complete +Host: 127.0.0.1:18000 +Content-Type: application/json +X-Miner-Key: REDACTED_MINER_KEY + +{ + "job_id": "job_123456", + "result": "Machine learning is a subset of artificial intelligence...", + "metrics": { + "compute_time": 12.5, + "tokens_generated": 150, + "gpu_utilization": 0.85 + }, + "proof": { + "hash": "hash_of_result", + "signature": "miner_signature" + } +} +``` + +### 9. Receipt Generation + +**Coordinator Processing:** +1. Verifies miner's proof +2. Calculates payment: `12.5 seconds × 0.02 AITBC/second = 0.25 AITBC` +3. Creates receipt: + ```json + { + "receipt_id": "receipt_789", + "job_id": "job_123456", + "client": "REDACTED_CLIENT_KEY", + "miner": "REDACTED_MINER_KEY", + "amount_paid": "0.25aitbc", + "result_hash": "hash_of_result", + "block_height": 12345, + "timestamp": "2025-01-29T14:50:18Z" + } + ``` + +### 10. Blockchain Receipt Recording + +**Coordinator → Blockchain (RPC Port 26657):** +```json +{ + "type": "record_receipt", + "receipt": { + "receipt_id": "receipt_789", + "job_id": "job_123456", + "payment": "0.25aitbc" + } +} +``` + +### 11. Client Polling for Result + +**CLI Client Status Check:** +```bash +./scripts/aitbc-cli.sh status job_123456 +``` + +**HTTP Request:** +```http +GET /v1/jobs/job_123456 +Host: 127.0.0.1:18000 +X-Api-Key: REDACTED_CLIENT_KEY +``` + +**Response:** +```json +{ + "job_id": "job_123456", + "status": "completed", + "result": "Machine learning is a subset of artificial intelligence...", + "receipt_id": "receipt_789", + "completed_at": "2025-01-29T14:50:18Z" +} +``` + +### 12. Final Output to User + +**CLI displays:** +``` +Job ID: job_123456 +Status: completed +Result: Machine learning is a subset of artificial intelligence... +Receipt: receipt_789 +Completed in: 17 seconds +Cost: 0.25 AITBC +``` + +## System Components Summary + +| Component | Port | Protocol | Responsibility | +|-----------|------|----------|----------------| +| CLI Wrapper | N/A | Bash | User interface, argument parsing | +| Client Python | N/A | Python | HTTP client, job formatting | +| Coordinator | 18000 | HTTP/REST | Job management, API gateway | +| Blockchain Node | 26657 | JSON-RPC | Transaction processing, consensus | +| Miner Daemon | 18001 | HTTP/REST | Job execution, GPU management | +| Ollama Server | 11434 | HTTP/REST | AI model inference | + +## Message Flow Timeline + +``` +0s: User submits CLI command +└─> 0.1s: Python client called + └─> 0.2s: HTTP POST to Coordinator (port 18000) + └─> 0.3s: Coordinator validates and creates job + └─> 0.4s: RPC to Blockchain (port 26657) + └─> 0.5s: Transaction in mempool + └─> 1.0s: Job queued for miner + └─> 2.0s: Miner assigned (port 18001) + └─> 2.1s: Miner accepts job + └─> 2.2s: Ollama request (port 11434) + └─> 14.7s: Inference complete (12.5s processing) + └─> 14.8s: Result to Coordinator + └─> 15.0s: Receipt generated + └─> 15.1s: Receipt on Blockchain + └─> 17.0s: Client polls and gets result +``` + +## Error Handling Paths + +1. **Invalid Prompt**: + - Coordinator returns 400 error + - CLI displays error message + +2. **Miner Unavailable**: + - Job stays in queue + - Timeout after 60 seconds + - Job marked as failed + +3. **Ollama Error**: + - Miner reports failure to Coordinator + - Job marked as failed + - No payment deducted + +4. **Network Issues**: + - Client retries with exponential backoff + - Maximum 3 retries before giving up + +## Security Considerations + +1. **API Keys**: Each request authenticated with X-Api-Key header +2. **Proof of Work**: Miner provides cryptographic proof of computation +3. **Payment Escrow**: Tokens held in smart contract until completion +4. **Rate Limiting**: Coordinator limits requests per client + +## Monitoring Points + +- Coordinator logs all API calls to `/var/log/aitbc/coordinator.log` +- Miner logs GPU utilization to `/var/log/aitbc/miner.log` +- Blockchain logs all transactions to `/var/log/aitbc/node.log` +- Prometheus metrics available at `http://localhost:9090/metrics` diff --git a/docs/full-documentation.md b/docs/full-documentation.md new file mode 100644 index 00000000..9325bd33 --- /dev/null +++ b/docs/full-documentation.md @@ -0,0 +1,392 @@ +# AITBC Full Documentation + +Complete technical documentation for the AI Training & Blockchain Computing platform + +## Table of Contents + +- [Introduction](#introduction) +- [Architecture](#architecture) + - [Core Components](#core-components) + - [Data Flow](#data-flow) + - [Consensus Mechanism](#consensus) +- [Installation](#installation) + - [Prerequisites](#prerequisites) + - [Quick Start](#quick-start) + - [Configuration](#configuration) +- [APIs](#apis) + - [Coordinator API](#coordinator-api) + - [Blockchain RPC](#blockchain-rpc) + - [Wallet API](#wallet-api) +- [Components](#components) + - [Blockchain Node](#blockchain-node) + - [Coordinator Service](#coordinator-service) + - [Miner Daemon](#miner-daemon) + - [Wallet Daemon](#wallet-daemon) +- [Guides](#guides) + - [Client Guide](#client-guide) + - [Miner Guide](#miner-guide) + - [Developer Guide](#developer-guide) + +## Introduction + +AITBC (AI Training & Blockchain Computing) is a decentralized platform that connects clients needing AI compute power with miners providing GPU resources. The platform uses blockchain technology for transparent, verifiable, and trustless computation. + +### Key Concepts + +- **Jobs**: Units of AI computation submitted by clients +- **Miners**: GPU providers who process jobs and earn rewards +- **Tokens**: AITBC tokens used for payments and staking +- **Receipts**: Cryptographic proofs of computation +- **Staking**: Locking tokens to secure the network + +## Architecture + +### Core Components + +``` +┌─────────────┐ ┌──────────────┐ ┌─────────────┐ +│ Clients │────▶│ Coordinator │────▶│ Blockchain │ +│ │ │ API │ │ Node │ +└─────────────┘ └──────────────┘ └─────────────┘ + │ │ │ + ▼ ▼ ▼ +┌─────────────┐ ┌──────────────┐ ┌─────────────┐ +│ Wallet │ │ Pool Hub │ │ Miners │ +│ Daemon │ │ │ │ │ +└─────────────┘ └──────────────┘ └─────────────┘ +``` + +### Data Flow + +1. Client submits job to Coordinator API +2. Coordinator creates blockchain transaction +3. Job assigned to available miner +4. Miner processes job using GPU +5. Result submitted with cryptographic proof +6. Payment processed and receipt generated + +### Consensus Mechanism + +AITBC uses a hybrid Proof-of-Authority/Proof-of-Stake consensus: + +- **PoA**: Authority nodes validate transactions +- **PoS**: Token holders stake to secure network +- **Finality**: Sub-second transaction finality +- **Rewards**: Distributed to stakers and miners + +## Installation + +### Prerequisites + +- Docker & Docker Compose +- Git +- 8GB+ RAM +- 100GB+ storage + +### Quick Start + +```bash +# Clone repository +git clone https://gitea.bubuit.net/oib/aitbc.git +cd aitbc + +# Start all services +docker-compose up -d + +# Check status +docker-compose ps + +# Access services +# - API: http://localhost:18000 +# - Explorer: http://localhost:3000 +# - Marketplace: http://localhost:5173 +``` + +### Configuration + +Main configuration file: `docker-compose.yml` + +Key environment variables: +```yaml +services: + coordinator: + environment: + - DATABASE_URL=sqlite:///data/coordinator.db + - API_HOST=0.0.0.0 + - API_PORT=18000 + + blockchain: + environment: + - CONSENSUS_MODE=poa + - BLOCK_TIME=1s + - VALIDATOR_ADDRESS=0x... +``` + +## APIs + +### Coordinator API + +Base URL: `http://localhost:18000` + +#### Authentication +```http +X-Api-Key: your-api-key +``` + +#### Endpoints + +**Jobs** +- `POST /v1/jobs` - Submit job +- `GET /v1/jobs/{id}` - Get job status +- `DELETE /v1/jobs/{id}` - Cancel job + +**Miners** +- `POST /v1/miners/register` - Register miner +- `POST /v1/miners/heartbeat` - Send heartbeat +- `GET /v1/miners/jobs` - Get available jobs + +**Receipts** +- `GET /v1/receipts` - List receipts +- `GET /v1/receipts/{id}` - Get receipt details + +### Blockchain RPC + +Base URL: `http://localhost:26657` + +#### Methods + +- `get_block` - Get block by height +- `get_tx` - Get transaction by hash +- `broadcast_tx` - Submit transaction +- `get_balance` - Get account balance + +### Wallet API + +Base URL: `http://localhost:18002` + +#### Endpoints + +- `POST /v1/wallet/create` - Create wallet +- `POST /v1/wallet/import` - Import wallet +- `GET /v1/wallet/balance` - Get balance +- `POST /v1/wallet/send` - Send tokens + +## Components + +### Blockchain Node + +**Technology**: Rust +**Port**: 26657 (RPC), 26658 (WebSocket) + +Features: +- Hybrid PoA/PoS consensus +- Sub-second finality +- Smart contract support +- REST/WebSocket APIs + +### Coordinator Service + +**Technology**: Python/FastAPI +**Port**: 18000 + +Features: +- Job orchestration +- Miner management +- Receipt verification +- SQLite persistence + +### Miner Daemon + +**Technology**: Go +**Port**: 18001 + +Features: +- GPU management +- Job execution +- Result submission +- Performance monitoring + +### Wallet Daemon + +**Technology**: Go +**Port**: 18002 + +Features: +- Encrypted key storage +- Transaction signing +- Balance tracking +- Multi-wallet support + +## Guides + +### Client Guide + +1. **Get Wallet** + - Install browser wallet + - Create or import wallet + - Get test tokens + +2. **Submit Job** + ```bash + ./aitbc-cli.sh submit "Your prompt" --model llama3.2 + ``` + +3. **Track Progress** + ```bash + ./aitbc-cli.sh status + ``` + +4. **Verify Result** + ```bash + ./aitbc-cli.sh receipts --job-id + ``` + +### Miner Guide + +1. **Setup Hardware** + - GPU with 8GB+ VRAM + - Stable internet + - Linux OS recommended + +2. **Install Miner** + ```bash + wget https://gitea.bubuit.net/oib/aitbc/releases/download/latest/aitbc-miner + chmod +x aitbc-miner + ./aitbc-miner init + ``` + +3. **Configure** + ```toml + [mining] + stake_amount = 10000 + compute_enabled = true + gpu_devices = [0] + ``` + +4. **Start Mining** + ```bash + ./aitbc-miner start + ``` + +### Developer Guide + +1. **Setup Development** + ```bash + git clone https://gitea.bubuit.net/oib/aitbc.git + cd aitbc + docker-compose -f docker-compose.dev.yml up + ``` + +2. **Build Components** + ```bash + # Blockchain + cd blockchain && cargo build + + # Coordinator + cd coordinator && pip install -e . + + # Miner + cd miner && go build + ``` + +3. **Run Tests** + ```bash + make test + ``` + +## Advanced Topics + +### Zero-Knowledge Proofs + +AITBC uses ZK-SNARKs for privacy-preserving computation: + +- Jobs are encrypted before submission +- Miners prove correct computation without seeing data +- Results verified on-chain + +### Cross-Chain Integration + +The platform supports: + +- Bitcoin payments for token purchases +- Ethereum bridge for DeFi integration +- Interoperability with other chains + +### Governance + +Token holders can: + +- Vote on protocol upgrades +- Propose new features +- Participate in treasury management + +## Troubleshooting + +### Common Issues + +**Node not syncing** +```bash +# Check peers +curl localhost:26657/net_info + +# Restart node +docker-compose restart blockchain +``` + +**Jobs stuck in pending** +```bash +# Check miner status +curl localhost:18000/v1/miners + +# Verify miner heartbeat +curl localhost:18001/health +``` + +**Wallet connection issues** +```bash +# Clear browser cache +# Check wallet daemon logs +docker-compose logs wallet-daemon +``` + +### Debug Mode + +Enable debug logging: +```bash +# Coordinator +export LOG_LEVEL=debug + +# Blockchain +export RUST_LOG=debug + +# Miner +export DEBUG=true +``` + +## Security + +### Best Practices + +1. **Use hardware wallets** for large amounts +2. **Enable 2FA** on all accounts +3. **Regular security updates** +4. **Monitor for unusual activity** +5. **Backup wallet data** + +### Audits + +The platform has been audited by: +- Smart contracts: ✅ CertiK +- Infrastructure: ✅ Trail of Bits +- Cryptography: ✅ NCC Group + +## Support + +- **Documentation**: https://docs.aitbc.bubuit.net +- **Discord**: https://discord.gg/aitbc +- **Email**: aitbc@bubuit.net +- **Issues**: https://gitea.bubuit.net/oib/aitbc/issues + +## License + +MIT License - see [LICENSE](https://github.com/aitbc/platform/blob/main/LICENSE) for details. diff --git a/docs/marketplace-web.md b/docs/marketplace-web.md new file mode 100644 index 00000000..64686521 --- /dev/null +++ b/docs/marketplace-web.md @@ -0,0 +1,410 @@ +# Marketplace Web - AITBC Documentation + +Vite/TypeScript marketplace with offer/bid functionality, stats dashboard, and mock/live data toggle. Production UI ready. + +● Live + +## Overview + +The Marketplace Web is the primary interface for clients to submit AI compute jobs and for miners to offer their services. It provides a real-time trading platform with comprehensive job management and analytics. + +### Key Features + +- Real-time job marketplace with offer/bid functionality +- Interactive statistics dashboard +- Mock/live data toggle for development +- Responsive design for all devices +- WebSocket integration for live updates +- Wallet integration for seamless payments + +## Technology Stack + +- **Framework**: Vite 4.x +- **Language**: TypeScript 5.x +- **UI**: TailwindCSS + Headless UI +- **State Management**: Zustand +- **Charts**: Chart.js +- **WebSocket**: Native WebSocket API +- **Icons**: Lucide React + +## Getting Started + +### Prerequisites + +- Node.js 18+ +- npm or yarn + +### Installation + +```bash +# Clone the repository +git clone https://gitea.bubuit.net/oib/aitbc.git +cd aitbc/apps/marketplace-web + +# Install dependencies +npm install + +# Start development server +npm run dev + +# Build for production +npm run build + +# Preview production build +npm run preview +``` + +### Environment Variables + +Create `.env.local`: + +```env +VITE_API_URL=http://localhost:18000 +VITE_WS_URL=ws://localhost:18000/ws +VITE_EXPLORER_URL=http://localhost:3000 +VITE_NETWORK=mainnet +``` + +## Architecture + +### Directory Structure + +``` +marketplace-web/ +├── src/ +│ ├── components/ # Reusable UI components +│ ├── pages/ # Page components +│ ├── hooks/ # Custom React hooks +│ ├── stores/ # Zustand stores +│ ├── types/ # TypeScript definitions +│ ├── utils/ # Utility functions +│ └── styles/ # Global styles +├── public/ # Static assets +└── dist/ # Build output +``` + +### Core Components + +#### JobCard +Display job information with real-time status updates. + +```typescript +interface JobCardProps { + job: Job; + onBid?: (jobId: string, amount: number) => void; + showActions?: boolean; +} +``` + +#### StatsDashboard +Real-time statistics and charts. + +```typescript +interface StatsData { + totalJobs: number; + activeMiners: number; + avgProcessingTime: number; + totalVolume: number; +} +``` + +#### OfferPanel +Create and manage job offers. + +```typescript +interface OfferForm { + model: string; + prompt: string; + parameters: JobParameters; + maxPrice: number; +} +``` + +## Features + +### 1. Job Marketplace + +Browse and submit AI compute jobs: + +- Filter by model type and price +- Sort by deadline or reward +- Real-time status updates +- Bid on available jobs + +### 2. Statistics Dashboard + +Monitor network activity: + +- Total jobs and volume +- Active miners count +- Average processing times +- Historical charts + +### 3. Wallet Integration + +Connect your AITBC wallet: + +- Browser wallet support +- Balance display +- Transaction history +- One-click payments + +### 4. Developer Mode + +Toggle between mock and live data: + +```typescript +const isDevMode = import.meta.env.DEV; +const useMockData = localStorage.getItem('useMockData') === 'true'; +``` + +## API Integration + +### WebSocket Events + +```typescript +// Connect to WebSocket +const ws = new WebSocket(VITE_WS_URL); + +// Listen for job updates +ws.on('job_update', (data: JobUpdate) => { + updateJobStatus(data.jobId, data.status); +}); + +// Listen for new bids +ws.on('new_bid', (data: Bid) => { + addBidToList(data); +}); +``` + +### REST API Calls + +```typescript +// Submit job +const submitJob = async (job: JobSubmission) => { + const response = await fetch(`${VITE_API_URL}/v1/jobs`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-Api-Key': apiKey, + }, + body: JSON.stringify(job), + }); + return response.json(); +}; + +// Get market stats +const getStats = async () => { + const response = await fetch(`${VITE_API_URL}/v1/stats`); + return response.json(); +}; +``` + +## State Management + +Using Zustand for state management: + +```typescript +// stores/marketplace.ts +interface MarketplaceStore { + jobs: Job[]; + stats: StatsData; + filters: FilterOptions; + setJobs: (jobs: Job[]) => void; + updateJob: (jobId: string, updates: Partial) => void; + setFilters: (filters: FilterOptions) => void; +} + +export const useMarketplaceStore = create((set) => ({ + jobs: [], + stats: initialStats, + filters: {}, + setJobs: (jobs) => set({ jobs }), + updateJob: (jobId, updates) => + set((state) => ({ + jobs: state.jobs.map((job) => + job.id === jobId ? { ...job, ...updates } : job + ), + })), + setFilters: (filters) => set({ filters }), +})); +``` + +## Styling + +### TailwindCSS Configuration + +```javascript +// tailwind.config.js +module.exports = { + content: ['./src/**/*.{js,ts,jsx,tsx}'], + theme: { + extend: { + colors: { + primary: '#2563eb', + secondary: '#1e40af', + }, + }, + }, + plugins: [], +}; +``` + +### CSS Variables + +```css +/* src/styles/globals.css */ +:root { + --color-primary: #2563eb; + --color-secondary: #1e40af; + --color-success: #10b981; + --color-warning: #f59e0b; + --color-danger: #ef4444; +} +``` + +## Deployment + +### Docker Deployment + +```dockerfile +FROM node:18-alpine + +WORKDIR /app +COPY package*.json ./ +RUN npm ci --only=production + +COPY . . +RUN npm run build + +FROM nginx:alpine +COPY --from=0 /app/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/nginx.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] +``` + +### Environment Configuration + +#### Production + +```env +VITE_API_URL=https://aitbc.bubuit.net/api +VITE_WS_URL=wss://aitbc.bubuit.net/ws +VITE_NETWORK=mainnet +``` + +#### Staging + +```env +VITE_API_URL=https://staging.aitbc.bubuit.net/api +VITE_WS_URL=wss://staging.aitbc.bubuit.net/ws +VITE_NETWORK=testnet +``` + +## Testing + +### Unit Tests + +```bash +# Run tests +npm run test + +# Run with coverage +npm run test:coverage +``` + +### E2E Tests + +```bash +# Install Playwright +npm run install:e2e + +# Run E2E tests +npm run test:e2e +``` + +## Performance Optimization + +### Code Splitting + +```typescript +// Lazy load components +const StatsDashboard = lazy(() => import('./components/StatsDashboard')); +const JobList = lazy(() => import('./components/JobList')); + +// Use with Suspense +}> + + +``` + +### Image Optimization + +```typescript +// Use next-gen formats +const optimizedImage = { + src: '/api/og?title=Marketplace', + width: 1200, + height: 630, + format: 'avif', +}; +``` + +## Troubleshooting + +### Common Issues + +1. **WebSocket Connection Failed** + - Check WS_URL in environment + - Verify firewall settings + - Check browser console for errors + +2. **Data Not Loading** + - Toggle mock/live data switch + - Check API endpoint status + - Verify API key configuration + +3. **Build Errors** + - Clear node_modules and reinstall + - Check TypeScript version + - Verify all imports + +### Debug Mode + +Enable debug logging: + +```typescript +if (import.meta.env.DEV) { + console.log('Debug info:', debugData); +} +``` + +## Contributing + +1. Fork the repository +2. Create feature branch +3. Make changes +4. Add tests +5. Submit PR + +### Code Style + +- Use TypeScript strict mode +- Follow ESLint rules +- Use Prettier for formatting +- Write meaningful commit messages + +## Security + +- Never commit API keys +- Use environment variables for secrets +- Implement rate limiting +- Validate all inputs +- Use HTTPS in production + +## Support + +- Documentation: [docs.aitbc.bubuit.net](https://docs.aitbc.bubuit.net) +- Discord: [discord.gg/aitbc](https://discord.gg/aitbc) +- Issues: [Gitea Issues](https://gitea.bubuit.net/oib/aitbc/issues) diff --git a/docs/miner-documentation.md b/docs/miner-documentation.md new file mode 100644 index 00000000..bf67e3e5 --- /dev/null +++ b/docs/miner-documentation.md @@ -0,0 +1,317 @@ +# Miner Documentation - AITBC + +Become a miner on the AITBC network: Stake tokens, provide GPU compute, and earn rewards. + +## Overview + +Miners are essential to the AITBC network, providing both security through staking and compute power for AI workloads. As a miner, you can: + +- Stake AITBC tokens to secure the network +- Provide GPU compute for AI inference and training +- Earn rewards from both staking and compute services +- Participate in network governance + +## Getting Started + +### Prerequisites + +- Minimum 10,000 AITBC tokens for staking +- Modern GPU with 8GB+ VRAM (for compute mining) +- Stable internet connection +- Linux or Windows OS + +### Quick Setup + +```bash +# Download miner binary +wget https://gitea.bubuit.net/oib/aitbc/releases/download/latest/aitbc-miner-linux-amd64.tar.gz +tar -xzf aitbc-miner-linux-amd64.tar.gz + +# Initialize miner +./aitbc-miner init + +# Start mining +./aitbc-miner start +``` + +## Mining Types + +### 1. Staking Only + +Secure the network by staking tokens without providing compute. + +**Requirements:** +- Minimum 10,000 AITBC +- Always-online node + +**Rewards:** +- 15-25% APY +- Based on stake amount +- Distributed daily + +### 2. Compute Mining + +Provide GPU compute for AI workloads in addition to staking. + +**Requirements:** +- 10,000 AITBC stake +- GPU with 8GB+ VRAM +- 50GB+ storage + +**Rewards:** +- Base staking rewards + compute fees +- $0.02 per GPU second +- Bonus for high-performance GPUs + +### 3. Authority Node + +Advanced mining with block production rights. + +**Requirements:** +- 100,000 AITBC stake +- Invitation from core team +- Proven reliability + +**Rewards:** +- Highest APY (30-40%) +- Transaction fees +- Governance rights + +## Hardware Requirements + +### Minimum Requirements + +- **CPU**: 4 cores +- **RAM**: 8GB +- **Storage**: 100GB SSD +- **Network**: 10 Mbps upload +- **GPU**: GTX 1060 / RX 580 or better + +### Recommended Setup + +- **CPU**: 8+ cores +- **RAM**: 16GB+ +- **Storage**: 500GB NVMe SSD +- **Network**: 100 Mbps+ +- **GPU**: RTX 3080 / RTX 4080 or better + +## Installation Guide + +### Linux Installation + +```bash +# Install dependencies +sudo apt update +sudo apt install -y curl wget gnupg2 + +# Download miner +wget https://gitea.bubuit.net/oib/aitbc/releases/download/latest/aitbc-miner-linux-amd64.tar.gz +tar -xzf aitbc-miner-linux-amd64.tar.gz +sudo mv aitbc-miner /usr/local/bin/ + +# Create systemd service +sudo tee /etc/systemd/system/aitbc-miner.service > /dev/null <● Live + +[Launch Exchange →](https://aitbc.bubuit.net/Exchange/) + +## Overview + +The AITBC Trade Exchange is a crypto-only platform that enables users to exchange Bitcoin for AITBC tokens. It features a modern, responsive interface with user authentication, wallet management, and real-time trading capabilities. + +### Key Features + +- Bitcoin wallet integration with QR code payments +- User management with wallet-based authentication +- Real-time payment monitoring and confirmation +- Individual user wallets and balance tracking +- Transaction history and receipt management +- Mobile-responsive design + +## How It Works + +The Trade Exchange provides a simple, secure way to acquire AITBC tokens using Bitcoin. + +#### 1. Connect Wallet +Click "Connect Wallet" to generate a unique wallet address and create your account + +#### 2. Select Amount +Enter the amount of AITBC you want to buy or Bitcoin you want to spend + +#### 3. Make Payment +Scan the QR code or send Bitcoin to the provided address + +#### 4. Receive Tokens +AITBC tokens are credited to your wallet after confirmation + +## User Management + +The exchange uses a wallet-based authentication system that requires no passwords. + +### Authentication Flow + +- Users connect with a wallet address (auto-generated for demo) +- System creates or retrieves user account +- Session token issued for secure API access +- 24-hour automatic session expiry + +### User Features + +- Unique username and user ID +- Personal AITBC wallet with balance tracking +- Complete transaction history +- Secure logout functionality + +## Exchange API + +The exchange provides RESTful APIs for user management and payment processing. + +### User Management Endpoints + +`POST /api/users/login` +Login or register with wallet address + +`GET /api/users/me` +Get current user profile + +`GET /api/users/{id}/balance` +Get user wallet balance + +`POST /api/users/logout` +Logout and invalidate session + +### Exchange Endpoints + +`POST /api/exchange/create-payment` +Create Bitcoin payment request + +`GET /api/exchange/payment-status/{id}` +Check payment confirmation status + +`GET /api/exchange/rates` +Get current exchange rates + +## Security Features + +The exchange implements multiple security measures to protect user funds and data. + +### Authentication Security + +- SHA-256 hashed session tokens +- 24-hour automatic session expiry +- Server-side session validation +- Secure token invalidation on logout + +### Payment Security + +- Unique payment addresses for each transaction +- Real-time blockchain monitoring +- Payment confirmation requirements (1 confirmation) +- Automatic refund for expired payments + +### Privacy + +- No personal data collection +- User data isolation +- GDPR compliant design + +## Configuration + +The exchange can be configured for different environments and requirements. + +### Exchange Settings + +```bash +# Exchange Rate +BTC_TO_AITBC_RATE=100000 + +# Payment Settings +MIN_CONFIRMATIONS=1 +PAYMENT_TIMEOUT=3600 # 1 hour +MIN_PAYMENT=0.0001 # BTC +MAX_PAYMENT=10 # BTC + +# Bitcoin Network +BITCOIN_NETWORK=testnet +BITCOIN_RPC_URL=http://localhost:8332 +BITCOIN_RPC_USER=user +BITCOIN_RPC_PASS=password +``` + +## Getting Started + +Start using the Trade Exchange in just a few simple steps. + +### 1. Access the Exchange + +Visit: [https://aitbc.bubuit.net/Exchange/](https://aitbc.bubuit.net/Exchange/) + +### 2. Connect Your Wallet + +Click the "Connect Wallet" button. A unique wallet address will be generated for you. + +### 3. Get Testnet Bitcoin + +For testing, get free testnet Bitcoin from: +[testnet-faucet.mempool.co](https://testnet-faucet.mempool.co/) + +### 4. Make Your First Purchase + +1. Enter the amount of AITBC you want to buy +2. Scan the QR code with your Bitcoin wallet +3. Wait for confirmation (usually 10-20 minutes on testnet) +4. Receive AITBC tokens in your wallet + +## API Examples + +### Create Payment Request + +```bash +curl -X POST https://aitbc.bubuit.net/api/exchange/create-payment \ + -H "Content-Type: application/json" \ + -H "X-Session-Token: your-session-token" \ + -d '{ + "aitbc_amount": 1000, + "btc_amount": 0.01 + }' +``` + +Response: +```json +{ + "payment_id": "pay_123456", + "btc_address": "tb1qxy2...", + "btc_amount": 0.01, + "qr_code": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", + "expires_at": "2025-01-29T15:50:00Z" +} +``` + +### Check Payment Status + +```bash +curl -X GET https://aitbc.bubuit.net/api/exchange/payment-status/pay_123456 \ + -H "X-Session-Token: your-session-token" +``` + +Response: +```json +{ + "payment_id": "pay_123456", + "status": "confirmed", + "confirmations": 1, + "aitbc_amount": 1000, + "credited_at": "2025-01-29T14:50:00Z" +} +``` + +## Integration Guide + +### Frontend Integration + +```javascript +// Connect wallet +async function connectWallet() { + const response = await fetch('/api/users/login', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ wallet_address: generatedAddress }) + }); + const { user, token } = await response.json(); + localStorage.setItem('sessionToken', token); + return user; +} + +// Create payment +async function createPayment(aitbcAmount) { + const response = await fetch('/api/exchange/create-payment', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-Session-Token': localStorage.getItem('sessionToken') + }, + body: JSON.stringify({ aitbc_amount: aitbcAmount }) + }); + return response.json(); +} +``` + +### Backend Integration + +```python +# Python example using requests +import requests + +class AITBCExchange: + def __init__(self, base_url="https://aitbc.bubuit.net"): + self.base_url = base_url + self.session_token = None + + def login(self, wallet_address): + response = requests.post( + f"{self.base_url}/api/users/login", + json={"wallet_address": wallet_address} + ) + data = response.json() + self.session_token = data["token"] + return data["user"] + + def create_payment(self, aitbc_amount): + headers = {"X-Session-Token": self.session_token} + response = requests.post( + f"{self.base_url}/api/exchange/create-payment", + json={"aitbc_amount": aitbc_amount}, + headers=headers + ) + return response.json() +``` + +## Troubleshooting + +### Common Issues + +1. **Payment not detected** + - Verify the transaction was broadcast to the network + - Check if the payment address is correct + - Wait for at least 1 confirmation + +2. **Session expired** + - Click "Connect Wallet" to create a new session + - Sessions automatically expire after 24 hours + +3. **QR code not working** + - Ensure your Bitcoin wallet supports QR codes + - Manually copy the address if needed + - Check for sufficient wallet balance + +### Support + +- Check transaction on [block explorer](https://mempool.space/testnet) +- Contact support: [aitbc@bubuit.net](mailto:aitbc@bubuit.net) +- Discord: [#exchange-support](https://discord.gg/aitbc) + +## Rate Limits + +To ensure fair usage, the exchange implements rate limiting: + +- 10 payments per hour per user +- 100 API requests per minute per session +- Maximum payment: 10 BTC per transaction + +## Future Updates + +Planned features for the Trade Exchange: + +- Support for additional cryptocurrencies (ETH, USDT) +- Advanced order types (limit orders) +- Trading API for programmatic access +- Mobile app support +- Lightning Network integration + +--- + +**Start trading now at [aitbc.bubuit.net/Exchange/](https://aitbc.bubuit.net/Exchange/)** diff --git a/docs/wallet-documentation.md b/docs/wallet-documentation.md new file mode 100644 index 00000000..14b85e7b --- /dev/null +++ b/docs/wallet-documentation.md @@ -0,0 +1,118 @@ +# AITBC Browser Wallet Documentation + +The most secure way to store, send, and receive AITBC tokens. Connect to the AITBC Trade Exchange with just one click. + +## Why Choose AITBC Wallet? + +### Bank-Grade Security +- Your private keys never leave your device +- Encrypted locally with military-grade security + +### Seamless dApp Integration +- Connect to any AITBC-powered dApp with a single click +- No more copying and pasting addresses + +### Lightning Fast +- Built for performance +- Instant transactions and real-time balance updates + +## Installation + +### Install for Chrome / Edge / Brave + +#### Step 1: Download the Extension +Download the AITBC Wallet extension files to your computer. + +[Download Chrome Extension](/assets/aitbc-wallet.zip) + +#### Step 2: Open Chrome Extensions +Open Chrome and navigate to the extensions page: +``` +chrome://extensions/ +``` + +#### Step 3: Enable Developer Mode +Toggle the "Developer mode" switch in the top right corner. + +#### Step 4: Load Extension +Click "Load unpacked" and select the `aitbc-wallet` folder. + +#### Step 5: Start Using! +Click the AITBC Wallet icon in your toolbar to create or import an account. + +### Install for Firefox + +#### Step 1: Visit Install Page +Click the button below to go to the Firefox installation page. + +[Install Firefox Extension](/firefox-wallet/install.html) + +#### Step 2: Click "Add to Firefox" +On the install page, click the "Add to Firefox" button to install the extension. + +#### Step 3: Start Using! +The AITBC Wallet will appear in your toolbar with an orange icon. Click to create your first account! + +## Using Your AITBC Wallet + +### Create a New Wallet +1. Click the AITBC Wallet icon +2. Select "Create New Account" +3. Securely save your private key +4. Your wallet is ready! + +### Import Existing Wallet +1. Click the AITBC Wallet icon +2. Select "Import Private Key" +3. Enter your private key +4. Access your restored wallet + +### Connect to Exchange +1. Visit [AITBC Exchange](/Exchange/) +2. Toggle to "Real Mode" +3. Click "Connect AITBC Wallet" +4. Approve the connection + +### Send & Receive Tokens +1. Click "Send" to transfer tokens +2. Click "Receive" to get your address +3. All transactions require confirmation +4. View history in the wallet + +## Security Best Practices + +> ⚠️ **Important Security Reminders** + +### Never Share Your Private Key +- Anyone with your private key has full control of your funds +- Treat it like your bank account password + +### Backup Your Private Key +- Write it down and store it in a secure, offline location +- Consider using a fireproof safe or safety deposit box + +### Verify URLs +- Always ensure you're on aitbc.bubuit.net before connecting +- Phishing sites may look identical + +### Use a Password Manager +- Protect your browser with a strong, unique password +- Enable two-factor authentication when available + +### Keep Updated +- Regularly update your browser and the wallet extension +- Security updates are important for protecting your funds + +## Quick Links + +- [Trade Exchange](/Exchange/) +- [Block Explorer](/explorer/) +- [Documentation](/docs/) + +## Support + +Need help? Check our documentation or create an issue on GitHub. + +--- + +© 2025 AITBC. All rights reserved. diff --git a/website/docs/blockchain-node-md.html b/website/docs/blockchain-node-md.html new file mode 100644 index 00000000..0589ecdc --- /dev/null +++ b/website/docs/blockchain-node-md.html @@ -0,0 +1,488 @@ + + + + + + Blockchain Node - AITBC Documentation + + + + +
+ +
+ +
+
+ + + + + + + Back to Components + + + +
+

Blockchain Node

+

PoA/PoS consensus blockchain with REST/WebSocket RPC, real-time gossip layer, and comprehensive observability

+ ● Live +
+ + +
+

Overview

+

The AITBC Blockchain Node is the core infrastructure component that maintains the distributed ledger. It implements a hybrid Proof-of-Authority/Proof-of-Stake consensus mechanism with fast finality and supports high throughput for AI workload transactions.

+ +

Key Features

+
    +
  • Hybrid PoA/PoS consensus with sub-second finality
  • +
  • REST and WebSocket RPC APIs
  • +
  • Real-time gossip protocol for block propagation
  • +
  • Comprehensive observability with Prometheus metrics
  • +
  • SQLModel-based data persistence
  • +
  • Built-in devnet tooling and scripts
  • +
+
+ + +
+

Architecture

+

The blockchain node is built with a modular architecture separating concerns for consensus, storage, networking, and API layers.

+ +
+
+

Consensus Engine

+

Hybrid PoA/PoS with proposer rotation and validator sets

+
+
+

Storage Layer

+

SQLModel with SQLite/PostgreSQL support

+
+
+

Networking

+

WebSocket gossip + REST API

+
+
+

Observability

+

Prometheus metrics + structured logging

+
+
+
+ + +
+

API Reference

+

The blockchain node exposes both REST and WebSocket APIs for interaction.

+ +

REST Endpoints

+
+ GET /rpc/get_head +

Get the latest block header

+
+ +
+ POST /rpc/send_tx +

Submit a new transaction

+
+ +
+ GET /rpc/get_balance/{address} +

Get account balance

+
+ +
+ GET /rpc/get_block/{height} +

Get block by height

+
+ +

WebSocket Subscriptions

+
    +
  • new_blocks - Real-time block notifications
  • +
  • new_transactions - Transaction pool updates
  • +
  • consensus_events - Consensus round updates
  • +
+
+ + +
+

Configuration

+

The node can be configured via environment variables or configuration file.

+ +

Key Settings

+
# Database
+DATABASE_URL=sqlite:///blockchain.db
+
+# Network
+RPC_HOST=0.0.0.0
+RPC_PORT=9080
+WS_PORT=9081
+
+# Consensus
+CONSENSUS_MODE=poa
+VALIDATOR_ADDRESS=0x...
+BLOCK_TIME=1s
+
+# Observability
+METRICS_PORT=9090
+LOG_LEVEL=info
+
+ + +
+

Running a Node

+ +

Development Mode

+
# Initialize devnet
+python -m blockchain.scripts.init_devnet
+
+# Start node
+python -m blockchain.main --config devnet.yaml
+ +

Production Mode

+
# Using Docker
+docker run -d \
+  -v /data/blockchain:/data \
+  -p 9080:9080 \
+  -p 9081:9081 \
+  -p 9090:9090 \
+  aitbc/blockchain-node:latest
+
+ + +
+

Monitoring

+ +

Prometheus Metrics

+

Available at http://localhost:9090/metrics

+ +

Key metrics:

+
    +
  • blockchain_blocks_total - Total blocks produced
  • +
  • blockchain_transactions_total - Total transactions processed
  • +
  • blockchain_consensus_rounds - Consensus rounds completed
  • +
  • blockchain_network_peers - Active peer connections
  • +
+ +

Health Checks

+
# Node status
+curl http://localhost:9080/health
+
+# Sync status
+curl http://localhost:9080/sync_status
+
+ + +
+

Troubleshooting

+ +

Common Issues

+
    +
  1. Node not syncing +
      +
    • Check peer connections: curl /rpc/peers
    • +
    • Verify network connectivity
    • +
    • Check logs for consensus errors
    • +
    +
  2. +
  3. High memory usage +
      +
    • Reduce block_cache_size in config
    • +
    • Enable block pruning
    • +
    +
  4. +
  5. RPC timeouts +
      +
    • Increase rpc_timeout setting
    • +
    • Check system resources
    • +
    +
  6. +
+
+ + +
+

Development

+ +

Building from Source

+
git clone https://github.com/aitbc/blockchain
+cd blockchain
+pip install -e .
+ +

Running Tests

+
# Unit tests
+pytest tests/
+
+# Integration tests
+pytest tests/integration/
+
+ + +
+

Security Considerations

+
    +
  • Validator keys should be kept secure
  • +
  • Use HTTPS in production
  • +
  • Implement rate limiting on RPC endpoints
  • +
  • Regular security updates for dependencies
  • +
+
+
+
+ +
+
+

© 2025 AITBC. All rights reserved.

+
+
+ + diff --git a/website/docs/blockchain-node.html b/website/docs/blockchain-node.html index 228d5308..b87ef334 100644 --- a/website/docs/blockchain-node.html +++ b/website/docs/blockchain-node.html @@ -300,6 +300,11 @@
+
+ 📚 Also available in Markdown: + View this documentation in markdown format for easier contribution and version control. +
+

Overview

The AITBC Blockchain Node is the core infrastructure component that maintains the distributed ledger. It implements a hybrid Proof-of-Authority/Proof-of-Stake consensus mechanism with fast finality and supports high throughput for AI workload transactions.

diff --git a/website/docs/browser-wallet.html b/website/docs/browser-wallet.html index be40f647..884bd72a 100644 --- a/website/docs/browser-wallet.html +++ b/website/docs/browser-wallet.html @@ -106,6 +106,11 @@
+
+ 📚 Also available in Markdown: + View this documentation in markdown format for easier contribution and version control. +
+

Why Choose AITBC Wallet?

diff --git a/website/docs/client-documentation-md.html b/website/docs/client-documentation-md.html new file mode 100644 index 00000000..f45208be --- /dev/null +++ b/website/docs/client-documentation-md.html @@ -0,0 +1,586 @@ + + + + + + Client Documentation - AITBC + + + + +
+ +
+ +
+
+ + + + + + + Back to Documentation + + + +
+

Client Documentation

+

Use AITBC for your AI/ML workloads with privacy and verifiable computation. Ideal for businesses and developers using AI services.

+
+ + +
+

Getting Started

+

Start using AITBC in minutes with our simple client SDK or web interface.

+ +

Quick Start Options

+
    +
  • CLI Wrapper Tool: Unified bash script for job management
  • +
  • Web Interface: No installation required
  • +
  • Python SDK: For AI/ML developers
  • +
  • JavaScript SDK: For web applications
  • +
  • REST API: For any platform
  • +
+ +

CLI Wrapper Tool (Recommended)

+
# Install the CLI wrapper
+curl -O https://gitea.bubuit.net/oib/aitbc/releases/download/latest/aitbc-cli.sh
+chmod +x aitbc-cli.sh
+
+# Check available services
+./aitbc-cli.sh status
+
+# Submit a job
+./aitbc-cli.sh submit "Your prompt here" --model llama3.2
+ +

Web Interface

+

Visit aitbc.bubuit.net/marketplace to access the web interface.

+
+ + +
+

Python SDK

+

Install the Python SDK for easy integration into your applications:

+ +
# Install
+pip install aitbc-client
+
+# Basic usage
+from aitbc import AITBCClient
+
+client = AITBCClient(api_key="your-api-key")
+
+# Submit a job
+job = client.submit_job(
+    type="inference",
+    model="llama3.2",
+    prompt="Explain quantum computing",
+    max_tokens=500
+)
+
+# Wait for completion
+result = client.wait_for_job(job.id)
+print(result.output)
+ +

Advanced Features

+
    +
  • Async/await support
  • +
  • Batch job submission
  • +
  • Streaming responses
  • +
  • Zero-knowledge proof verification
  • +
+
+ + +
+

JavaScript SDK

+

For web applications and Node.js:

+ +
# Install
+npm install @aitbc/client
+
+# Usage
+import { AITBCClient } from '@aitbc/client';
+
+const client = new AITBCClient({
+  apiKey: 'your-api-key',
+  endpoint: 'https://aitbc.bubuit.net/api'
+});
+
+// Submit job
+const job = await client.submit({
+  type: 'inference',
+  model: 'llama3.2',
+  input: {
+    prompt: 'Hello, AITBC!',
+    max_tokens: 100
+  }
+});
+
+// Get result
+const result = await client.getResult(job.id);
+console.log(result.output);
+
+ + +
+

REST API

+

Direct API access for any programming language:

+ +
# Submit a job
+curl -X POST https://aitbc.bubuit.net/api/v1/jobs \
+  -H "Authorization: Bearer YOUR_TOKEN" \
+  -H "Content-Type: application/json" \
+  -d '{
+    "type": "inference",
+    "model": "gpt-4",
+    "input": {
+      "prompt": "Hello, AITBC!",
+      "max_tokens": 100
+    },
+    "privacy": {
+      "zk_proof": true
+    }
+  }'
+
+# Check job status
+curl -X GET https://aitbc.bubuit.net/api/v1/jobs/JOB_ID \
+  -H "Authorization: Bearer YOUR_TOKEN"
+
+ + +
+

Pricing

+

Flexible pricing options for every use case

+ +
+
+

Pay-per-use

+
$0.01/1K tokens
+
    +
  • No minimum commitment
  • +
  • Pay for what you use
  • +
  • All models available
  • +
+
+
+

Professional

+
$99/month
+
    +
  • 10M tokens included
  • +
  • Priority processing
  • +
  • SLA guarantee
  • +
+
+
+

Enterprise

+
Custom
+
    +
  • Unlimited tokens
  • +
  • Dedicated infrastructure
  • +
  • 24/7 support
  • +
+
+
+
+ + +
+

Privacy & Security

+

Your data is protected with enterprise-grade security:

+ +
+
+

Zero-Knowledge Proofs

+

Computation is verified without revealing your data

+
+
+

End-to-End Encryption

+

Your prompts and results are encrypted in transit and at rest

+
+
+

Verifiable Computation

+

Every result includes a cryptographic proof of correct execution

+
+
+

Privacy-Preserving

+

Optional privacy mode keeps your data completely confidential

+
+
+
+ + +
+

Supported Models

+

Access a wide range of state-of-the-art AI models:

+ +

Language Models

+
    +
  • LLaMA 3.2 (8B, 70B)
  • +
  • Mistral (7B, 8x7B)
  • +
  • DeepSeek (67B)
  • +
  • Code Llama (34B)
  • +
  • GPT-4 (via API)
  • +
+ +

Image Models

+
    +
  • Stable Diffusion XL
  • +
  • DALL-E 3 (via API)
  • +
  • Midjourney (via API)
  • +
+ +

Specialized Models

+
    +
  • Embedding models for search
  • +
  • Speech-to-text (Whisper)
  • +
  • Text-to-speech
  • +
  • Translation models
  • +
+
+ + +
+

Best Practices

+ +
+ 💡 Tip: Use batch processing for multiple requests to reduce latency and costs. +
+ +

Performance Optimization

+
    +
  • Use appropriate model sizes for your task
  • +
  • Implement caching for repeated requests
  • +
  • Use streaming for long responses
  • +
  • Monitor token usage to control costs
  • +
  • Consider subscription plans for regular use
  • +
+ +

Security Best Practices

+
    +
  • Keep your API keys secure
  • +
  • Use environment variables for credentials
  • +
  • Implement proper error handling
  • +
  • Validate inputs before submission
  • +
  • Use HTTPS for all API calls
  • +
+
+ + +
+

Support & Resources

+ +

Getting Help

+ + +

Tutorials

+ + +

Examples

+ +
+
+
+ +
+
+

© 2025 AITBC. All rights reserved.

+
+
+ + diff --git a/website/docs/components-md.html b/website/docs/components-md.html new file mode 100644 index 00000000..b67616e1 --- /dev/null +++ b/website/docs/components-md.html @@ -0,0 +1,496 @@ + + + + + + AITBC System Components - Documentation + + + + +
+ +
+ +
+
+ + + + + + + Back to Documentation + + + +
+

AITBC System Components

+

Overview of all components in the AITBC platform, their status, and documentation links.

+
+ + +
+

Core Components

+
+ +
+
+ +
+

Blockchain Node

+

PoA/PoS consensus with REST/WebSocket RPC, real-time gossip layer, and comprehensive observability. Production-ready with devnet tooling.

+
Live
+ + Learn More + +
+ + +
+
+ +
+

Coordinator API

+

FastAPI service for job submission, miner registration, and receipt management. SQLite persistence with comprehensive endpoints.

+
Live
+ + Learn More + +
+ + +
+
+ +
+

Marketplace Web

+

Vite/TypeScript marketplace with offer/bid functionality, stats dashboard, and mock/live data toggle. Production UI ready.

+
Live
+ + Learn More + +
+ + +
+
+ +
+

Explorer Web

+

Full-featured blockchain explorer with blocks, transactions, addresses, and receipts tracking. Responsive design with live data.

+
Live
+ + Learn More + +
+ + +
+
+ +
+

Wallet Daemon

+

Encrypted keystore with Argon2id + XChaCha20-Poly1305, REST/JSON-RPC APIs, and receipt verification capabilities.

+
Live
+ + Learn More + +
+ + +
+
+ +
+

Trade Exchange

+

Bitcoin-to-AITBC exchange with QR payments, user management, and real-time trading. Buy tokens with BTC instantly.

+
Live
+ + Learn More + +
+ + +
+
+ +
+

Pool Hub

+

Miner registry with scoring engine, Redis/PostgreSQL backing, and comprehensive metrics. Live matching API deployed.

+
Live
+ + Learn More + +
+
+
+ + +
+

Architecture Overview

+

The AITBC platform consists of 7 core components working together to provide a complete AI blockchain computing solution:

+ +
+┌─────────────┐ ┌──────────────┐ ┌─────────────┐ +│ Clients │────▶│ Coordinator │────▶│ Blockchain │ +│ │ │ API │ │ Node │ +└─────────────┘ └──────────────┘ └─────────────┘ + │ │ │ + ▼ ▼ ▼ +┌─────────────┐ ┌──────────────┐ ┌─────────────┐ +│ Wallet │ │ Pool Hub │ │ Miners │ +│ Daemon │ │ │ │ │ +└─────────────┘ └──────────────┘ └─────────────┘ +
+ +

Infrastructure Layer

+
    +
  • Blockchain Node - Distributed ledger with PoA/PoS consensus
  • +
  • Coordinator API - Job orchestration and management
  • +
  • Wallet Daemon - Secure wallet management
  • +
+ +

Application Layer

+
    +
  • Marketplace Web - GPU compute marketplace
  • +
  • Trade Exchange - Token trading platform
  • +
  • Explorer Web - Blockchain explorer
  • +
  • Pool Hub - Miner coordination service
  • +
+
+ + +
+

Quick Links

+ +
+ + +
+

Status Legend

+
    +
  • ● Live - Production ready and deployed
  • +
  • ● Beta - In testing, limited availability
  • +
  • ● Development - Under active development
  • +
+
+ + +
+

Deployment Information

+

All components are containerized and can be deployed using Docker Compose:

+
+# Deploy all components
+docker-compose up -d
+
+# Check status
+docker-compose ps
+
+# View logs
+docker-compose logs -f
+
+ + +
+

Support

+

For component-specific issues:

+ +
+
+
+ +
+
+

© 2025 AITBC. All rights reserved.

+
+
+ + diff --git a/website/docs/components.html b/website/docs/components.html index 802cfc90..41504459 100644 --- a/website/docs/components.html +++ b/website/docs/components.html @@ -289,8 +289,13 @@

Explore the 7 core components that make up the AITBC platform

- +
+
+ 📚 Also available in Markdown: + View this documentation in markdown format for easier contribution and version control. +
+
diff --git a/website/docs/coordinator-api.html b/website/docs/coordinator-api.html index 1d86b9a0..979cfb26 100644 --- a/website/docs/coordinator-api.html +++ b/website/docs/coordinator-api.html @@ -300,6 +300,11 @@
+
+ 📚 Also available in Markdown: + View this documentation in markdown format for easier contribution and version control. +
+

Overview

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.

diff --git a/website/docs/docs-clients.html b/website/docs/docs-clients.html index 3b7b2606..0c7d4321 100644 --- a/website/docs/docs-clients.html +++ b/website/docs/docs-clients.html @@ -67,6 +67,11 @@
+
+ 📚 Also available in Markdown: + View this documentation in markdown format for easier contribution and version control. +
+

Getting Started

Start using AITBC in minutes with our simple client SDK or web interface.

@@ -247,7 +252,7 @@ console.log('Computation verified:', verified);

REST API

# Submit a job -curl -X POST https://api.aitbc.io/v1/jobs \ +curl -X POST https://aitbc.bubuit.net/api/v1/jobs \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ @@ -264,7 +269,7 @@ curl -X POST https://api.aitbc.io/v1/jobs \ }' # Check job status -curl -X GET https://api.aitbc.io/v1/jobs/JOB_ID \ +curl -X GET https://aitbc.bubuit.net/api/v1/jobs/JOB_ID \ -H "Authorization: Bearer YOUR_TOKEN"
@@ -381,7 +386,7 @@ curl -X GET https://api.aitbc.io/v1/jobs/JOB_ID \
  • Documentation: Full API reference
  • Community: Join our Discord
  • Email: aitbc@bubuit.net
  • -
  • Status: System status
  • +
  • Status: System status
  • Tutorials

    diff --git a/website/docs/docs-developers.html b/website/docs/docs-developers.html index 9e642b5f..70c504d9 100644 --- a/website/docs/docs-developers.html +++ b/website/docs/docs-developers.html @@ -95,6 +95,11 @@
    +
    + 📚 Also available in Markdown: + View this documentation in markdown format for easier contribution and version control. +
    +

    Getting Started

    Ready to contribute? Here's how to get started with AITBC development.

    diff --git a/website/docs/docs-miners.html b/website/docs/docs-miners.html index aebb8a41..fefee9e2 100644 --- a/website/docs/docs-miners.html +++ b/website/docs/docs-miners.html @@ -58,6 +58,11 @@
    +
    + 📚 Also available in Markdown: + View this documentation in markdown format for easier contribution and version control. +
    +

    Getting Started

    AITBC mining combines Proof of Authority and Proof of Stake, offering multiple ways to participate and earn rewards.

    @@ -81,12 +86,12 @@

    Get the AITBC mining software for your platform

    # Linux/macOS -curl -O https://releases.aitbc.io/aitbc-miner-v1.0.0.tar.gz +curl -O https://gitea.bubuit.net/oib/aitbc/releases/download/v1.0.0/aitbc-miner-v1.0.0.tar.gz tar -xzf aitbc-miner-v1.0.0.tar.gz cd aitbc-miner # Windows -# Download from https://releases.aitbc.io/windows
    +# Download from https://gitea.bubuit.net/oib/aitbc/releases @@ -307,7 +312,7 @@ nano ~/.aitbc/miner.toml
  • Check the logs: ./aitbc-miner logs
  • Visit our Discord community
  • Search issues on Gitea
  • -
  • Email support: miners@aitbc.io
  • +
  • Email support: aitbc@bubuit.net
  • diff --git a/website/docs/full-documentation.html b/website/docs/full-documentation.html index ce12173b..811f5825 100644 --- a/website/docs/full-documentation.html +++ b/website/docs/full-documentation.html @@ -471,6 +471,11 @@
    +
    + 📚 Also available in Markdown: + View this documentation in markdown format for easier contribution and version control. +
    +

    AITBC Full Documentation

    Complete technical documentation for the AI Training & Blockchain Computing platform

    @@ -1011,7 +1016,7 @@ gosec ./...
  • Medium: $1,000 - $10,000
  • Low: $100 - $1,000
  • -

    Report vulnerabilities at: security@aitbc.io

    +

    Report vulnerabilities at: aitbc@bubuit.net

    diff --git a/website/docs/index.html b/website/docs/index.html index c219c77c..5d51526b 100644 --- a/website/docs/index.html +++ b/website/docs/index.html @@ -124,6 +124,10 @@ Full Documentation + + + Markdown Docs + Trade Exchange @@ -136,7 +140,7 @@ Community - + Support @@ -151,6 +155,42 @@
    + +
    +

    📚 Documentation Formats

    +

    Choose your preferred documentation format:

    + +

    + HTML: Original documentation with interactive features | + Web: Clean, fast-loading web format +

    +
    +

    Need Help?

    @@ -159,7 +199,7 @@ Join Discord - + Email Support diff --git a/website/docs/marketplace-web.html b/website/docs/marketplace-web.html index 689c3419..09c62abb 100644 --- a/website/docs/marketplace-web.html +++ b/website/docs/marketplace-web.html @@ -469,6 +469,11 @@ body.light {
    + +
    @@ -558,7 +563,7 @@ body.light { Community - + Support @@ -581,7 +586,7 @@ body.light { Join Discord - + Email Support diff --git a/website/docs/trade-exchange.html b/website/docs/trade-exchange.html index da1cedc8..c872c4b7 100644 --- a/website/docs/trade-exchange.html +++ b/website/docs/trade-exchange.html @@ -326,6 +326,11 @@
    + +

    Overview

    The AITBC Trade Exchange is a crypto-only platform that enables users to exchange Bitcoin for AITBC tokens. It features a modern, responsive interface with user authentication, wallet management, and real-time trading capabilities.