Hoox Docs

🛠️ Infrastructure Management

Hoox is fully serverless, using Cloudflare’s distributed services as its compute and storage engine. Managing these resources—such as provisioning D1 databases, registering KV config buckets, setting up S3-compatible R2 storage, and mounting asynchronous Queues—is done directly via the hoox infra command group.

This guide is your operations manual for provisioning, inspecting, and managing Hoox edge infrastructure.


⚡ 1. One-Click Quick Provisioning

When setting up your trading workspace for the first time, you do not need to manually configure resources in Cloudflare’s dashboard. The Hoox CLI automatically parses your enabled workers’ configurations and spins up the entire infrastructure stack in one command:

# Auto-provision all required KV, D1, R2, Vectorize, and Queue resources
hoox infra provision

This command performs a dependency audit and calls Cloudflare’s APIs to provision:

  1. D1 SQLite Database (hoox-db).
  2. CONFIG_KV Namespace bucket.
  3. trade-execution messaging Queue.
  4. trade-reports and system-logs R2 object storage buckets.
  5. rag-index Vectorize vector search database.

🗄️ 2. D1 Database Administration

D1 databases store your critical transactional data (ledger, positions, balance history).

# A. List all active D1 databases in your Cloudflare account
hoox infra d1 list

# B. Create a new custom database instance
hoox infra d1 create my-custom-db

# C. Delete a database instance (destructive)
hoox infra d1 delete my-custom-db

Note: Once a D1 database is created, the CLI will output its unique database_id (a 36-character UUID). You must ensure this ID is bound in your worker’s wrangler.jsonc file so the worker V8 isolate can establish a connection at runtime.


🔑 3. KV Configuration Namespace Management

KV stores are used to manage fast-path configurations, global parameters, and the kill switch.

# A. List all KV namespaces in your account
hoox infra kv list

# B. Create a new KV namespace (e.g. for staging or production)
hoox infra kv create CONFIG_KV

# C. Apply the default 16-key configuration manifest to your active namespace
hoox config kv apply-manifest

📨 4. Asynchronous Queues Setup

Queues guarantee order delivery during periods of extreme exchange rate limits or network congestion.

# A. List all active Cloudflare Queues
hoox infra queues list

# B. Create the trade execution queue
hoox infra queues create trade-execution

Queue Parameters & Throttling

During provisioning, Hoox configures the queue with:

  • Retry Backoff: 30 seconds initial delay, scaling exponentially up to 15 minutes.
  • Message Retention: 4 days (ensuring messages are preserved even during prolonged exchange maintenance events).

📦 5. R2 Object Storage Administration

R2 is an S3-compatible, zero-egress fee object storage service used to offload heavy JSON payloads and PDF portfolio reports.

# A. List all R2 buckets
hoox infra r2 list

# B. Create the trade-reports bucket
hoox infra r2 create trade-reports

🧠 6. Vectorize RAG Index Management

Vectorize indexes house high-dimensional vector embeddings that power semantic search and Telegram AI bot memory.

# A. List all Vectorize indexes
hoox infra vectorize list

# B. Create a vector index with specific dimensions (e.g. 1536 for OpenAI embeddings)
hoox infra vectorize create rag-index --dimensions 1536 --metric cosine

Warning: Destroying resources via hoox infra <service> delete is highly destructive and irreversible. Deleting a D1 database instantly wipes your trading records; deleting a KV bucket drops all configurations and triggers immediate gateway errors. Always backup ledgers before running deletions!

🔗 Next Steps