☰ MenuArchitecture

Redpoint Engine — Architecture

1. Shape

One Next.js app + one Postgres (Supabase) + R2 + Stripe. Three surfaces served by the same app:

Tenant frontends (e.g. wakecut.com marketing + order pages) are separate thin apps. They call the Engine API and embed/redirect to engine-hosted flows (upload, review) to avoid rebuilding the hard parts. In-house tenants may also just use engine-hosted pages on their domain.

2. Tenancy model

3. Roles

4. Job state machine (unchanged spine)

NEW → ASSIGNED → IN_PROGRESS → IN_REVIEW → (QC_REJECTED ↩ IN_PROGRESS)
    → CLIENT_REVIEW → (REVISION ↩ IN_PROGRESS, capped) → APPROVED → DELIVERED
any-pre-capture → CANCELLED

Status changes are audit-logged to events by trigger. Allowed transitions enforced in a single server-side transition function (transitionJob()) — never raw updates from UI code.

5. Money flow

  1. Order → Stripe Checkout, manual capture (authorize only). Billing mode per tenant config:
    • one_off: one Checkout per job.
    • retainer: Stripe subscription grants N job entitlements/month (entitlements table); job creation debits one, no per-job checkout.
    • credits: prepaid pack purchase credits entitlements; same debit path as retainer.
    • rush: surcharge line item, flag on job, tighter SLA.
  2. Webhook (verified) creates job NEW with payment_intent_id (or debits entitlement).
  3. Client APPROVED → capture → Stripe Connect transfer of editor share (packages.editor_payout_*) → margin retained.
  4. CANCELLED pre-capture → void authorization.
  5. VAT: record buyer_country + buyer_is_business per job; no tax computation yet.

6. Files

7. Dispatch (launch = managed; pool-ready schema)

Launch behaviour: admin assigns editor + internal deadline manually. Schema already carries what stage 2 (curated pool) needs so it becomes a feature flag, not a migration: editor_profiles (skill tags, max_concurrent_jobs, available bool, vetting_status: applied→test_assigned→approved), editor_tenants eligibility, quality counters (qc_pass/revision/on_time rates) updated by triggers. Auto-match = filter eligible+available+under-cap, rank by quality — Phase 8+, admin override always.

8. Security

9. Non-goals (unchanged from original spec)

No open bidding, no native apps, no custom timestamped review player (Frame.io fills the gap early), no auto-pricing of bespoke edits, no unlimited-subscription billing.