# BRAIN.md ## Architecture (invest-copilot) - **Backend:** FastAPI (`src/backend/main.py`) — routers, services, models, schemas, Celery tasks - **Frontend:** Next.js 15 App Router — pages, components (shadcn/ui), Zustand stores, TanStack Query hooks - **Data:** TimescaleDB (PostgreSQL), Redis cache, MinIO storage - **Pipeline:** `src/data-pipeline/` — price/SEC/news ingestion, `pipeline.py` orchestrator - **Real-time:** Celery → Redis Pub/Sub → SSE/WebSocket (`stream.py`) → frontend ## Key Patterns - Frontend → FastAPI Router → Service → SQLAlchemy → TimescaleDB - Auth: JWT + session via middleware - Strategy → DB → Celery evaluation → Alert → SSE push ## Invariants - TimescaleDB hypertables for all time-series data - Never assume DB schema — read migrations first - Research → design → implement flow