Architecture Overview
Core Shape
The backend is a FastAPI service with four main layers:
api/for route handlers and schemasauth/for user registry and request authenticationinfra/db/for encrypted per-user DB engines and repositoriesservices/for run execution, exports, results assembly, and integration logic
Supporting layers:
security/for encryption, provider keys, and DB-key cachingevaluation/for eval logic and report generationadapters/for model-specific generation backends
Runtime Model
Each user has:
- one active encrypted DB file
- one per-user log DB
- one filesystem run-artifact tree
The backend does not use a single master app DB for user content.
Startup
On startup the app:
- installs the env override proxy
- registers the SQLCipher dialect
- verifies
sqlcipher3import - loads the user registry from the filesystem
- initializes the shared credits DB
- verifies the seed DB exists
- attempts orphan-run recovery only for users whose DB key is already cached