Forven is a local-first trading operations framework with three main layers:
- A SvelteKit frontend for operator workflows
- A FastAPI backend for APIs, orchestration, and compatibility routes
- Local persistence and workspace state centered on SQLite and
FORVEN_HOME
graph TD
UI["SvelteKit frontend"] -->|typed API wrappers| API["FastAPI app"]
UI -->|WebSocket live feed| WS["/api/ws/live"]
API --> CP["control_plane modules"]
API --> DOM["api_domains and service modules"]
API --> DB[("SQLite")]
API --> MEM[("ChromaDB")]
API --> WORK["workspace files under FORVEN_HOME"]
API --> EXT["AI providers, data sources, Discord, exchanges"]
The frontend lives in frontend/.
Current frontend stack:
- SvelteKit 2
- Svelte 5
- Tailwind CSS
- Vite
- Vitest and Playwright for test coverage
Important frontend conventions:
- API access belongs in
frontend/src/lib/api/ - Shared state belongs in
frontend/src/lib/stores/ - Reusable components live in
frontend/src/lib/components/ - Route shells live in
frontend/src/routes/
The active route tree includes:
//agents/ai-dropzone/data/lab/lab/strategy/[id]/memory/ops/risk/runs/settings/tasks/trades
The dashboard also supports /?view=quant_factory and /?view=beta.
- The Vite dev server proxies
/apiand/healthto the backend - Frontend API resolution also supports direct backend access on port
8003 - Live updates use the WebSocket endpoints exposed by the backend
The FastAPI app is assembled in forven/api.py.
Key app responsibilities:
- Register routers
- Apply CORS
- Apply
ForvenV1CompatMiddleware - Run startup initialization through
forven.api_core._on_startup - Expose the health endpoints and websocket routes used by the frontend
The registered router set currently includes:
statusnotificationsmemoryapprovalsopsanalyticsdatataskstradingpaperjobslegacysystemauthagentsstrategieswebsocketsquant_factorywebhooksbacktestinglifecyclesimulationverdictrobustness
The repo uses several layers instead of a single monolith:
forven/routers/: HTTP and websocket route definitionsforven/control_plane/: operator-facing runtime behavior such as status, ops, approvals, and notificationsforven/api_domains/: extracted API-facing domain logic and compatibility helpersforven/strategies/: strategy base classes, registry, optimization, and backtesting helpersforven/api_core.py: shared compatibility, startup, and legacy behavior that has not yet been fully extracted
ForvenV1CompatMiddleware and the legacy routes keep older /api/forven/* clients working while the current frontend and newer APIs use the newer route layout.
SQLite is the main system of record for:
- strategies and lifecycle events
- backtest results and related artifacts
- tasks and audit logs
- approvals
- notifications
- scheduler state
- trades and positions
- settings and KV runtime state
The core implementation lives in forven/db.py.
Runtime state defaults to ~/.forven unless FORVEN_HOME is set. Important files and directories include:
forven.dbauth.jsonconfig.jsonworkspace/
ChromaDB is used for memory and retrieval-style workflows. The frontend exposes this through the /memory route and the backend memory router.
start_all.ps1 is the most complete bootstrap path on Windows. It:
- creates or repairs
.venv - installs backend dependencies if missing
- installs frontend dependencies if missing
- initializes the database
- starts backend, frontend, and optional bot/daemon services
start_all.sh starts backend, frontend, and optional bot/daemon services after dependencies are already installed. It also loads .env automatically when present.
- Backend health:
/api/health - Compatibility health:
/health - System status:
/api/system/status - Soak report:
/api/system/soak-report - Live websocket:
/api/ws/liveand/ws/live
- Use absolute Python imports
- Keep backend routers thin
- Add frontend API wrappers instead of raw component fetches
- Treat
forven/exchange/as sensitive integration code - Update docs when route surfaces, startup flows, or operator behavior change