1
12 Comparative Decisions
First-pass vs red-team research. Each decision has kill criteria for when to revisit.
D1
Agent Orchestration
Agent SDK alone
Mastra rejected. 40+ LLM providers wasted -- we're Claude-only. Subagent API handles parallel gen.
D2
Error Recovery
Custom + Eval Inngest P5
Pipeline is 7 sequential stages, not a complex DAG. .pipeline-state.json sufficient. Inngest for Phase 5 ping/post.
D3
Deployment
Stay Coolify
Dokploy saves 850MB but migration risk > benefit. 4 services already configured. Upgrade droplet if needed.
D4
Video Rendering
Rendervid + FFmpeg
Remotion dropped. Rendervid is MCP-native, JSON templates, FREE. FFmpeg for transcoding. No React.
D5
Data Tables
SVAR (leads) + shadcn (rest)
SVAR DataGrid for 443K+ lead rows (virtual scrolling). shadcn Data Table for everything else. Two components justified.
D6
Charts
LayerChart + ECharts
LayerChart for 90% of charts (shadcn-native). ECharts only for 3 Sankey/funnel instances. Unovis rejected.
D7
ORM
Drizzle + Kysely
Drizzle for schema/CRUD. Kysely for analytics (CTEs, window functions). Official bridge shares connection pool.
D8
Workflow Automation
n8n in Phase 3
Skip for P1-2. Add when email drips + social automation become real needs. SvelteKit cron sufficient until then.
D9
Analytics / A/B
GrowthBook only
PostHog overkill for 1-5 users. GrowthBook = Bayesian A/B testing for content site. CF Analytics for traffic.
D10
Email
Listmonk in Phase 3
Tool → email → convert is highest-ROI missing funnel. Self-hosted, Go + Postgres, $0 cost. MJML templates.
D11
Auth
Simple session gate
Env var credentials + bcrypt + httpOnly cookie. 1-3 users. Migrate to Lucia when team > 5 or needs RBAC.
D12
Video Production
Skip OpenMontage
52 tools, 12 pipelines -- massive overkill. Our workflow: select clips → overlay CTA → burn captions → export.
Everything here is final. No additions without kill criteria being met on an existing decision.
SvelteKit 2
Framework + SSR
Svelte 5 Runes
shadcn-svelte
Component Library
Tailwind-native
Tailwind CSS 4
Styling
Dark mode
Drizzle + Kysely
ORM + Analytics
Official bridge
PostgreSQL 17
Database
Separate from Directus
Agent SDK
Pipeline Execution
Claude, streaming
Superforms + Zod
Forms
Brief editor
LayerChart
Charts (90%)
D3 + shadcn
ECharts
Sankey/Funnel (10%)
3 chart instances
SVAR DataGrid
Lead Tables
Virtual scrolling
Rendervid
Video Rendering
MCP + JSON templates
Sharp
Image Processing
Resize, composite
Cloudflare R2
Asset Storage
Zero egress
GrowthBook
A/B Testing
Self-hosted, Phase 3
Listmonk
Email
Self-hosted, Phase 3
n8n
Automation
Social + email, Phase 3
3
7-Stage AI Pipeline -- Model Routing
Each stage fires via Agent SDK query(). Opus for creative work, Sonnet for structured/scoring tasks. ~$2.50-$5.00 per full run.
Stage 1
Brief Validator
Sonnet
Parse + enrich
→
Stage 2
Strategy Engine
Opus
Angle generation
→
⏸
User Selects Angles
Human-in-the-loop
→
Stage 3
Copy Factory
Opus
Full matrix gen
→
3B
Copy Review
Sonnet
6-dim QA scoring
→
⏸
User Reviews Copy
PASS / FLAG / FAIL
→
Stage 4
Creative Dir.
Sonnet
Prompt gen
→
Stage 5
Architect
Sonnet
Budget math
→
Stage 7
Landing Page
Opus
HTML gen
→
Stage 6
Export
Sonnet
XLSX + CSV
Per Pipeline Run
~$3-5
Opus for creative (Stages 2, 3, 7)
Sonnet for structured (1, 3B, 4, 5, 6)
Monthly (4 campaigns)
~$12-20
Plus ~$5-10 for retros, research,
and iterative stage re-runs
vs Revenue Impact
250x+
$20/mo AI cost vs $500/day ad spend
optimization = massive leverage
4
6 UI Modules -- What the Operator Sees
SvelteKit routes. Dark mode. Sidebar nav. Command palette. Internal tool for 1-5 users.
Dashboard
/dashboard
Command center. KPI tiles (spend, CPL, conversions, agent costs). Active campaigns with status. Creative fatigue alerts. Platform health summary. Weekly intelligence digest.
LayerChart cards + real-time data via server load
Campaign Workflow
/campaigns/[id]/*
Brief editor (Superforms multi-step) → Strategy browser (angle cards, approve/reject) → Copy workspace (variant table, QA scores, 6 dimensions) → Creative gallery (grid, generation controls) → Structure viewer → Landing page builder → Export center (XLSX, CSV, ZIP).
10 sub-routes per campaign -- SSE streaming for pipeline execution
Lead Intelligence
/leads
SVAR DataGrid with 443K+ leads. Server-side filtering. Visual segment builder. Geographic choropleth map (svelte-maplibre-gl). Metabase embedded at /analytics for deep analysis.
SVAR DataGrid (virtual scroll) + Kysely analytics queries
Content Manager
/content
Article list from Directus. Tool configuration. Content site rebuild trigger. Article performance metrics. One-click publish workflow.
Directus API integration + content site build trigger
Brand Hub
/brand (Phase 3)
Social profiles across 7 platforms. Content calendar. Post composer with per-platform previews. Queue management. Engagement metrics. Connected via n8n workflows.
n8n → Facebook/X/LinkedIn/Pinterest APIs
Platform Health
/platform-health (Phase 3)
Per-platform trust indicators. Meta HiVA estimate. Google optimization score. Account warm-up progress. Weekly intelligence digest. Competitive intel feed. Automated alerts.
Cron → Firecrawl policy monitoring + API metric pulls
5
Database Schema -- 11 Tables
Separate Postgres from Directus. Drizzle manages schema + migrations. Kysely for analytics via official bridge.
verticals
id uuid PK
name text UNIQUE
slug text UNIQUE
domain text
status text
config_path text
campaigns
id uuid PK
vertical_id → verticals
name, slug, directory
status, current_stage
daily_budget numeric
platforms jsonb
brief_yaml, brief_json
agent_sessions
id uuid PK
campaign_id → campaigns
session_id text
stage int, status text
tokens (in/out/cache)
cost_usd numeric
model text
pipeline_stages
id uuid PK
campaign_id → campaigns
stage int, status text
session_id → agent_sessions
output_files jsonb
validation jsonb
UNIQUE(campaign, stage)
approvals
id uuid PK
campaign_id → campaigns
stage int (2 or 3)
item_type, item_id
status (pending/approved/rejected)
score 0-60, review_data
ad_metrics
id uuid PK
campaign_id → campaigns
platform, date
ad_set_id, ad_id
angle_id → strategy.json
impressions, clicks, conversions
spend, ctr, cpc, cpl, roas
creative_assets
id uuid PK
campaign_id → campaigns
type (image/video/ugc)
r2_key, r2_url
dimensions jsonb
generation jsonb
angle_ids text[]
performance jsonb
winners_vault
id uuid PK
vertical_id → verticals
angle_id, angle_name
status (winner/loser/fatigued)
metrics jsonb
winning_copy jsonb
fatigue_date date
buyers (Phase 5)
id uuid PK
vertical_id → verticals
name, endpoint_url
ping_url, auth jsonb
filters jsonb
bid_floor, bid_ceiling
daily_cap, monthly_cap
lead_transactions (P5)
id uuid PK
lead_id text
buyer_id → buyers
stage (ping/post/accepted)
bid_amount, revenue
margin, response_ms
attributes jsonb (no PII)
scheduled_tasks
id uuid PK
name, type text
cron_expr text
config jsonb
status text
last_run, next_run
last_result jsonb
gold = primary key
pink = foreign key
teal = indexed lookup
Full SvelteKit route tree. Server-side auth guard on every route. API routes for pipeline execution + data.
src/routes/
├── login/ -- simple session gate login
├── dashboard/ -- KPIs, active campaigns, alerts, agent costs
├── campaigns/
│ ├── new/ -- multi-step brief editor (Superforms + Zod)
│ └── [id]/
│ ├── brief/ │ strategy/ │ copy/ │ creative/
│ ├── structure/ │ landing-page/ │ export/
│ ├── performance/ -- live ad metrics (Phase 4)
│ └── retro/ -- campaign retrospective
├── leads/ -- SVAR DataGrid + segments/ + maps/
├── content/ -- articles/ + tools/ (Directus-connected)
├── creative-library/ -- cross-campaign asset library
├── analytics/ -- Metabase embed + costs/
├── brand/ -- social profiles, calendar, queue (Phase 3)
├── platform-health/ -- trust tiers, warm-up, intel (Phase 3)
├── settings/ -- verticals/ + platforms/ + scheduling/
└── api/
├── pipeline/ (execute, status, approve)
├── metrics/ (pull, summary)
├── creative/ (generate, upload)
├── leads/ (query, export)
├── content/ (build)
└── auth/ (login, logout)