Server setup
Routers
/market — market data
/ai — agent endpoints
/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
/rag
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:
Haiku is used wherever the task is classification or extraction (cheap, fast). Sonnet is used wherever reasoning or synthesis is required (higher quality).
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