Cerina implements a supervisor-worker pattern using LangGraph to orchestrate specialized agents that collaboratively create CBT content. The system ensures clinical safety and quality through multiple review stages before human approval.
- Draftsman - Generates and revises CBT exercise content
- Safety Guardian - Validates against self-harm risks and medical boundaries
- Clinical Critic - Ensures empathy, tone, and clinical accuracy
- Finalizer - Prepares final output for human review
The system consists of three main components:
- Agent System - LangGraph-based multi-agent orchestration
- Backend API - FastAPI REST service with PostgreSQL persistence
- Frontend Dashboard - Next.js web interface for session management
graph LR
subgraph Clients
CLAUDE["Claude Desktop<br/>(MCP Client)"]
REACT["React UI<br/>(Browser)"]
end
CLAUDE -->|MCP Protocol| MCP["MCP Server<br/>(cerina-foundry)"]
REACT -->|HTTP| API["FastAPI<br/>Backend"]
MCP --> API
API --> LG
subgraph LG["LangGraph Workflow"]
direction TB
DRAFT["Draftsman"]
SAFETY["Safety Guard"]
CRITIC["Critic"]
FINAL["Finalizer"]
end
graph TD
SUP["SUPERVISOR AGENT"] --> DRAFT["Draftsman"]
SUP --> SAFETY["Safety Guardian"]
SUP --> CLINICAL["Clinical Critic"]
DRAFT --> SUP
SAFETY --> SUP
CLINICAL --> SUP
SUP --> REFINE["Refinement Agent"]
REFINE --> SUP
SUP --> HUMAN["Human Review"]
HUMAN -->|approve| APPROVED["Approved"]
HUMAN -->|reject| REJECTED["Rejected"]
HUMAN -->|edit| SUP
- Python 3.13 or higher
- PostgreSQL 16 or higher
- Node.js 18 or higher (for frontend)
- uv package manager
Start the database:
docker-compose up -dConfigure environment variables:
cp .env.example backend/.envSet your API keys in the .env file:
ANTHROPIC_API_KEY=your_key_here
OPENAI_API_KEY=your_key_hereInstall Python dependencies:
cd backend
uv syncRun the backend server:
uv run python -m src.mainThe API will be available at http://localhost:8000.
cd frontend
npm install
npm run devAccess the dashboard at http://localhost:3000.
POST /api/v1/sessions- Create new sessionGET /api/v1/sessions- List all sessionsGET /api/v1/sessions/{id}- Retrieve session detailsDELETE /api/v1/sessions/{id}- Delete sessionPOST /api/v1/sessions/{id}/review- Submit review decisionGET /api/v1/sessions/{id}/stream- Server-sent events stream
GET /api/v1/exercises- List approved exercisesGET /api/v1/exercises/{id}- Retrieve exercise details
Create a new session:
curl -X POST http://localhost:8000/api/v1/sessions \
-H "Content-Type: application/json" \
-d '{"user_input": "Create an exposure hierarchy for agoraphobia"}'Submit a review:
curl -X POST http://localhost:8000/api/v1/sessions/\{session_id\}/review \
-H "Content-Type: application/json" \
-d '{"decision": "approve", "reviewer_id": "reviewer-1"}'Configure the language model provider in your .env file:
LLM_PROVIDER=anthropic # or openaiEnable LangSmith tracing:
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY=your_langsmith_key
LANGCHAIN_PROJECT=cerinaApply database migrations:
cd backend
uv run alembic upgrade head