Skip to main content
Version: 2.0.0
Last Updated: 2026-05-12
Classification: Internal Operations Manual
Audience: DevOps Engineers, Senior TypeScript Developers, System Administrators

Table of Contents

  1. System Overview
  2. Pre-Flight Requirements
  3. Complete Environment Matrix
  4. Development Setup
  5. Production Setup
  6. Infrastructure Provisioning
  7. Worker Deployment Sequence
  8. Dashboard Setup & Deployment
  9. Secret Management Reference
  10. Validation & Health Checks
  11. Repair & Recovery Procedures
  12. Operational Runbook
  13. Complete File Inventory
  14. 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

All production secrets must be set via wrangler secret put or hoox secrets update-cf. Never commit secrets to version control.

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 in CONFIG_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)
Optional for local dev:
  • 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

The dashboard runs at http://localhost:3000.

5. Production Setup

5.1 Phase 1: Account & Tooling

  1. Create Cloudflare account
  2. Generate API Token with required permissions (see Section 2.3)
  3. Install Bun, Wrangler CLI
  4. 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

Schema Tables:
  • trade_signals — Incoming signal tracker
  • trades — Executed trades log
  • positions — Active & closed positions
  • balances — Exchange balance snapshots
  • system_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

The hoox worker requires a Durable Object migration:
This is automatically applied on first deploy.

7. Worker Deployment Sequence

Deploy order matters due to service bindings. A worker must be deployed before another worker can bind to it.

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 with wrangler dev, create .dev.vars in each worker directory:

9.3 Secret Security Best Practices

  1. Never commit secrets — Use .gitignore for .env.local, .dev.vars, .keys/
  2. Use wrangler secret put — Never pass secrets as CLI arguments
  3. Rotate regularly — Exchange API keys every 90 days
  4. Use least privilege — Create exchange API keys with minimal permissions
  5. Enable IP restrictions — Restrict exchange API keys to Cloudflare IP ranges
  6. 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
Last modified on June 21, 2026