Skip to content

Commit 3eab069

Browse files
aafreclaude
andcommitted
perf(api,web): bound transactions query by date, add /transactions/months
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ATghuAGL4B1rYcAk97LmjE
1 parent 7c4c112 commit 3eab069

11 files changed

Lines changed: 1627 additions & 49 deletions

‎.python-version‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

‎CLAUDE.md‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
Everything runs through `uv` (never bare `python`/`pytest`):
8+
9+
```bash
10+
uv sync # install locked deps
11+
uv run pfa db migrate # required before any CLI/API workflow
12+
uv run pfa <cmd> # CLI entrypoint (pfa.cli.app:app)
13+
uv run uvicorn pfa.api.app:app --host 127.0.0.1 --port 8000
14+
uv run pfa eval-classifier # classifier smoke, needs a running Ollama model
15+
```
16+
17+
Full quality gate — all four must pass before claiming work is complete (matches CI):
18+
19+
```bash
20+
uv run ruff check . && uv run ruff format --check . && uv run mypy src && uv run pytest
21+
```
22+
23+
mypy runs in `strict` mode over `src` only. Single test: `uv run pytest -k 'test_name'`.
24+
25+
## Hard rules
26+
27+
- **The LLM never computes financial facts.** Every number a user sees must come from deterministic
28+
Python/SQL in `analytics`, `planning`, or `domain`, surfaced through a typed read-only tool. The
29+
agent interprets and explains; it does not calculate. Adding a number to a prompt/response that no
30+
tool returned is a bug.
31+
- **Local models only.** No cloud/hosted LLM APIs, no telemetry. Ollama at `PFA_OLLAMA_BASE_URL` is
32+
the only inference path. Live AI paths are fine to exercise, but `uv run pytest` must stay offline —
33+
the normal suite never calls Ollama.
34+
- **Money is integer minor units.** Use `domain.money.Money` and `Decimal`; binary floats must never
35+
reach a monetary calculation. v0.1 is GBP-only and rejects other currencies rather than summing them.
36+
- **Schema changes go through Alembic** (`alembic/versions/`). Runtime service code never creates or
37+
upgrades tables.
38+
39+
## Domain semantics
40+
41+
Getting these wrong silently corrupts reported figures:
42+
43+
- Owned-account transfers are persisted for audit but excluded from both income and spending.
44+
For paired transfers, only the debit/outgoing side contributes to a metric.
45+
- `savings rate = (saving transfers + investment transfers) / income` for the period.
46+
- Spending = classified expenses + fees − refunds. A refund reduces spending in the month it posts,
47+
even if the purchase was earlier.
48+
- Cash withdrawals move bank cash to physical cash: total tracked cash is unchanged, and the amount
49+
is not spending until the underlying purchase is classified.
50+
51+
Layer boundaries and deliberate constraints: @docs/architecture.md
52+
Agent design, tool contracts, and grounding rules: @docs/ai-engineering.md
53+
54+
## Repo etiquette
55+
56+
- Work on a feature branch and open a PR; never commit directly to `main`.
57+
- Conventional commits: `type(scope): subject` (e.g. `fix(analytics): ...`). The `F-NN` IDs in older
58+
commits refer to a completed validation pass — don't invent new ones.
59+
- `.env` is local and gitignored; copy `.env.example` and use `PFA_`-prefixed settings.

‎PRODUCT.md‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Product
2+
3+
<!-- impeccable:product-schema 1 -->
4+
5+
## Platform
6+
7+
web
8+
9+
## Stack
10+
11+
delegated: plain HTML/CSS/vanilla JavaScript served by the existing FastAPI app; no frontend framework added for a local-first dashboard
12+
13+
## Users
14+
15+
One person reviewing their own private financial activity on a local machine.
16+
17+
## Product Purpose
18+
19+
PFA helps a person understand and improve their financial life over time through evidence-backed
20+
analysis, deterministic calculations, scenarios, and concise explanations.
21+
22+
## Positioning
23+
24+
Financial facts come from deterministic Python/SQLite services. The local model interprets those
25+
facts but is never the source of totals, balances, rates, or projections.
26+
27+
## Operating Context
28+
29+
The user imports synthetic or personal bank CSVs, reviews monthly changes, checks budgets and goals,
30+
asks natural-language questions, and simulates decisions. The application runs locally with SQLite
31+
and optional Ollama.
32+
33+
## Capabilities and Constraints
34+
35+
Transactions, accounts, budgets, goals, imports, analytics, scenarios, recurring-payment evidence,
36+
anomaly/trend signals, a CLI, and a FastAPI API are implemented. Initial behavior is read-only and
37+
advisory. No cloud APIs, money movement, brokerage execution, or hosted telemetry.
38+
39+
## Brand Commitments
40+
41+
The product name is PFA (Personal Finance Agent). Voice is concise, plain-language, evidence-backed,
42+
transparent about assumptions, and respectful of the user's decision authority.
43+
44+
## Evidence on Hand
45+
46+
`data/demo_transactions.csv` is synthetic demonstration data covering June–August 2026. No real
47+
financial claims, testimonials, or commercial proof should be fabricated.
48+
49+
## Product Principles
50+
51+
- Deterministic calculations outrank model guesses.
52+
- Local privacy is the default.
53+
- Show evidence and assumptions beside recommendations.
54+
- Keep the user in control; initial features are read-only.
55+
- Prefer small, explainable workflows over speculative infrastructure.
56+
57+
## Accessibility & Inclusion
58+
59+
The dashboard must support keyboard navigation, visible focus, semantic HTML, responsive layouts,
60+
adequate contrast, reduced-motion preferences, and text alternatives for status indicators.
61+
62+
## Assumptions
63+
64+
The UI surface, visual direction, and frontend implementation path are inferred because no visual
65+
brief or question mechanism was available in this session. Revisit these if the user supplies a
66+
different dashboard scope, brand direction, or frontend constraint.

0 commit comments

Comments
 (0)