A FastAPI application that takes an expert from onboarding, through a knowledge base, into a single conversational agent (IQ) that can build apps, write content, and ship them live. This is the engine — and it's running in production.
Architecture at a glance
The user only ever talks to IQ. IQ routes across modes and reaches into a registry of tools — onboarding, knowledge, builders, and the MIOSA infrastructure — then streams results back over SSE.
The major flows
Six pipelines carry the product. Each is implemented, wired into IQ's tools, and exercised in the end-to-end tests.
Session → expert dossier → offer stack → context profile → avatar (FAL portraits) → QA checkpoint → engine selection → handoff. State-machine driven, with editable section revisions and progress tracking.
Sources (files / URLs / pasted text) → async extraction (pypdf, docx) → embeddings → Pinecone, with custom retrieval rules and a manual review checkpoint. IQ retrieves from it via tools.
One conversational agent, four modes, 45+ tools auto-discovered across the codebase. Streams over SSE with ticket-based auth. Grounded in the knowledge base and foundation docs.
Website, webinar, email, sales script/letter, ad creative, content, podcast, lead magnet, funnel, program. Outputs stored as versioned artifacts; exportable to Markdown / HTML / PDF.
Create sandboxes, write files, exec, expose previews, publish releases, deploy to *.cliniciq.com, provision managed databases and storage — all workspace-scoped.
Email (Resend / Mailchimp), social (Ayrshare), landing pages with custom domains + DNS verification. Background-job dispatched per target.
API surface
| Domain | Representative endpoints | Purpose |
|---|---|---|
| Auth | POST /auth/login · /register · /google/login · /refresh | JWT + Google OAuth, Argon2id, RBAC roles |
| Onboarding | POST /onboarding/session · /offer · /qa-checkpoint · GET /handoff | Expert setup state machine |
| Knowledge | POST /knowledge/sources · GET /knowledge/documents · /rules | Index + retrieve expert knowledge |
| IQ | POST /iq/chat · /iq/sse-ticket · /iq/upload-files | Conversational agent, streaming |
| Builders | POST /builders/{website|webinar|email|funnel|…} | Generate content artifacts |
| MIOSA | POST /miosa/sandboxes · /expose · /deploy · /databases | Infra: sandbox, preview, deploy, data |
| Artifacts | GET /artifacts/{id} · /export · /html | Builder output management + render |
| App projects | POST /app-projects · /files · /diff · /deploy | Sandbox-backed app lifecycle |
| Publish | POST /publish/schedule · POST /domains · /verify | Multi-channel + custom domains |
Stack & conventions
In flight right now
These are the uncommitted changes on my machine — the final pass on agent rendering and output quality before you pull. This is the "refine the outputs" work, mid-stride.
# backend-cliniciq · uncommitted (working tree) M app/agents/orchestrator/_llm_loop.py // agent loop tuning M app/agents/orchestrator/runner.py // streaming + render hook M app/agents/orchestrator/prompt_context.py // prompt grounding M app/agents/meta_agents/artifact_renderer.py // output rendering M app/agents/tools/build/build_app.py // IQ builds + previews M app/agents/tools/build/deploy_artifact.py // deploy path M app/agents/tools/drafting/draft_landing.py // landing output quality … + ad/email/post/content drafting + artifact create/update # recently shipped 68e1f8a Scope sandbox preview exposure by workspace b448337 wire build_app so IQ can build and preview through its own tools 3c25419 ground IQ in foundation docs, stop re-onboarding completed experts cd84dc0 harden artifact renderer: detached serve, idempotency, premium slides