📈 Reports & Caching
Reports aggregate expense data; caching keeps the hot paths fast without Mongo round-trips.
📊 Reports
Report endpoints live under interfaces/report/ and run over the expenses via the report domain models in domain/report/.
- Aggregate by tag, entity, category, or date range.
- Output shapes are defined in domain report models and serialized by the interface DTOs.
- Shared with the CLI report helpers when driven locally.
Typical flow: GET /reports/{kind}?from=...&to=...&tag=... returns a grouped breakdown (count + total per bucket).
🗃 Repositories & FK Population
Repos in infra/repos/ are generic mongo-ops repos wrapped per model. Key behaviors:
search(filter={...}, limit=...)— filter-first reads, no magic.- In-memory LRU cache — the default read path; writes call
_invalidate_cache. - Optional Redis mirror —
infra/cache/redis.pywith TTL-aware caching. x-fkcross-collection population — referenced ids (e.g.account_idon expenses) are populated by explicit filter lookups against the target repo, not Mongo joins.
🌐 HTTP Cache
infra/http_cache/ caches external HTTP responses:
| Config | Meaning |
|---|---|
HTTP_CACHE_TTL |
Cache time-to-live for responses |
HTTP_CACHE_MAX_ENTRIES |
Eviction cap for the cache store |
REDIS_URL |
When set, cache lives in Redis; otherwise in-memory |
Used by fetchers and enrichment lookups to avoid hammering upstreams during a full-statement import.
⚙️ Config Summary
| Env var | Purpose |
|---|---|
MONGO_URI / MONGO_DB |
MongoDB connection + database |
REDIS_URL |
Redis (cache mirror, optional) |
HTTP_CACHE_TTL / HTTP_CACHE_MAX_ENTRIES |
HTTP cache behavior |
LLAMA_CLOUD_API_KEY |
LlamaParse (llama family) |
EMAIL_HOST / EMAIL_USER / EMAIL_PASS |
IMAP ingestion |
AUTH_SERVER |
External auth/service integration |
WORKER_* |
Worker polling knobs (see fetch-request workflow) |
DEBUG |
Verbose logging |