Skip to main content
Convex provides real-time run state, ordered step tracking, asset storage, and execution logs for all live Zap runs. Every stage of a pipeline — from the initial POST /api/zaps/run through provider polling to final asset delivery — is recorded in Convex and updated idempotently. Upstash Redis works alongside Convex to manage polling queues and enforce idempotency across retries.
Mock CLI runs (ZAP_PROVIDER=mock) do not require a Convex deployment. Only web live runs — where a real provider job is submitted and polled — need the full Convex + Upstash stack.

Table Schema

The Convex schema (convex/schema.ts) defines six tables:

zaps

Installed and discoverable recipe metadata. Each record represents a Zap definition that has been published or saved as a draft. Indexes: by_slug, by_status

runs

Run status, creator input summary, budget tracking, and provider mode for each execution. Indexes: by_runId, by_status, by_zap

steps

Ordered pipeline step state for each run. One record per step per run. Indexes: by_run, by_step, by_status

assets

Generated outputs produced during a run: images, video clips, audio files, and stitched results. Indexes: by_run, by_step

feedback

Creator ratings, RLHF votes, and VLM judge scores used as eval signals. Indexes: by_run, by_step

cronLogs

Poller and drain execution logs. Written after each scheduled or triggered drain cycle. Indexes: by_job, by_startTime, by_status

Runtime Flow

Each live run follows this sequence through the stack:
  1. The API route validates the Zap.md recipe and resolves creator secrets from Supabase
  2. A runs record and one steps record per pipeline stage are written to Convex
  3. The provider job is submitted; the returned providerRequestId is stored on the step
  4. An Upstash job is enqueued with the step’s idempotency key (idemKey)
  5. The drain endpoint (/api/providers/poll/drain) is called by Upstash on a schedule, polling the provider for status
  6. Results are written back to steps and assets in Convex; the runs record is updated to reflect the final status

Configuration

Required Environment Variables

Upstash Integration

Convex and Upstash Redis work together to provide idempotent polling queues. Configure Upstash in both your Vercel environment and any Convex actions that enqueue jobs:

Poll Drain Endpoint

The drain endpoint is the bridge between Upstash and Convex. Set these in Vercel: Set ZAP_POLL_DRAIN_SECRET in both Vercel (where the endpoint runs) and in the Convex environment (or Upstash job config) that enqueues drain calls.

Local Development Setup

After cloning and installing dependencies, regenerate the Convex client types and confirm your deployment target:
convex:codegen must be re-run whenever convex/schema.ts changes to keep the typed client in sync with the deployed schema.