Lifecycle Layers
Every request flows through:- ASGI server receives request
- middleware (rate limiting, timing, CORS)
- FastAPI route validation + dispatch
- service orchestration
- persistence side effects
- response return (
JSON,SSE, orWS)
Startup Lifecycle
On app boot:- config load
- DB/index initialization
- optional FTS backfill from Chroma when needed
- optional observability integration bootstrap
Ingestion Lifecycle
Job-backed paths
POST /api/ingestPOST /api/ingest/upload
- create queued job record
- run background processing
- update progress/state (
queued -> processing -> completed|failed) - expose status via
GET /api/ingest/{job_id}andWS /api/ingest/ws/{job_id}
Direct path
POST /api/ingest/url
ok / error) without job polling semantics.
Chat Lifecycle (/api/chat and /api/chat/stream)
Key contracts:
- conversation creation is implicit in chat flow
- provenance fields are returned in response payloads
- streaming path ends with one terminal event (
doneorerror)
Persistence Touchpoints
Chat path writes:- conversations/messages
- feedback-linked metadata fields
- Chroma vectors + metadata
- FTS index rows
- learnings artifacts
- cache invalidation side effects