Private writing workspace that produces structured, multi-agent reflection and evaluation. The system is intentionally non-social and focused on clarity, accountability, and auditability.
- Five fixed agents: Editor, Definer, Risk, Skeptic, Coach.
- Read-only reflection outputs (no conversational UI).
- Streaming or non-streaming reflection.
- JSON snapshots for audits and local backup.
- Evaluation pipeline for format and role compliance.
- User writes an entry and saves it.
- The entry is stored in MongoDB.
- User triggers reflection.
- The API calls each agent with shared rules and agent-specific prompts.
- Feedback is stored in MongoDB and a snapshot is written to
apps/web/reflections/<entryId>.json. - Optional: run eval scripts to validate outputs and store evaluation results.
flowchart TD
U["User"] --> UI["Next.js UI"]
UI -->|"POST /api/entries"| EN["Entries API"]
EN --> DB[("MongoDB: entries")]
UI -->|"POST /api/entries/:id/reflect"| RF["Reflect API"]
RF -->|"Build userText"| OR["OpenRouter calls"]
OR -->|"editor/definer/risk/skeptic/coach"| FB["Feedback records"]
FB --> DB
FB --> SNAP["Snapshot writer"]
SNAP --> FS["apps/web/reflections/<entryId>.json"]
subgraph EvalPipeline["Eval Pipeline"]
EV["scripts/eval-batch.mjs"] --> EP["eval/eval-prompt.txt"]
EV --> TX["Transcript builder"]
TX --> EM["Eval model"]
EM --> VL["validateEvalResult"]
VL --> DBE[("MongoDB: evaluations")]
end
DB --> UI
DBE --> UI
- Next.js (App Router)
- React + TypeScript
- Tailwind CSS
- MongoDB
- OpenRouter API
apps/web/
├── app/ # UI and API routes
├── lib/ # MongoDB, OpenRouter, prompts, eval utils
├── reflections/ # Snapshot JSON files
├── eval/ # Eval prompt and golden cases
└── scripts/ # Eval scripts
Create apps/web/.env.local:
MONGODB_URI=your_mongodb_connection_string
MONGODB_DB=ai_private_blog
OPENROUTER_API_KEY=your_openrouter_api_key
OPENROUTER_MODEL=your_default_model
# Optional per-agent overrides
OPENROUTER_MODEL_EDITOR=...
OPENROUTER_MODEL_DEFINER=...
OPENROUTER_MODEL_RISK=...
OPENROUTER_MODEL_SKEPTIC=...
OPENROUTER_MODEL_COACH=...
# Optional per-agent max tokens
OPENROUTER_MAX_TOKENS=...
OPENROUTER_MAX_TOKENS_EDITOR=...
OPENROUTER_MAX_TOKENS_DEFINER=...
OPENROUTER_MAX_TOKENS_RISK=...
OPENROUTER_MAX_TOKENS_SKEPTIC=...
OPENROUTER_MAX_TOKENS_COACH=...
OPENROUTER_EVAL_MODEL=your_eval_model
OPENROUTER_EVAL_MAX_TOKENS=1500
OPENROUTER_APP_URL=http://localhost:3000
OPENROUTER_APP_NAME=Private Blogging Intelligence
Run from apps/web:
npm run devnpm run buildnpm run startnpm run lintnpm run eval:prnpm run eval:gate
GET /api/entriesPOST /api/entriesGET /api/entries/:idPATCH /api/entries/:idDELETE /api/entries/:idPOST /api/entries/:id/reflectPOST /api/entries/:id/reflect/stream
- Prompts:
apps/web/lib/prompts.ts - Model config:
apps/web/lib/model-config.ts - Reflect routes:
apps/web/app/api/entries/[id]/reflect - Eval prompt:
apps/web/eval/eval-prompt.txt - Eval utils:
apps/web/lib/eval-utils.tsand.mjs - Eval dashboard:
apps/web/app/admin/eval
- Build transcript from entry + feedback.
- Eval model produces a JSON verdict.
- Validation enforces evidence must exist in the transcript.
- Results are stored in
evaluationsand visualized in the admin dashboard.
apps/web/lib/prompts.ts- Reflect routes agent list
apps/web/lib/model-config.tsapps/web/eval/eval-prompt.txtapps/web/lib/eval-utils.tsand.mjs- UI agent labels/order (
apps/web/app/page.tsx) - Eval dashboard ordering (
apps/web/app/admin/eval)