Version: 2.0.0
Last Updated: 2026-05-12
Classification: Internal Operations Manual
Audience: DevOps Engineers, Senior TypeScript Developers, System Administrators
Table of Contents
- System Overview
- Pre-Flight Requirements
- Complete Environment Matrix
- Development Setup
- Production Setup
- Infrastructure Provisioning
- Worker Deployment Sequence
- Dashboard Setup & Deployment
- Secret Management Reference
- Validation & Health Checks
- Repair & Recovery Procedures
- Operational Runbook
- Complete File Inventory
- Troubleshooting Matrix
1. System Overview
1.1 Architecture
Hoox is an edge-deployed cryptocurrency trading system built on Cloudflare Workers. It consists of:1.2 Communication Flow
1.3 Infrastructure Components
2. Pre-Flight Requirements
2.1 Required Accounts
2.2 Required Tools
2.3 Required Cloudflare Permissions
Your Cloudflare API Token needs these permissions:2.4 Required Repository Access
You need access to clone with submodules:3. Complete Environment Matrix
3.1 Secret Inventory
3.2 Environment Variables by File
.env.local (Project Root)
workers/dashboard/.env.local (Dashboard Local Dev)
workers/dashboard/.dev.vars (Wrangler Dev Mode)
wrangler.jsonc (Central Configuration)
3.3 KV Configuration Keys
These keys must be set inCONFIG_KV namespace:
4. Development Setup
4.1 Step 1: Clone Repository
4.2 Step 2: Verify Submodules
4.3 Step 3: Install Dependencies
4.4 Step 4: Configure Local Environment
4.5 Step 5: Authenticate Wrangler
4.6 Step 6: Create Infrastructure (Local)
For local development, some infrastructure is optional. You need: Required:- D1 database (for trade data)
- KV namespace (for config)
- R2 buckets
- Queues
- Vectorize
- Analytics Engine
4.7 Step 7: Apply Database Schema
4.8 Step 8: Start Development
4.9 Step 9: Dashboard Local Dev
http://localhost:3000.
5. Production Setup
5.1 Phase 1: Account & Tooling
- Create Cloudflare account
- Generate API Token with required permissions (see Section 2.3)
- Install Bun, Wrangler CLI
- Authenticate:
wrangler login
5.2 Phase 2: Repository Setup
5.3 Phase 3: Infrastructure Provisioning
See Section 6 for detailed commands.5.4 Phase 4: Configuration
5.5 Phase 5: Secret Deployment
5.6 Phase 6: Database Setup
5.7 Phase 7: KV Configuration
5.8 Phase 8: Worker Deployment
See Section 7 for the exact sequence.5.9 Phase 9: Dashboard Deployment
5.10 Phase 10: Verification
See Section 10 for validation procedures.6. Infrastructure Provisioning
6.1 D1 Database
trade_signals— Incoming signal trackertrades— Executed trades logpositions— Active & closed positionsbalances— Exchange balance snapshotssystem_logs— System observability logs
6.2 KV Namespaces
6.3 R2 Buckets
6.4 Queue
6.5 Vectorize Index
6.6 Analytics Engine
6.7 Durable Objects Migration
Thehoox worker requires a Durable Object migration:
7. Worker Deployment Sequence
7.1 Deployment Order
7.2 Deployment Commands
7.3 Post-Deployment: Telegram Webhook
7.4 Post-Deployment: Update Internal URLs
8. Dashboard Setup & Deployment
8.1 Configuration Files
8.2 Wrangler Configuration
8.3 Local Development
8.4 Production Build & Deploy
8.5 Dashboard Environment Variables
9. Secret Management Reference
9.1 Setting Secrets via CLI
9.2 Local Development Secrets
For local development withwrangler dev, create .dev.vars in each worker directory:
9.3 Secret Security Best Practices
- Never commit secrets — Use
.gitignorefor.env.local,.dev.vars,.keys/ - Use
wrangler secret put— Never pass secrets as CLI arguments - Rotate regularly — Exchange API keys every 90 days
- Use least privilege — Create exchange API keys with minimal permissions
- Enable IP restrictions — Restrict exchange API keys to Cloudflare IP ranges
- Monitor usage — Review analytics-worker logs for unusual patterns
10. Validation & Health Checks
10.1 Automated Validation Commands
10.2 Manual Health Checks
10.2.1 Gateway Health
10.2.2 Trade Worker Health
10.2.3 Agent Worker Health
10.2.4 D1 Worker Health
10.2.5 Telegram Worker Health
10.2.6 Analytics Worker Health
10.2.7 Dashboard Health
10.3 Database Validation
10.4 KV Validation
10.5 Complete System Validation Checklist
- All workers deployed and returning HTTP 200 on
/health - D1 database has all required tables
- KV namespace has required configuration keys
- Secrets are set for all enabled workers
- Service bindings resolve correctly (no 502/503 errors)
- Queue is configured and consumer is registered
- Telegram webhook is set and responding
- Dashboard accessible and authenticated
- Analytics Engine receiving data points
- Cron triggers scheduled (agent-worker: every 5min, email-worker: every 5min)
11. Repair & Recovery Procedures
11.1 Complete System Repair Checklist
11.2 Individual Worker Repair
11.3 Database Repair
11.4 Secret Repair
11.5 KV Configuration Repair
11.6 Dashboard Repair
11.7 Complete Rebuild from Scratch
12. Operational Runbook
12.1 Daily Operations
12.2 Kill Switch Operations
12.3 Updating Workers
12.4 Rotating Secrets
12.5 Monitoring
12.6 Backup Procedures
13. Complete File Inventory
13.1 Required Configuration Files
13.2 Worker Configuration Files
13.3 Dashboard Files
13.4 Package Files
13.5 Script Files
13.6 Documentation Files
14. Troubleshooting Matrix
Appendix A: Quick Reference Commands
Appendix B: Directory Structure
Document Version: 1.0.0
Last Updated: 2026-05-05
Maintainer: Hoox Development Team