Data layer

D1, R2 & Secrets

The three sites communicate through shared server-side resources. Bind them correctly and keep secrets out of source control.

IridesceuxHVNCommandCloudflare

D1 setup

  1. Create the D1 database.
  2. Open its console/query interface.
  3. Run the full command-app/command-schema.sql.
  4. Verify team_members, content, site override, presentation, advertising, analytics, and operations tables exist.
  5. Bind the database as COMMAND_DB to Command, Iridesceux, and HVN Pages Functions.
  6. Redeploy all projects after adding bindings.

R2 setup

  1. Create a private R2 bucket for Command/HVN approved assets.
  2. Bind it as COMMAND_ASSETS where the code expects it.
  3. Keep originals/private assets private; deliver public-approved content only through controlled media routes.
  4. Do not store master encryption keys in D1 or R2.

Command variables and secrets

NamePurpose
BOOTSTRAP_ADMIN_EMAILFirst founder/Super Admin.
CF_ACCESS_TEAM_DOMAINAccess team/issuer domain used for JWT verification.
CF_ACCESS_AUDAudience tag for the Command Access app.
COMMAND_REQUIRE_ACCESS_JWT=trueRequire cryptographic Access JWT validation in production.
COMMAND_MASTER_KEYEncryption key for the operational secret vault.
BROADCAST_AGENT_TOKENAdditional app-layer token for the trusted OBS agent.
IRIDESC_EUX_GITHUB_*Iridesceux Code Studio integration.
HVN_GITHUB_*HVN Code Studio integration.
Never commit secrets to Git. Put secret values in Cloudflare environment/secrets. If a token is ever exposed in chat, a screenshot, source code, or a public log, revoke/rotate it.

Upload-size reality

Command's broadcast/ad browser uploader intentionally caps a single creative below Cloudflare's common request-body ceiling. This is for station IDs, station bugs, short promos and normal ad creatives—not giant program masters.

Large master files: use a direct/multipart R2 ingest workflow rather than pushing a huge master through a Pages Function form upload. Always test your actual Cloudflare plan and representative media before launch.

Binding test

  1. Bind D1 as COMMAND_DB.
  2. Bind R2 as COMMAND_ASSETS.
  3. Redeploy.
  4. Run /setup-doctor.html.
  5. Upload a disposable station-bug image.
  6. Refresh Command and confirm the inventory record remains.
  7. Preview the asset through the protected media-preview route.