Server setup
Routers
/market — market data
| Endpoint | Description | TTL cache |
|---|---|---|
GET /market/stock/{symbol} | Single stock price + change % | 60s |
POST /market/stocks | Batch stock prices | 60s |
GET /market/crypto/{id} | Single crypto price (CoinGecko) | 60s |
POST /market/crypto | Batch crypto prices | 60s |
POST /market/forex | Exchange rates for pairs list | 5 min |
POST /market/batch | Stocks + crypto + forex in one call | 60s |
GET /market/history/{symbol} | OHLCV history (period + assetType) | 5 min |
GET /market/earnings | Earnings calendar | 1 hour |
/ai — agent endpoints
| Endpoint | Description |
|---|---|
POST /ai/ask | Non-streaming orchestrated response |
POST /ai/stream | SSE streaming response |
POST /ai/parse-bill | Extract line items from bill text/image (Haiku) |
POST /ai/parse-notification | Extract transaction from notification text (Haiku) |
GET /ai/daily-insights | Run AnomalyAlerts, return insight list |
/transactions, /holdings, /accounts
Standard CRUD. All endpoints require JWT auth via get_current_user dependency. All Supabase queries are scoped to user_id and protected by RLS.
/newsletter
| Endpoint | Description |
|---|---|
GET /newsletter/latest | Most recent newsletter for user |
GET /newsletter/today | Today’s newsletter (null if not yet generated) |
POST /newsletter/generate | Trigger generation immediately |
/rag
| Endpoint | Description |
|---|---|
POST /rag/ingest | Manual ingestion trigger (admin, query param user_id) |
TTL cache
price_cache— stocks and crypto (60s TTL)forex_cache— currency pairs (300s TTL)auth_cache— validated JWTs (300s TTL)history_cache— OHLCV data (300s TTL)earnings_cache— earnings calendar (3600s TTL)
Supabase client
user_insights and user_newsletters without being blocked by user-scoped RLS. User data access is still scoped by passing user_id explicitly to all queries.
Claude clients
AsyncAnthropic instance under the hood. Model is specified per-call:
| Use case | Model |
|---|---|
| Intent classification (fallback) | claude-haiku-4-5 |
| Bill parsing | claude-haiku-4-5 |
| Notification parsing | claude-haiku-4-5 |
| News curation (newsletter) | claude-haiku-4-5 |
| Specialist agent responses | claude-sonnet-4-5 |
| Newsletter synthesis | claude-sonnet-4-5 |
APScheduler — background jobs
Three RAG ingestion jobs run automatically:user_embeddings.
Environment variables
Health check
Production deployment
The full deployment guide is in Self-Hosting → EC2 Deployment. Summary:- uvicorn with
--workers 1(single process — in-memory caches are process-local) - nginx reverse proxy on port 443, forwards to uvicorn on 8000
- systemd service for auto-restart on crash
- Certbot for TLS certificate