Three independent inbound flows land in the growth tables. Knowing which function owns each hop is most of growth support.

Flow 1 — website lead

The marketing site’s contact form calls the submit_website_lead RPC (anon-callable, defended by a honeypot field and a per-email rate limit) → row in codex.website_leads.

Flow 2 — demo-call booking (Cal.com)

cal-webhook receives BOOKING_CREATED only (other Cal.com triggers are noise, not lead signals) and inserts directly into website_leads with interest='design_partner' and source = the Cal.com event-type slug.
  • Auth is Cal.com’s own HMAC-SHA256 over the raw body (header x-cal-signature-256) — not Svix. Secret: CAL_WEBHOOK_SECRET.
  • It reads organisation, role, team_size from custom booking questions matched by identifier — the Cal.com event type’s questions must be named exactly organisation, role, team_size. Unanswered questions become NULL and never fail the insert.
  • It bypasses the RPC’s honeypot/rate-limit on purpose: those defenses exist for the anon-callable surface; this is a signature-verified server-to-server source.

Flow 3 — the email nurture pipeline

Design facts that answer most questions:
  • clerk-to-resend is a second, separate Clerk webhook endpoint with its own signing secret (CLERK_TO_RESEND_SIGNING_SECRET). Deliberate isolation: a Resend outage must never retry-storm the identity-sync webhook (clerk-webhook), which is load-bearing for RLS and entitlements.
  • clerk-to-resend never writes codex.* — read-only Supabase access, only to resolve domain-owner emails for org-level billing events.
  • Sequencing lives entirely in Resend Automations (built in the Resend dashboard, not in this repo). The first event resend-webhook hears about a send is usually the first it has ever heard of it, hence lazy upserts throughout.
  • email_events has no unique constraint and no dedup by design — Resend retries and multiple opens/clicks are legitimate.

Testing the pipeline safely

pnpm test:emails (script scripts/test-email-events.ts) has two modes:
The script’s event fixtures mirror exactly what the real callers send — a payload drift in either place makes the test fail rather than silently diverge.

Resend environment as-built

Full inventory of every template, automation, custom event, segment and webhook in the live Resend account — including automation step graphs and four open gaps.