Architecture
How Casey runs in five layers
All five layers live inside one Next.js application. The orchestrator and the LLM sub-agents are real. The data plane is mocked to a single SQLite file shipped with the repo — in production these connect to firm systems.
Client (App Router)
Three RSC + Client routes: /, /triage/[jobId], /architecture. EventSource consumes the SSE stream.
Route Handlers (Node runtime)
POST /api/triage kicks off orchestrator; GET /stream emits SSE events; GET /[jobId] returns final result.
Orchestrator + in-memory jobs
Sequence of generateObject calls. Halts on blocking conflict. Event bus delivers to SSE subscribers.
Sub-agents (Vercel AI SDK + Anthropic)
Each agent: focused system prompt + Zod schema via generateObject. Model: claude-sonnet-4-6.
Data plane
MockedRead-only SQLite for the demo. In production, these are firm systems: Intapp Conflicts, CRM, experience DB.
Data flow per RFP
- 1. User picks a sample or uploads a PDF →
POST /api/triageparses the document, mints ajobId, starts the orchestrator in a background promise. - 2. Client navigates to
/triage/[jobId]and opens anEventSourceon the stream route. - 3. Orchestrator emits
stage_N_start/stage_N_doneevents as each sub-agent completes. UI animates each card in. - 4. On
conflicts.overallPosition === 'blocking', the orchestrator emitshaltedand skips stages 3–5. - 5. On
complete, the kickoff brief renders at the bottom of the triage view.