✅ WHAT SHIPPED
Phase 1B scaffold Done
SvelteKit 2 + Tailwind 4 + shadcn-svelte; PostgreSQL + Drizzle migrations; Agent Executor + SSE streaming + cost tracker + session manager; pipeline orchestrator; brief editor (7-step form → YAML); pipeline execution UI; approval panels; 3 pipeline API routes.
❌ WHAT DIDN'T
Agent executor + Phase 2B ~80% rebuild needed
Per 2026-04-29-project-standing-audit.md: agent executor issues bare messages.stream with no tool harness, no SKILL invocation, no filesystem access. Phase 2B detail routes (strategy / copy / creative / structure / export / landing-page) are 0L. Coolify production deploy pending.
🎯 OPERATOR FRAMING
Ship MVP via brain CLI Active path
UI rebuild = post-revenue project. The 12 architecture decisions, locked tech stack, 7-stage pipeline economics ($2.50–$5/run), database schema, 9 modules, 25+ integrations, phase roadmap below all remain target-state. Decision filter: does this serve $35 CPL MVP, or future-quarter expansion?
🔧 Recommended next 3 sessions per audit: (1) wire agent executor to actually invoke SKILLs (Agent SDK + tool-use harness OR shell-out to claude --skill); (2) build /campaigns/[id]/{brief,strategy,copy,creative,structure,export,landing-page} detail routes; (3) mount campaign-forge repo into production container + fix CAMPAIGN_FORGE_PATH. Both target-state and post-revenue framings are valid — ship MVP first.
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)
7
System Architecture -- 3-Tier Deployment
Cloudflare edge handles public traffic. DigitalOcean runs the ops platform. External APIs provide AI + ad platform connectivity.
Cloudflare Edge (Public-Facing)
Pages (content sites)
R2 (asset storage)
Zaraz (server-side tracking)
Workers (CAPI relay)
DNS + CDN
Web Analytics (free)
↓
DigitalOcean Droplet (8GB/4vCPU via Coolify) — $56/mo
CampaignForge Platform (SvelteKit)
PostgreSQL 17 (platform DB)
Directus (CMS + ops DB)
Metabase (BI dashboards)
Plane (project mgmt)
Listmonk (Phase 3)
GrowthBook (Phase 3)
n8n (Phase 3)
↓
External Services (AI + Ad Platforms + Data)
Anthropic Agent SDK
fal.ai (image + video gen)
ElevenLabs (TTS)
Meta Marketing API
Google Ads API
Everflow (attribution)
Firecrawl (scraping)
8
9 Module Specifications
Each module is a self-contained area of the platform. Click to expand full spec.
Agent Executor
/api/pipeline/execute
• Wraps Agent SDK query() with SSE streaming to frontend
• Model routing: Opus for creative (Stages 2, 3, 7), Sonnet for structured (1, 3B, 4, 5, 6)
• Token counting → agent_costs table
• Session persistence + resume capability
• Per-session cost cap ($10 hard limit)
• Stage-specific allowed tools + settings sources
@anthropic-ai/claude-agent-sdk + SSE
Pipeline Orchestrator
/api/pipeline/status
• Stage sequencing: 1 → 2 → pause → 3 → 3B → pause → 4 → 5 → 7 → 6
• Calls Python validation script after each stage (exit 0 = proceed)
• pipeline_stages table tracks per-campaign, per-stage status
• Approval flow integration (Stage 2 angles, Stage 3B copy)
• Retry logic with idempotent stage re-runs
Pipeline state + validate-stage-output.py
Brief Editor
/campaigns/new
• Superforms + Zod multi-step form
• Partner, offer, audience, platforms, budget, compliance fields
• Vertical config defaults pre-fill most fields
• Outputs brief.yaml for pipeline Stage 1
• 10-15 minute operator time per brief
Superforms + Zod → YAML
Strategy Browser
/campaigns/[id]/strategy
• Angle cards with filtering by type (vault/market/original)
• Approve/reject flow with notes
• Vault winners tagged blue, market angles yellow, original angles red
• Minimum 3-5 angles approved before Stage 3
• approvals table persistence
Angle cards + approval flow
Copy Workspace
/campaigns/[id]/copy
• Variant table with QA scores (0-60, 6 dimensions)
• Compliance (HARD GATE), Hook Strength, Platform Fit, Specificity, Angle Consistency, CTA Strength
• PASS (≥45) / FLAGGED (30-44) / FAIL (compliance) verdicts
• Side-by-side comparison + character count validation
• Copy-review auto-triggers after Stage 3
shadcn Data Table + QA scoring
Creative Gallery
/campaigns/[id]/creative
• Grid view of all creative assets per campaign
• Generation controls: Rendervid (video), fal.ai (image), Sharp (composite)
• Dry-run toggle (preview generation plan without spending API credits)
• R2 upload integration for CDN-served assets
• Per-platform dimension preview (9:16, 1:1, 16:9)
Rendervid MCP + fal.ai MCP + R2
Lead Intelligence
/leads
• SVAR DataGrid for 443K+ leads with virtual scrolling
• Server-side filtering via Kysely queries
• Visual segment builder (filter → name → save → export for LLAs)
• Geographic choropleth map (svelte-maplibre-gl)
• Metabase embedded at /analytics for deep analysis
SVAR DataGrid + Kysely + MapLibre
Content Manager
/content
• Article list from Directus (Phase 2+)
• Tool configuration and data refresh UI
• Content site rebuild trigger (one-click deploy)
• Article performance metrics (Cloudflare Analytics)
• Draft → Review → Published workflow
Directus API + Astro build trigger
Platform Health (Phase 3)
/platform-health
• Per-platform trust indicators: Meta HiVA estimate, Google optimization score, TikTok verification tier, Bing partner status
• Account warm-up progress tracking (prep → engage → soft → full → scale)
• Weekly intelligence digest from Firecrawl policy monitoring
• Competitive intel feed (Meta Ad Library + Google Transparency Center)
• Automated health checks: daily cron pulls account health scores, disapproval rates, frequency alerts
• Brand social health: follower growth, posting cadence compliance, engagement metrics
Firecrawl cron + Directus collections + Metabase dashboards
9
Integration Map -- 25+ Services
Every external service, library, and API the platform connects to. MCP = Model Context Protocol (agent-accessible).
| Integration | Type | What It Connects | Phase |
| Anthropic Agent SDK | npm | Pipeline execution — 7-stage campaign generation | 1 |
| fal.ai MCP | MCP | Image gen (Flux 2, Nano Banana) + Video (Veo 3.1, Kling) | 1 |
| Rendervid MCP | MCP | Video rendering — JSON templates, 40+ animation presets | 1 |
| CloudLayer MCP | MCP | HTML-to-image — ad template → PNG export | 1 |
| ElevenLabs MCP | MCP | Voice cloning + TTS for UGC voiceovers | 2 |
| Firecrawl MCP | MCP | Web scraping, policy monitoring, competitive research | 1 |
| Drizzle ORM | npm | Schema, migrations, CRUD queries | 1 |
| Kysely | npm | Complex analytics (CTEs, window functions) via Drizzle bridge | 1 |
| Superforms + Zod | npm | Brief editor form validation | 1 |
| LayerChart | npm | 90% of charts (line, bar, area, pie) — shadcn-native | 2 |
| Apache ECharts | npm | Sankey/funnel diagrams (3 chart instances) | 2 |
| SVAR DataGrid | npm | Lead intelligence table — virtual scrolling for 443K+ rows | 3 |
| svelte-maplibre-gl | npm | GPU-accelerated choropleth map for lead geography | 3 |
| Sharp | npm | Image resize, composite, overlay, watermark | 1 |
| fluent-ffmpeg | npm | Video transcoding, aspect ratio transforms | 1 |
| Cloudflare R2 | API | Creative asset storage (S3-compatible, zero egress) | 2 |
| Cloudflare Zaraz | API | Server-side tag management, 100% fire rate | 1 |
| Meta Marketing API | API | Campaign insights, CAPI events, account health | 4 |
| Google Ads API | API | Read-only metrics, Quality Score, optimization score | 4 |
| Everflow | API | Attribution tracking, click/conversion data | 1 |
| Directus | API | CMS + ops database (19 collections) | 1 |
| Metabase | Embed | BI dashboards (7 existing + 5 new in Phase 3) | 1 |
| Plane MCP | MCP | Project management — task creation from pipeline | 1 |
| Listmonk | API | Email capture, drip sequences, subscriber management | 3 |
| GrowthBook | API | A/B testing, feature flags (Bayesian stats) | 3 |
| n8n | API | Workflow automation (social posting, alerts, data sync) | 3 |
What gets built when. Each phase has a GATE that blocks the next. Click to expand.
Phase 1: Foundation (Weeks 1-3) — Platform MVP + Tracking
BUILD-P: SvelteKit scaffold, Drizzle schema, PostgreSQL, Auth, App shell, Agent Executor, Pipeline Orchestrator, Brief Editor, Stage execution UI, Deploy to Coolify
OPERATE: Meta Pixel + Google tag via Zaraz, CAPI relay, ad account creation, verification, campaign structures (paused)
BUILD-C: Astro scaffold, design tokens, layouts, MDX content migration (runs in parallel, 30 tasks)
GATE: Campaign creatable + pipeline runnable from UI + tracking verified end-to-end
Phase 2: Core Workflow + Warm-Up (Weeks 4-6) — Full UI + First Campaign
BUILD-P: Strategy browser, Copy workspace + QA, Creative gallery + R2, Export center, Landing page builder, Campaign overview
OPERATE: Meta warm-up (engagement → traffic → conversion), Google Search launch + Bing import, TikTok verification, first live campaign, first retro → seed Winners Vault
GATE: Full workflow from brief → approval → export in UI + accounts through learning phase + Winners Vault seeded
Phase 3: Intelligence + Automation (Weeks 7-9) — 28 Tasks
3A Intelligence: SVAR DataGrid leads, segment builder, geographic map, Metabase embed, dashboard KPIs
3B Email + A/B: Listmonk deploy, MJML templates, email capture on tools, GrowthBook deploy, first experiments
3C Social: n8n deploy, Brand Hub UI, article → social workflow, tool highlight workflow, platform API connectors
3D Health: Platform Health module, Firecrawl policy cron, Ad Library scrape, fatigue detection, Winners Vault DB sync
3E Data: Directus collections (4 new), 5 Metabase dashboards
GATE: Email capturing, social automated, intel monitoring live, health tracked
Phase 4: Ad Platform Integration (Weeks 10-14) — 15 Tasks
Meta Marketing API + Google Ads API + TikTok + Bing — read-only metrics → ad_metrics table → performance dashboard. Daily cron for metric pulls. Full CAPI + Zaraz configuration. Campaign retro automation. Ad fatigue alerting. Cross-platform attribution (ECharts Sankey).
GATE: Live metrics in platform, CAPI firing, retro automated, cross-platform attribution
Phase 5: Scale (Weeks 15+) — Distribution + Multi-Vertical
Evaluate Inngest for durable workflows. Build ping/post routing engine (ingest → validate → ping buyers → auction → post). Buyer CRUD, revenue/margin tracking, fraud detection (IPQualityScore). Multi-vertical expansion to auto-insurance. Campaign push to ad platforms (PAUSED state, manual review).
GATE: Own lead distribution active. Second vertical profitable.
11
Deployment -- Coolify Services
All services on a single 8GB DigitalOcean droplet ($56/mo). Phase 3 adds ~1.1GB; upgrade to 16GB ($112/mo) at ~80% utilization.
Phase 1-2 (Current)
~4.5 GB
Coolify 1.2GB + Platform 256MB
Directus 512MB + Metabase 1.5GB
Plane 512MB + Postgres 256MB
Phase 3 (+3 Services)
~5.6 GB
+ Listmonk 128MB + n8n 512MB
+ GrowthBook 256MB
70% utilization on 8GB
Phase 5 (Scale)
~6.5 GB+
+ Ping/Post engine + 2nd vertical
Upgrade to 16GB ($112/mo)
or split services across droplets