MoneyMap
MoneyMap turns raw bank statements — PDFs and text exports, with no bank API behind them — into financial numbers and advice a person can actually trust: reconciled transactions, correct spending vs income vs transfers, budgets, anomaly flags, and a grounded AI advisory layer.
It was built and validated end-to-end on a real-world archive of household statements: 59 statements, 5 accounts at 3 banks, 1,754 transactions across two years. The design question it answers is not “how do I add AI to a budgeting app” but which steps genuinely need a language model — and what has to be true before a model’s output is allowed to count.
The problem
Section titled “The problem”“Build a budgeting app” sounds solved. In this setting it wasn’t, and the reasons are the interesting part:
- No data pipe. Aggregation services don’t cover the banks involved, so the only input is the monthly statement each bank lets you download — a PDF, sometimes a text export. Any solution starts from documents, not an API.
- Every bank is different. Different layouts, one or two date columns, running balances present or absent, credits marked “CR”, “Cr” or not at all — and one card statement that prints two similar closing totals, where only one is the real balance.
- Money moves between accounts constantly. Counted naively, a salary moved to savings, a credit card paid from checking, a transfer to a broker are all “spending” — the same money counted twice. In this corpus, two years of savings and investment transfers initially read as expenses: the headline number, “how much did the household spend?”, was wrong in the most important direction.
- Statements arrive at different times. Until every account’s statement for a month is uploaded, every month-over-month comparison and budget check silently lies.
- Review fatigue. 1,700+ transactions can’t be hand-labeled every month, but fully automatic categorization is wrong often enough to matter. The system has to decide which ones a person must see.
The trust problem is harder than the parsing problem:
- LLMs transcribing financial documents make confident, plausible mistakes — a flipped sign, the wrong balance field, in one observed run an entirely invented statement.
- LLM “confidence” is usually a vibe: a model that says it is 90% sure has to be measured before that number can decide whether a human looks at a transaction.
- Raw transaction descriptions carry names, IBANs and card numbers; sending them to a hosted model is not acceptable by default.
- An AI adviser that cites a figure the data doesn’t support is worse than no adviser.
My role
Section titled “My role”Sole designer and builder — architecture, pipeline, model routing, web UI and evaluation. Delivered in about two weeks: 26 commits, ~14k lines of Python, ~7k lines of TypeScript, 700 automated tests.
The system was built in pair-programming sessions with Claude Code under an explicit contract: the coding agent stops and asks before any architectural decision — schema fields, what happens when reconciliation fails, whether the orchestrator may call a model, how a missing month is treated. Every such decision is recorded with its date and supporting data in a design log, so the reasoning behind each choice below can be traced.
Approach
Section titled “Approach”Five principles shaped every decision:
- Deterministic by default, AI by exception. Each step asks: does this need judgment over messy language, or is it arithmetic, matching or rules? Only the first gets a model.
- Every AI output passes an independent check before it counts. Extracted statements must reproduce their own balances; categories are routed by calibrated confidence; every number an explanation cites must match the data it was given.
- Measure, then design. Thresholds, confidence cut-offs and anomaly windows were set from measured data, not assumptions. Proposed signals that didn’t add measurable information were dropped.
- Humans decide the ambiguous cases, and the system learns from each decision. A correction applies immediately to every past and future transaction from that merchant, so the same question is never asked twice.
- Be honest about incomplete data. The system tracks which days each account’s statements cover and labels partial months instead of drawing conclusions from them.
Architecture
Section titled “Architecture”flowchart LR
U[User uploads a statement<br/>and picks the account] --> API[FastAPI]
API --> ORCH
subgraph LOCAL["Runs on the user's machine: raw data never leaves"]
ORCH[Deterministic orchestrator<br/>fixed stage order, no model calls]
ORCH --> ING[Ingestion<br/>parsers + reconciliation]
ORCH --> TR[Transfer detection]
ORCH --> INC[Income classification]
ORCH --> CAT[Categorization]
ORCH --> ANO[Anomaly detection]
ORCH --> BUD[Budget tracking]
ING -. PDF fallback .-> OLL[(Local LLM<br/>Ollama)]
CAT --> OLL
ING & TR & INC & CAT & ANO & BUD --> DB[(SQLite state store<br/>integer cents, migrations,<br/>activity log)]
end
DB --> RO[Read-only, column-restricted<br/>connection]
RO --> PKT[Bounded data packet<br/>aggregates, no descriptions,<br/>no account numbers]
subgraph CLOUD["Cloud model: sees only the packet"]
PKT --> ADV[Advisory]
PKT --> CHAT[Chat]
end
ADV --> VAL{Grounding validator<br/>every cited number checked}
VAL --> DB
DB --> UI[MoneyMap web UI<br/>review queues, reports,<br/>budgets, dashboard]
CHAT --> UI
Three layers, three trust levels:
- The pipeline runs once per uploaded statement, in a fixed order, with no model in the control flow. Each stage is a small specialist with one job and a plain-data contract.
- The state store is the single source of truth. Money is stored as integer cents and converted through
Decimalat the boundary; schema changes go through numbered migrations; an append-only activity log records every user and system action. - The cloud layer never touches the database. A separate assembler builds a small, pre-computed packet through a connection that SQLite itself prevents from reading sensitive columns. Only that packet is sent to Claude.
Where AI is used — and where it deliberately isn’t
Section titled “Where AI is used — and where it deliberately isn’t”| Capability | Model | Why this choice |
|---|---|---|
| Orchestration | None | Stage order is a business rule, not a judgment. A model deciding control flow would add failure modes and remove auditability. |
| PDF extraction, fixed-column layout | None | The column positions in the PDF settle debit vs credit exactly. The LLM kept misreading one ambiguous row; the layout never does. |
| PDF extraction, varied layouts | Local LLM | Layouts vary too much for maintainable per-bank parsers — trusted only after reconciliation proves the output. |
| Transfer detection | None | Matching amounts, dates and accounts is exact logic. Ambiguous matches go to a person. |
| Income vs refund vs own-account credit | None — rules + memory + human | Too consequential and context-dependent to guess. A remembered decision is applied automatically next time. |
| Spending categorization | Local LLM | Merchant strings like SVCS*Q7X2K9LM — abbreviated, coded, sometimes garbled — need language understanding; calibrated confidence decides how much autonomy it gets. |
| Anomaly detection | None | Z-scores per merchant, duplicate-charge windows, recurring-payment cadence — cheaper, explainable, testable. An LLM fallback was designed but never needed. |
| Budgets and suggestions | None | Sums, averages, comparisons. |
| Explaining alerts, advisory, Q&A | Cloud Claude | Turning computed findings into short, prioritized plain language is where a strong model adds real value. |
Rule of thumb: models read language and write language; code does arithmetic, matching and control flow.
The order matters too: “is this spending at all?” (transfer, income, refund) is answered before “what was it spent on?”. The categorizer only ever sees real spending, so it is never asked to label a salary or a card payment with a shopping category.
Cost stays bounded by the same design: deterministic stages cost nothing, the local model runs on the user’s machine, the cloud model receives a small packet instead of a data dump, and a run with nothing new to explain doesn’t call it at all.
Guardrails: what makes a model output safe to trust
Section titled “Guardrails: what makes a model output safe to trust”Reconciliation — the correctness gate for extraction
Section titled “Reconciliation — the correctness gate for extraction”Every parsed statement must reproduce its own printed identity: opening + transactions = closing. If it doesn’t, the statement is blocked and nothing downstream runs. Of the 59 statements in the corpus, 51 passed and 8 were correctly blocked — including a PDF that was missing 5 of its 11 pages.
This is what lets the LLM be flexible: an independent, deterministic check decides whether its output is accepted. The known gap is documented too — a statement that prints no balances can’t be reconciled, which is exactly how the one fully hallucinated statement slipped through. It was caught during labeling, not by the system, and that limit is now explicit.
Confidence measured, not asked for
Section titled “Confidence measured, not asked for”Categorization confidence comes from the local model’s token log-probabilities for the chosen category, not from asking the model how sure it is. That number is calibrated against hand-labeled transactions and routes each transaction to one of three tiers:
flowchart LR
T[Spending transaction] --> M{Merchant corrected<br/>by the user before?}
M -- yes --> AC1[Auto-commit<br/>memory wins]
M -- no --> LLM[Local LLM: category<br/>+ logprob confidence]
LLM --> C{Calibrated confidence}
C -- ">= 0.95" --> AC2[Auto-commit]
C -- "0.45 - 0.95" --> AF[Audit flag<br/>committed, open to spot-checks]
C -- "<= 0.45" --> H[Hold<br/>waits for a person]
H --> R[Person approves or corrects]
AF --> R
R --> MEM[Merchant memory updated]
MEM --> P[Applied to every matching<br/>past transaction immediately]
Measured, not assumed:
- First calibration (118 labeled rows): 67.8% accuracy against 70.0% average claimed confidence — the model was well calibrated. Accuracy rose steeply across confidence bins: 13.8% → 58.6% → 96.6% → 100%.
- Second calibration (654 labeled rows, stratified): 73.4% accuracy against 72.8% claimed. The cut-offs tightened — from 0.86/0.39 to 0.95/0.45 — because the smaller sample had overstated how trustworthy high confidence was. Re-tiering moved 191 transactions, all toward more caution.
- Two proposed signals were tested and dropped. A “string legibility” heuristic would have caught 1 of 5 confident-but-wrong cases — the real cause was taxonomy ambiguity, not cryptic text. The gap between primary and alternative categories carried no information beyond confidence. Neither was built.
On the full corpus, 76% of spending was committed automatically, 14% committed with an audit flag, 10% held for a person. The hold queue is empty.
Grounded generation — the model explains, code verifies
Section titled “Grounded generation — the model explains, code verifies”Advisory runs in two stages. First, deterministic code computes everything: which alerts are new, their priority, how often a budget was exceeded, the 75th-percentile month, the top merchants behind an overspend, a suggested budget. Then Claude writes the explanation as structured JSON, and a validator checks every insight:
- it must cite a real item from the packet;
- every cited number must match that item’s value within 1%;
- every cited number must actually appear in the text;
- headlines may not contain numbers;
- priority is never taken from the model.
Insights that fail are dropped with a visible “couldn’t verify” note.
Chat takes a different trade-off: free-form answers can’t be validated field by field, so its safeguard is retrieval — questions are matched against the real merchant list, the real category taxonomy and a hand-written date parser, totals are computed in SQL, and any answer drawing on more than 200 rows is aggregated rather than dumped.
Privacy as a guarantee, not a policy
Section titled “Privacy as a guarantee, not a policy”- Anything touching raw data — extraction, categorization — runs on a local model through Ollama; model routing is one table, overridable per feature.
- The two cloud features read through a SQLite connection opened read-only, with an authorizer that denies transaction descriptions, account references, model reasoning and the whole accounts table. A query touching a denied column fails outright; it doesn’t return NULL.
- What the cloud model does see: category totals, merchant names and figures computed by code.
“The prompt says don’t send card numbers” is a policy. A connection that cannot read them is a guarantee.
A human-in-the-loop that compounds
Section titled “A human-in-the-loop that compounds”Approving or correcting a category writes a merchant memory entry, applied at once to every other transaction from that merchant — including spelling variants like GREENFIELD MKT / GREENFIELD MARKET LTD. Transactions a person corrected individually are never overwritten.
The model is still called on memory hits, so its accuracy can be re-measured for the next calibration. Today 169 learned rules categorize 512 transactions, and review effort shrinks over time by design.
Flow-type modeling did the same for correctness: classifying every transaction as spending, income or transfer (savings is derived — income minus spending — never categorized) removed 32 items from the review queue on day one and made the headline metrics trustworthy.
Results
Section titled “Results”| Measure | Value |
|---|---|
| Statements processed | 59 (51 reconciled exactly, 8 correctly blocked) |
| Transactions | 1,754 across 5 accounts at 3 banks, over a two-year period |
| Categorization calibration | 73.4% accuracy vs 72.8% claimed confidence, 654 labeled rows |
| Spending auto-committed | 76% (14% audit flag, 10% held; hold queue empty) |
| Categorized from learned memory | 512 transactions via 169 merchant rules |
| Anomalies raised / reviewed | 88 / 81 (40 confirmed, 41 dismissed) |
| Duplicate-charge window | 3 days, chosen from the data: 0–3 days flagged glitches, 4–7 mostly routine repeats |
| Automated tests | 700 — in-memory SQLite, no network, no model calls |
What failed and what it taught
Section titled “What failed and what it taught”| Failure | Response |
|---|---|
| LLM invented an entire statement (no balances printed) | Caught during labeling; documented as the known limit of the reconciliation gate |
| LLM faked a running balance that “confirmed” its own flipped sign | Replaced the LLM for that bank with a parser reading columns by x-coordinate — the information was in the PDF layout all along |
| Hand-typed labels silently failing an exact-string join during calibration | Validation pass before scoring (59 rows fixed); backups before editing a file a human is editing |
What I chose not to build (yet)
Section titled “What I chose not to build (yet)”- An LLM fallback for anomalies — deterministic rules explain every current flag; a model would add cost and opacity without a demonstrated gap.
- Goal planning — designed (deterministic projection engine, explanation-only model), paused on a product question, not a technical one.
- Tool access for the cloud model — not needed: every question is answered from a packet that code has already prepared.
What this demonstrates
Section titled “What this demonstrates”| Skill area | Evidence |
|---|---|
| Per-task model selection & routing | Local vs cloud split by data sensitivity; one routing table, overridable per feature |
| Evaluation & calibration | Logprob confidence calibrated twice on labeled data; cut-offs tightened by measurement; two signals dropped after testing |
| Guardrail & trust architecture | Reconciliation gate, three-tier auto-commit routing, grounding validator on every cited number |
| Privacy & trust boundaries | Read-only, authorizer-restricted database connection; local models for raw data; bounded packets |
| Human-in-the-loop design | Merchant memory that compounds — 169 rules covering 512 transactions, review queue empty |
| Domain modeling | Flow types that make “how much did we spend?” correct before any AI is involved |
| Knowing when not to use AI | Deterministic orchestration; a layout parser replacing an LLM; no model in budgets, anomalies or arithmetic |
| Production discipline | 700 model-free tests, numbered migrations, append-only activity log, dated design decisions |