Quick Reference¶
5-Minute Architecture Overview¶
Deployment Stack¶
Infrastructure: - Frontend: React/Vite at http://localhost:3000 (dev) - Backend: FastAPI at http://localhost:8000 (dev) - Database: PostgreSQL (prod) via SSH tunnel from Uberspace - LLM: Ollama (local default), upgradable to OpenAI/Gemini - Proxy: oauth2-proxy at http://localhost:4180 (prod entry point) - Market Data: Finnhub (primary) → Alpha Vantage (fallback)
Docker Compose:
- 4 local services: backend, frontend, ollama, oauth2-proxy
- All configured in root Taskfile.yml and docker-compose.yml
- Uberspace-hosted database reached via SSH tunnel
Data Domains¶
Domain 1: Assets (Portfolio + Market Data) - User portfolio: stocks, ETFs, cryptocurrencies - Real-time prices via Finnhub/Alpha Vantage (EUR converted) - Price history via polling (30s cadence) - Analytics: allocation, performance, sector analysis
Domain 2: Transactions (Bank Imports + Spending Analysis) - CSV import from bank (CaMT52 format, German banking standard) - Encoding detection (UTF-8, ISO-8859-1, CP1252) - AI categorization via Ollama (6 categories) - Encryption: Fernet AES-256 for descriptions - Blind indexing: HMAC for searchable encrypted fields - Deduplication: SHA-256 fingerprinting
Technology Stack¶
| Component | Tech |
|---|---|
| Backend | FastAPI + SQLAlchemy (ORM) |
| Frontend | React + Vite + Tailwind CSS |
| Database | PostgreSQL (prod), SQLite (dev) |
| LLM | Ollama (local), OpenAI/Gemini (optional) |
| Market Data | Finnhub API + Alpha Vantage (fallback) |
| Security | Fernet encryption, HMAC blind indexing, OAuth2 |
| Deployment | Docker Compose, Uberspace, GitHub Actions |
🔴 Top 14 Improvements (Ranked by Impact)¶
Critical Issues (Must Fix)¶
- Monolithic main.py (50+ endpoints in single file)
- Impact: HIGH | Effort: MEDIUM
- Solution: Split into APIRouter modules (assets, transactions, settings, ai, health)
-
Benefit: Maintainability, testing, scalability
-
Endpoint Ordering Dependency (
/analyzemust precede/{symbol}) - Impact: HIGH | Effort: LOW
- Solution: Use explicit FastAPI route decorators and parameter validation
-
Benefit: Eliminate fragile dependencies, improve robustness
-
No Encryption Key Versioning
- Impact: HIGH | Effort: MEDIUM
- Solution: Add key_version columns to Transaction model; implement key rotation strategy
- Benefit: Enable future key rotation; essential for production
Important Issues (High Priority)¶
- Frontend Theme Inconsistency (dark + inline styles vs. Tailwind)
- Impact: MEDIUM | Effort: MEDIUM
- Solution: Standardize on Tailwind; migrate asset screens to consistent theme
-
Benefit: Maintainability, consistency, faster development
-
No API Versioning (/api/v1/)
- Impact: MEDIUM | Effort: LOW
- Solution: Add version prefix to all endpoints
-
Benefit: Backward compatibility, easier API evolution
-
Hardcoded Transaction Categories
- Impact: MEDIUM | Effort: MEDIUM
- Solution: Move categories to database enum; make extensible
-
Benefit: Enable Budget feature, user customization
-
Frontend Polling Without Backoff (hard-coded 30s)
- Impact: MEDIUM | Effort: LOW
- Solution: Add jitter, exponential backoff, configurable cadence
- Benefit: Resilience, reduced thundering herd risk
Quality of Life (Medium Priority)¶
- No Request/Response Validation Models
- Impact: MEDIUM | Effort: MEDIUM
- Solution: Add Pydantic models for all endpoints
-
Benefit: Type safety, auto-generated API docs, better errors
-
No Error Handling Middleware
- Impact: MEDIUM | Effort: LOW
- Solution: Standardize error responses (JSON format, error codes)
-
Benefit: Consistent client error handling
-
Insufficient Test Coverage
- Impact: MEDIUM | Effort: HIGH
- Solution: Add tests for transaction pipeline, security, edge cases
- Benefit: Confidence in critical paths
-
No Structured Logging
- Impact: LOW | Effort: LOW
- Solution: Add structured request logging (JSON format)
- Benefit: Debugging, monitoring, audit trail
Future Enablers (Low Priority)¶
-
No Feature Flags System
- Impact: LOW | Effort: MEDIUM
- Solution: Implement feature flags (enables gradual rollout)
- Benefit: Safer deployments, A/B testing
-
Market Data Requests Sequential (no parallel fallback)
- Impact: LOW | Effort: LOW
- Solution: Parallelize Finnhub + Alpha Vantage requests
- Benefit: Faster response times
-
No API Rate Limiting
- Impact: LOW | Effort: MEDIUM
- Solution: Add rate limiting middleware
- Benefit: Prevent abuse, protect external APIs
📊 Architecture Quality Score: 7/10¶
Strengths: - ✅ Security-first design (encryption, blind indexing, fingerprinting) - ✅ Clean utils layer (market data, LLM, parsers, security modules) - ✅ Flexible LLM routing (Ollama → OpenAI/Gemini) - ✅ Good provider fallback (Finnhub → Alpha Vantage) - ✅ Encrypted transaction storage with searchable indexes
Weaknesses: - ❌ Monolithic main.py (50+ endpoints) - ❌ No API versioning or clear routing structure - ❌ Endpoint ordering dependencies (fragile) - ❌ Frontend theme inconsistency - ❌ Hardcoded categories (inflexible for Budget feature) - ❌ No encryption key rotation strategy
🚀 Recommendations for New Features¶
FinTS Integration (Issue #11)¶
- Build as new APIRouter:
routers/bank_connections.py - Reuse transaction encryption/dedup pipeline
- Use explicit routing pattern (not monolithic)
- Add tests for HBCI parser
Google Sheets Budget (Issue #12)¶
- Build as new APIRouter:
routers/budgets.py - Requires: DB-driven categories (Issue #6)
- Make category mapping flexible
- Handle multi-person responsibility tracking
For detailed architecture, see System Diagrams.
For full recommendations, see Improvement Roadmap.