Bundle Auto-Deploy: From Purchase to Live App in Seconds

We've streamlined the bundle experience. Previously, purchasing a bundle created your app records instantly, but the actual deployment required a manual setup process. Now, your bundle is live on Cloudflare Workers the moment checkout completes.

The Old Flow vs The New Flow

Before: purchase → manual worker setup → paste code → configure KV → set up routing → finally live

After: purchase → automatic deployment → live in seconds

How It Works

The deployment engine kicks in the moment Stripe confirms payment:

  1. Stripe webhook fires → we create your subscription, app, and function records
  2. If you selected a provider at checkout → deployment starts immediately in a background goroutine
  3. If no provider was connected → we enter awaiting_provider state and prompt you in the dashboard
  4. When you connect a provider → deployment triggers automatically

The worker script gets generated by combining your bundle's function templates into a single Cloudflare Worker, with URL-based routing for each endpoint.

State Machine

Deployment tracks state on the subscription record:

text
pending → provisioning → deploying → deployed → active
                              ↓
                           failed (with retry: 1min → 5min → 15min)

If deployment fails, we retry up to 3 times with exponential backoff before giving up. You can always manually retry from the dashboard.

Cloudflare Workers Integration

For Cloudflare Workers, the deployment:

  1. Generates a combined worker script from your bundle templates
  2. Creates a dedicated KV namespace for state ({script-name}-state)
  3. Deploys the worker via the Cloudflare API
  4. Enables workers.dev subdomain
  5. Creates a backend record pointing to the live worker URL

Template APIs get adapted automatically:

  • state.set(key, val)env.STATE.put(key, JSON.stringify(val))
  • ai.chat.completions.create()env.AI.run('@cf/meta/llama-3-8b-instruct', ...)

What You See

On checkout, you now select a provider:

text
Deploy to:
○ Cloudflare Workers  [connected ✓]
○ Vercel              [connect]
○ Deno Deploy         [connect]
○ Fly.io              [connect]

After purchase, the dashboard shows deployment status in real-time:

  • Provisioning — creating your app records
  • Deploying — pushing code to your worker
  • Deployed — live at https://{script}.{account}.workers.dev
  • Failed — with error details and a retry button

Idempotent by Design

Duplicate Stripe webhooks (which happen) won't cause double deployments. Before deploying, we check if a backend already exists for that app + provider combination. If it does, we skip and mark it as deployed.

What's Next

We're starting with Cloudflare Workers. Vercel, Deno Deploy, and Fly.io support is on the roadmap using a runtime shim approach that proxies state/AI/email calls back to FunctionFly.