%%{init: {
"theme": "base",
"themeVariables": {
"background": "#faf9f5",
"primaryColor": "#ffffff",
"primaryTextColor": "#1a1917",
"primaryBorderColor": "#d1cdc3",
"lineColor": "#8d8b83",
"secondaryColor": "#f0ede8",
"tertiaryColor": "#faf9f5",
"fontSize": "13px",
"fontFamily": "Inter, sans-serif",
"nodeBorder": "#d1cdc3",
"clusterBkg": "#f5f3ee",
"edgeLabelBackground": "#faf9f5"
}
}}%%
flowchart LR
%% ── AI PROVIDERS ──────────────────────────────────────────────────────────
subgraph AI["🟣 AI Providers"]
direction TB
ANTH["◆ Anthropic
─────────────────
Claude Sonnet · Haiku · Opus
Default LLM for interviewer,
authoring & analysis"]
BEDR["☁ AWS Bedrock
─────────────────
Claude via Bedrock
Enterprise data residency
Existing AWS contracts"]
OTHE["◉ OpenAI · Google · xAI
─────────────────
GPT-4o · Gemini · Grok
Fallback & multilingual
Via Vercel AI SDK"]
end
%% ── STUDIO / REACHY ───────────────────────────────────────────────────────
subgraph STU["🟢 Studio · AWS"]
direction TB
REAC["✦ Reachy
─────────────────
Multi-agent research builder
Persistent researcher memory
Website · crosstabs · authoring
Direct ClickHouse read"]
AUTH["✍ Survey Authoring Agent
─────────────────
Brief → JS survey program
Card schema aware
Compliance check on publish
Reachy sub-agent"]
STUI["🖥 Studio UI
─────────────────
Researcher workspace
Org & RD hierarchy
Study management & review
Better Auth (migrating Cognito)"]
AURO["🗄 Aurora / Neon
─────────────────
Researcher profiles
Org & RD hierarchy
Reachy memory store
Study metadata"]
ANAL["📊 Analysis & Dashboards
─────────────────
Toplines · crosstabs · verbatims
Reachy insight chat
Live during fielding
Shareable reports · export"]
end
%% ── CF GATEWAY ────────────────────────────────────────────────────────────
subgraph GWY["🔵 CF · Gateway"]
direction TB
GW["⚡ CF Worker — Gateway
─────────────────
JWT verification · routing
Publish endpoint for Studio
MCP server host
<5ms cold start · global PoPs"]
COMP["🛡 Compliance Worker
─────────────────
Leading question detection
PII flagging · GDPR consent
Triggered on every publish
Haiku model — fast & cheap"]
MCPS["🔌 MCP Surfaces
─────────────────
Authoring MCP: create_study,
author_from_brief, publish_study
Analytics MCP: query_responses
Execution MCP: field_study"]
JWT["🔑 JWT Survey Link
─────────────────
Signed by Studio or Panel API
Payload: studyId, sessionId,
panelId, quotaCellId, exp
HMAC-SHA256 · 2h TTL"]
D1["💾 D1 — Study Registry
─────────────────
Published JS survey programs
Quota config per study
Session index
Edge-local SQLite reads"]
end
%% ── CF EXECUTION ──────────────────────────────────────────────────────────
subgraph EXE["🔵 CF · Execution Layer"]
direction TB
IDO["🎙 Interview DO
─────────────────
Executes survey.js program
await interview.ask() = pause
Hibernates between turns
SQLite session state · $0 idle"]
SDO["📋 Study DO
─────────────────
Quota cell enforcement
Completion counter tracking
Synthetic respondent dispatch
One DO per active study"]
AIAG["🤖 AI Interviewer Agent
─────────────────
Claude · real-time probing
Coverage checklist tracking
Dynamic follow-up questions
SSE streaming · voice-aware"]
CARD["🃏 Card Renderer
─────────────────
Mobile-first React SPA
65+ card types rendered
SSE stream from Interview DO
Pure renderer — no logic"]
QUEU["📨 CF Queues
─────────────────
Interview DOs → ClickHouse
Durable · ordered delivery
Decouples hot path from
analytics writes"]
end
%% ── PANEL & EXTERNAL ──────────────────────────────────────────────────────
subgraph PNL["🟠 Panel & External"]
direction TB
PANL["👥 Rival Panel & Distribution
─────────────────
Respondent database
Demographic targeting
Invite dispatch pipeline
JWT survey link generation"]
PAPI["🔌 Panel API — Target State
─────────────────
recruit_respondents()
dispatch_links()
get_quota_status()
Lucid · Cint · Dynata plug-in"]
SYNT["🧬 Synthetic Respondents
─────────────────
AI personas via Study DO
Same Interview DO path
Quota gap fill
Configurable persona profiles"]
VOIC["🔊 Voice Pipeline
─────────────────
WebSocket transport
Cartesia TTS · Deepgram STT
Live captions · transcripts
DO hibernation API"]
MCPC["🤖 MCP Clients
─────────────────
Claude Desktop · Cursor
Any MCP-capable agent
Headless authoring + analytics"]
BIBI["📉 BI Tools
─────────────────
Tableau · PowerBI · Looker
Direct ClickHouse connector
Scoped read-only creds per org"]
end
%% ── DATA LAYER ────────────────────────────────────────────────────────────
CH["📈 ClickHouse Cloud — Analytics & Events
─────────────────────────────────────────────────────────────────────────
Tables: interview_events · ai_probe_turns · card_responses · quota_snapshots
Written by CF Queues · Read by Studio / Reachy / BI tools with scoped read-only creds per org
Real-time streaming queries during fielding · Sub-second aggregations"]
%% ── ARROWS ────────────────────────────────────────────────────────────────
%% All 3 AI → Reachy
ANTH -.->|LLM| REAC
BEDR -.-> REAC
OTHE -.-> REAC
%% All 3 AI → AI Interviewer
ANTH -.->|LLM API| AIAG
BEDR -.-> AIAG
OTHE -.-> AIAG
%% Studio internal
REAC -.-> AUTH
STUI -.-> AURO
STUI -.->|study dispatch| PANL
%% Authoring → Gateway
AUTH -->|publish study| GW
%% Gateway
GW -->|route + JWT verify| IDO
GW -.-> SDO
GW -.->|pre-publish| COMP
%% D1 reads
D1 -.->|study lookup| GW
D1 -.->|session state| IDO
%% Execution internal
IDO -->|LLM call| AIAG
IDO -->|SSE stream| CARD
SDO -.->|dispatch| SYNT
%% Events → data
IDO -->|events| QUEU
QUEU -->|async write| CH
%% Analytics
CH -->|direct read| ANAL
CH -.-> BIBI
%% Panel chain
PANL --> PAPI
PAPI -->|JWT links| JWT
JWT -->|respondent entry| GW
%% MCP
MCPC -.->|MCP| MCPS
MCPS -.-> GW
%% ── CLASS DEFINITIONS ─────────────────────────────────────────────────────
classDef aiNode fill:#f3eef8,stroke:#7a5a96,stroke-width:2px,color:#1a1917
classDef studioNode fill:#eef3ec,stroke:#5a7a4f,stroke-width:2px,color:#1a1917
classDef cfNode fill:#eef1f8,stroke:#4a6fa5,stroke-width:2px,color:#1a1917
classDef panelNode fill:#faf3e8,stroke:#b87a2e,stroke-width:2px,color:#1a1917
classDef extNode fill:#eef6f2,stroke:#2a7a60,stroke-width:2px,color:#1a1917
classDef dataNode fill:#faeaea,stroke:#b04040,stroke-width:2px,color:#1a1917
class ANTH,BEDR,OTHE aiNode
class REAC,AUTH,STUI,AURO,ANAL studioNode
class GW,COMP,MCPS,JWT,D1,IDO,SDO,AIAG,CARD,QUEU cfNode
class PANL,PAPI panelNode
class SYNT,VOIC cfNode
class MCPC,BIBI extNode
class CH dataNode
%% subgraph styles
style AI fill:#f9f6fd,stroke:#7a5a96,stroke-width:1.5px,color:#7a5a96
style STU fill:#f4f8f2,stroke:#5a7a4f,stroke-width:1.5px,color:#5a7a4f
style GWY fill:#f0f3fb,stroke:#4a6fa5,stroke-width:1.5px,color:#4a6fa5
style EXE fill:#eef2fa,stroke:#4a6fa5,stroke-width:1.5px,color:#4a6fa5
style PNL fill:#fdf6ec,stroke:#b87a2e,stroke-width:1.5px,color:#b87a2e