> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chromaflow.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Deployment

> Step-by-step playbook for real-time enterprise deployments—local dev, edge builds, Cloudflare scaling, CI/CD, and zero-downtime recovery.

# Real-Time Enterprise Deployment Playbook

Deploy ChromaFlow like a precision launch: edge-optimized, scalable, and resilient. This guide covers local-to-global workflows, real-time configurations, and enterprise scaling patterns for zero-downtime operations on Cloudflare.

<div class="doc-cards">
  <div class="doc-card">
    <span class="doc-badge">Edge Velocity</span>
    <h3>Global Instant Deploys</h3>
    <p>\<12ms cold starts with Vite + Cloudflare Pages; real-time state migration via Durable Objects.</p>
  </div>

  <div class="doc-card">
    <span class="doc-badge">Secure Scale</span>
    <h3>Multi-Tenant Config</h3>
    <p>Wrangler bindings for isolated namespaces; Auth0/Stripe secrets per environment.</p>
  </div>

  <div class="doc-card">
    <span class="doc-badge">Live Monitoring</span>
    <h3>Streaming Observability</h3>
    <p>WebSocket health checks, webhook alerts, and edge metrics for proactive ops.</p>
  </div>
</div>

## Mission Prerequisites

* **Runtime**: Node.js ≥18.18, pnpm ≥9.4.0 (`package.json`).
* **Cloudflare**: Account with Pages, Workers, Durable Objects enabled; Wrangler CLI (`wrangler login`).
* **Enterprise Services**: Active Auth0 tenant, Supabase project, Stripe account, Perplexity API key.
* **Real-Time Tools**: GitHub for CI/CD; monitoring stack (Datadog/Sentry optional).

## Local Real-Time Development Loop

Stream dev changes instantly:

```bash
pnpm install
pnpm dev
```

* Boots Remix/Vite on port 5173 with Cloudflare dev proxy (`vite.config.ts`).
* Secrets via `.env` or `env/.development`; emulate Durable Objects locally.
* WebSocket workbench for live testing; stream logs to console.

<Note>**Pro Tip**: Use `pnpm dev -- --open` for browser auto-launch; monitor real-time metrics in terminal.</Note>

## Build & Real-Time Preview

Validate production streams:

```bash
pnpm build
pnpm preview
```

* `pnpm build`: Runs `npx remix vite:build`; generates `build/client` (assets) and `worker.js` (Functions).
* `pnpm preview`: Emulates Cloudflare with bindings; test SSE/WebSockets at scale.
* Output: Edge-optimized bundles; real-time compatibility verified.

## Edge Deployment to Cloudflare Pages

Global rollout with zero downtime:

```bash
pnpm run deploy
```

* Builds, then `wrangler pages deploy ./build/client --project-name=chromaflow --branch=main`.
* Auto-binds Durable Objects; streams deployment progress via CLI.
* Verify: \<1min to live; global anycast routing.

### Real-Time Environment Variables

| Variable                   | Description      | Real-Time Role         | Example                    |
| -------------------------- | ---------------- | ---------------------- | -------------------------- |
| `AUTH0_DOMAIN` etc.        | Auth0 config     | Session streaming      | `dev-123.us.auth0.com`     |
| `SESSION_SECRET`           | Remix encryption | Secure SSE             | 64-char key                |
| `SUPABASE_URL/KEY`         | DB connection    | Realtime subscriptions | `https://proj.supabase.co` |
| `STRIPE_*`                 | Billing keys     | Webhook verification   | `sk_live_...`              |
| `PERPLEXITY_API_KEY`       | Search           | Edge augmentation      | `pplx-...`                 |
| `INTERCOM_APP_ID`          | Support          | Live Messenger         | `abc123`                   |
| `DURABLE_OBJECT_NAMESPACE` | State binding    | WebSocket persistence  | `AGENT_STATE`              |

Set via Wrangler secrets: `wrangler secret put SESSION_SECRET`.

### Durable Objects & Real-Time Bindings

Configure stateful real-time:

* `functions/_worker.js` exports `AgentStateManager`.
* In `wrangler.toml`:
  ```
  [[durable_objects.bindings]]
  name = "AGENT_STATE"
  class_name = "AgentStateManager"
  ```
* Reference in Remix: `context.cloudflare.env.AGENT_STATE.get(id)` for streams.
* Scale: Partition by tenant ID; auto-migrate on deploys.

<Note>
  **Multi-Region**: Add `compatibility_flags = ["nodejs_compat"]`; deploy to secondary regions for \<50ms global.
</Note>

## Post-Launch Real-Time Checklist

<Accordion title="Stream Verification">Confirm chat SSE, WebSocket agents, Perplexity augmentation.</Accordion>

<Accordion title="Integration Smoke">
  Live OAuth (GitHub), provisioning (Supabase), sessions (Stripe), boot (Intercom).
</Accordion>

<Accordion title="Performance Audit">Latency \<100ms; concurrent WebSockets >1k tested.</Accordion>

<Accordion title="Security Scan">Tokens rotate; RLS enforces; webhooks verify.</Accordion>

<Accordion title="Observability Hook">Connect Cloudflare Logs to Slack; stream alerts on thresholds.</Accordion>

## Real-Time Rollbacks & Recovery

<Accordion title="Instant Rollback">
  Cloudflare Pages history; `wrangler pages publish --tag=prev` for \<1s revert.
</Accordion>

<Accordion title="State Recovery">Durable Objects snapshot/restore; `scripts/restore-all.sh` for configs/UI.</Accordion>

<Accordion title="Live Drills">Simulate failures; auto-debugger patches; WebSocket notifies team.</Accordion>

<Accordion title="Backup Streams">GitHub Actions for automated snapshots; real-time diff reviews.</Accordion>

## Enterprise CI/CD & Automation

Stream deployments end-to-end:

<Accordion title="Pipeline Setup">GitHub Actions runs `pnpm lint/test/build/deploy` on push.</Accordion>

<Accordion title="Real-Time Gates">Pre-deploy smoke tests; post-deploy health streams.</Accordion>

<Accordion title="Scaling Automation">`scripts/scale-enterprise.sh` adjusts bindings/quota based on load.</Accordion>

<Accordion title="Monitoring Integration">Webhooks to Datadog; real-time dashboards for edge metrics.</Accordion>

**CI/CD Table**:

| Stage   | Real-Time Check   | Tool         | Fail-Safe      |
| ------- | ----------------- | ------------ | -------------- |
| Build   | Bundle Validation | Vite         | Cache Purge    |
| Test    | Streaming E2E     | WebContainer | Auto-Retry     |
| Deploy  | Edge Rollout      | Wrangler     | Canary Release |
| Monitor | Live Metrics      | Cloudflare   | Alert Streams  |

## Configuration Metadata

<ResponseField name="envVars" type="object" required>
  Define real-time environment variables for secure, scalable deployments.
</ResponseField>

<ResponseField name="bindings" type="array">
  Configure Durable Objects for stateful real-time features.
</ResponseField>

<ResponseField name="secrets" type="string">
  Manage encrypted secrets via Wrangler for production security.
</ResponseField>

ChromaFlow deployments: Real-time, resilient, enterprise-scalable. For custom pipelines, engage [ops@chromaflow.ai](mailto:ops@chromaflow.ai).
