Build a Read-Only AI Personal Finance Assistant: Design and Practice
This article describes how to design an AI personal finance assistant that answers natural-language questions about spending, unusual charges, and interest while keeping access read-only. It covers permission boundaries, transaction data normalization, deterministic aggregation, anomaly detection, result traceability, and a privacy and security checklist.
1. Background and Problem Definition
Many applications now let users ask about their finances in natural language, for example “Where did my money go this month?”, “Were there any unusual charges recently?”, or “How was this interest charge calculated?” These features make personal finance easier to understand. However, they depend on highly sensitive data, such as account balances and transaction records. Engineers need to answer three questions:
- Which data can the system read, and what must it never do?
- Who generates statistics and calculations, and how is their accuracy ensured?
- When a result is wrong, how can users trace and verify it?
This article proposes a practical design approach built around these three questions.
2. Permission Boundary: Read-Only Is the Baseline
The first principle for financial features is least privilege. The system requests only the ability to read accounts and transaction records. Write operations, such as transfers, payments, and changes to account settings, are excluded at the architecture level. The system does not rely only on prompt instructions telling the model not to move funds.
A permission policy can be expressed as declarative configuration, which makes it easier to review and manage under version control:
{"scopes": ["accounts:read", "transactions:read"],"denied": ["transfers:write", "payments:write", "investments:write"],"token_ttl_minutes": 30,"raw_data_retention_days": 7}
This design has three requirements:
- The authorization scope is set during onboarding. It cannot be expanded at runtime.
- Access tokens have a short lifetime, and users can revoke them at any time.
- The retention period for raw transaction data is explicit. Expired data is deleted automatically, and analysis results are saved on demand.
Read-only access does not eliminate risk. Sensitive information can still leak through logs, caches, or model output, so each later stage needs its own safeguards.
3. Transaction Data Normalization
Transaction records from different sources have very different fields. If the model processes them directly, the definitions of amounts, dates, and categories become inconsistent. A safer approach is to map all records to a unified internal structure before any further calculation:
from dataclasses import dataclassfrom datetime import datefrom decimal import Decimal@dataclass(frozen=True)class Transaction:tx_id: str # Unique transaction ID, used for traceabilityaccount_id: str # Account that the transaction belongs tooccurred_on: date # Transaction dateamount: Decimal # Positive for expenses, negative for incomemerchant: str # Merchant name (can be masked before display)category: str # Normalized spending category
Store amounts as Decimal or as integers in the smallest currency unit to avoid rounding errors from floating-point numbers. Use the account’s local time zone for dates. Otherwise, transactions near midnight can be filed under the wrong month.
Category normalization is another common problem. The same merchant can appear under several descriptions across different channels. You can maintain the mapping with a merchant name rule table and manual review. Keep the original description field so that classification errors are easier to trace.
4. Spending Aggregation: Deterministic Computation Beats Model Inference
“Total this month’s spending by category” is a deterministic task. If a language model performs the arithmetic, it may miss amounts or count them twice. A better division of work is this: code handles filtering and summation, while the model interprets the question, selects tools, and writes the answer in natural language.
from collections import defaultdictfrom decimal import Decimaldef monthly_spending_by_category(txs, year, month):totals = defaultdict(Decimal)for tx in txs:same_month = tx.occurred_on.year == year and tx.occurred_on.month == monthif same_month and tx.amount > 0:totals[tx.category] += tx.amountreturn dict(totals)
Document the calculation rules in the API documentation. Specify whether refunds are included, whether internal transfers count as spending, and how same-name transactions across accounts are deduplicated. If the rules are unclear, the same figure can differ across pages, and users will find it hard to trust the results.
Visualizations such as weekly spending charts, upcoming bill calendars, and custom dashboards should all be generated from the same aggregated results. They should not be calculated separately, so that the numbers stay consistent.
5. Unusual Bill Detection
Anomaly detection is the most valuable part of financial analysis, and it is also the most error-prone. Two common patterns are described below.
5.1 Duplicate Charges
A duplicate charge usually appears as the same amount from the same merchant, occurring several times within a short time window. Detection must exclude normal high-frequency spending, such as buying one coffee at the same café every day. Both the window length and the amount-matching rules should be configurable.
from collections import defaultdictfrom datetime import timedeltadef find_possible_duplicates(txs, window_days=2):groups = defaultdict(list)for tx in sorted(txs, key=lambda t: t.occurred_on):groups[(tx.merchant, tx.amount)].append(tx)alerts = []for items in groups.values():for prev, curr in zip(items, items[1:]):if curr.occurred_on - prev.occurred_on <= timedelta(days=window_days):alerts.append((prev.tx_id, curr.tx_id))return alerts
This function outputs only candidate results. The system should ask the user to verify them rather than draw conclusions. Pre-authorizations, installment payments, and re-charges after refunds can also produce similar records.
5.2 Gradual Subscription Price Increases
The recurring charge for a single service may rise step by step over a year. Each increase is small, so users often do not notice. To detect this, group recurring charges by merchant, compare the first amount with the most recent one, and calculate the percentage increase.
Two points matter during implementation. First, define “recurring” clearly, for example as a monthly or annual charge. Second, set a threshold for small changes caused by exchange rate fluctuations to avoid false alerts.
6. Aggregate Questions and Interest Calculation
Users often ask whether their spending exceeds their income, or how much interest they paid this year. These two types of questions require different handling.
Comparing income with spending requires only two totals. The key is to define what counts as income, including whether transfers in and bonuses are included, and whether they are recurring.
Interest calculation should explain the concept before giving a number. The annual percentage rate (APR) is the yearly interest rate. The actual method may accrue interest daily, compound it monthly, or follow other rules, and these methods differ widely between products. The following code gives a simplified simple-interest estimate that shows only the order of magnitude:
from decimal import Decimaldef estimate_simple_interest(principal, annual_rate, days):"""Simple interest estimate: principal × annual rate × days / 365, rounded to two decimal places."""interest = principal * annual_rate * Decimal(days) / Decimal(365)return interest.quantize(Decimal("0.01"))
The estimate may differ from the amount on the statement. The output should therefore state the assumptions used and advise the user to rely on the statement.
7. Terminology and Cognitive Support
Financial terms are difficult for general users. Before showing data, the system can explain key terms such as “credit limit,” “billing cycle,” and “minimum payment.” These explanations should stay within general definitions. They should not include recommendations, marketing for specific products, or investment advice.
Showing explanations separately from the data helps users distinguish concepts from conclusions and reduces misreading.
8. Traceability and Manual Verification
Any analysis result can be wrong because of missing data, misclassification, or model misinterpretation. A reliable system should:
- Let users expand every aggregated figure into its underlying transaction list, with each
tx_idincluded. - Label estimates with their formula and assumptions.
- Prompt users to check important amounts against their original statements or bank records.
- Record the data scope and calculation version for each query to support later audits.
Traceability determines whether users can correct errors. A figure without supporting detail can be accurate and still fail to earn lasting trust.
9. Privacy and Security Checklist
Before launch, verify each item on the following list:
- Use encrypted transport, encrypt stored data at rest, and manage keys in a dedicated key management service.
- Do not log full account numbers, card numbers, or raw transaction descriptions. Keep only masked fields.
- Limit model input to the minimum data needed for the current question. Do not inject the entire transaction history into the context at once.
- Keep an audit record of all data access, including the access time, the accessing principal, and the access scope.
- Let users view, export, and delete their analysis records, and let them revoke authorization at any time.
- Provide no fund-movement endpoints in external interfaces, and verify this constraint with automated tests.
10. Summary
In financial scenarios, the core of the technical solution is solid deterministic computation, access control, and result traceability. Natural-language interaction then handles understanding and explanation. Read-only permissions limit risk at the architecture level. A standardized data model keeps definitions consistent. Code performs the calculations, the model handles communication, and detailed transaction records and verification steps provide the final safeguard. Following this layered approach, developers can build personal finance analysis that is explainable and verifiable while protecting user privacy.
