Personal Finance Analysis with an AI Assistant: Practices Under Read-Only Access
This article explains how to build a personal finance analysis feature on a large language model with read-only access to account data. It covers the security boundary and permission design, multi-account data aggregation and normalization, rule-based and model-based expense classification, anomaly detection rules such as duplicate charges and hidden fee increases, interest calculation with its assumptions, dashboard design, result verification through transaction traceability, and compliance requirements. Readers get a general engineering checklist for building this kind of system safely and verifiably.
1. Background and Problem Definition
Personal finance management has long faced two difficult problems. The first is fragmented data. Income and spending records are spread across multiple banks, payment tools, and credit accounts, so users struggle to get a complete view of where their money goes. The second is a high barrier to understanding. Terms such as fees, interest, and installment conditions on statements often confuse ordinary users, and unusual charges are easy to overlook.
Large language models can understand natural language and summarize structured information, which makes them a suitable interpretation layer for financial data. Users can ask questions in everyday language, such as “How much did I spend on dining this month?” The system then converts the question into queries and statistics over account data. However, connecting a general-purpose model directly to financial accounts creates clear security and reliability risks. The core question for this kind of feature is therefore not “What can the model do?” but “Within what permission boundary does it operate, and how are its results verified?”
This article takes a general technical perspective. It discusses the architecture, data processing rules, and engineering practices for such features. It does not cover the implementation details of any specific product.
2. Read-Only Access: Design Principles for the Security Boundary
Read-only access is the first line of defense for this kind of system. The system may read data such as balances and transaction details. It may not initiate transfers, change account settings, or execute investment operations on the user’s behalf. This constraint can be enforced at three levels.
- Authorization: Use an open authorization protocol that follows industry practice, and explicitly limit the granted scope to read-only data. Reject any request for write permissions.
- Service: Deploy the data-reading service separately from any fund-operation service. The AI module’s call chain should contain no interface that can issue fund instructions.
- Auditing: Log every data access request, including the access time, the query type, and the scope of data returned, so that activity can be traced afterward.
The principle of least privilege requires the system to hold only the capabilities needed to complete its task. In a financial context, this means that even if the model’s output is misleading, it cannot cause any financial loss. The risk stays at the level of “wrong information” and does not expand to “wrong money movement.”
Access tokens and keys also require strict management. Credentials should be stored in a dedicated key management service, given an expiration period, and revocable at any time. They must never be written into code or logs.
3. Data Integration and Account Aggregation
Aggregating multiple accounts is the foundation of personal finance analysis. A typical approach is to build a unified data model for each data source and map the fields returned by different institutions to a standard structure. The standard structure includes fields such as account identifier, transaction time, amount, currency, counterparty, description, and category.
Normalization includes the following steps:
- Store amounts as integers in the smallest currency unit to avoid floating-point errors;
- Convert timestamps to a standard format with time zone information;
- Deduplicate transactions, using the institution’s transaction ID or a combination of account, time, amount, and counterparty as the unique key;
- Link refunds to their original transactions so that a refund is not counted again as an expense.
Data synchronization can combine scheduled pulls with incremental updates. Incremental sync relies on cursors or time windows, and it must handle late-arriving data. Banks often post transactions later than the time the purchase occurred. The same transaction may first appear as “pending” and later change to “posted.” The system should update records when their status changes instead of simply appending new ones.
4. Expense Classification and Trend Analysis
Classification is the core of expense analysis. Rule-based classification maintains a mapping from merchant keywords to categories and matches transactions using the merchant category code. Model-based classification handles long-tail merchants that the rules do not cover. It can output a category with a confidence score, and results with low confidence are passed to the user for confirmation.
In practice, a two-layer structure works well. Rules first classify high-frequency merchants quickly, and the model then handles the remaining entries. Users should be able to correct classification results, and those corrections can serve as input for improving the rules.
The following pseudocode shows the basic structure of the classification flow:
function categorize(transaction):rule_hit = match_merchant_rules(transaction.merchant_name)if rule_hit is not null:return { category: rule_hit, source: "rule", confidence: 1.0 }prediction = classify_with_model(transaction.description, transaction.amount)if prediction.confidence >= THRESHOLD:return { category: prediction.category, source: "model", confidence: prediction.confidence }return { category: "pending confirmation", source: "pending", confidence: prediction.confidence }
Trend analysis depends on time aggregation. Summing spending by category per week or month and comparing it with the same period in previous years can reveal abnormal fluctuations. Installment payments, annual insurance premiums, and quarterly bills make monthly data uneven. When computing statistics, the system should distinguish between cash-flow amounts (when money leaves the account) and the period a purchase belongs to. This prevents a one-time large payment from being mistaken for a change in spending habits.
5. Designing Rules to Detect Abnormal Charges
The value of anomaly detection lies in surfacing problems that users are likely to miss. Common detection rules include the following types.
- Duplicate charges: two or more debits from the same merchant with similar amounts within a short time window.
- Abnormal fees: a fee that exceeds the usual range relative to the transaction amount, or a fee category that appears without a corresponding service.
- Gradual price increases: the monthly amount of a subscription service rises slightly but steadily over a year. Each increase is small, but the cumulative change is significant.
- Unused recurring charges: a periodic charge with no matching usage record over a long period.
Example pseudocode:
function detect_duplicate_charges(transactions, window_hours = 24):alerts = []sorted_tx = sort_by_time(transactions)for i in range(len(sorted_tx)):for j in range(i + 1, len(sorted_tx)):a = sorted_tx[i]b = sorted_tx[j]if hours_between(a.time, b.time) > window_hours:breakif a.merchant == b.merchant and a.amount == b.amount:alerts.append({ pair: [a.id, b.id], reason: "suspected duplicate charge" })return alerts
Rule thresholds should be calibrated against the distribution of each user’s data, and users should be able to add exceptions to an allowlist. For example, two identical charges from the same merchant may be two legitimate orders. The system should flag such cases as “suspected” and should not state that they are errors.
6. Explaining Terms and Calculating Interest
Specialized financial terms are a major obstacle for ordinary users. Before showing calculation results, the system should explain the key concepts. Take the annual interest rate as an example. It represents the interest cost over one year as a percentage of the principal. For daily calculation, the daily rate is typically obtained by dividing the annual rate by 365.
The general formula for estimating interest is:
Interest = Average daily balance × Annual interest rate ÷ 365 × Number of days
For example, with an average daily balance of 10,000 yuan (CNY), an annual interest rate of 20%, and 30 days of interest, the estimated interest is:
10,000 × 0.20 ÷ 365 × 30 ≈ 164.38 yuan
Calculation rules differ across institutions. Some charge interest daily and others monthly. Some offer a grace period, and the compounding method may vary. The system should label the assumptions behind any estimate and remind users that the statement is the authoritative source.
When calculating total interest, the system should first identify interest-related entries in the transaction records and then compare them with the estimate. If the two differ significantly, the system should prompt the user to check, rather than defaulting to the estimated value.
7. Visualization and Custom Dashboards
The goal of visualization is to reduce the effort needed to understand the data. Common formats include weekly spending bar charts, category share pie charts, a bill due-date calendar, and a monthly income and expense trend line. Dashboards should let users define their own metrics, such as a budget line for a specific category, an alert threshold for large transactions, or a summary view for a fixed period.
Generated charts and dashboard configurations should be adjustable at any time and saved as editable parameters, not as one-time static images. This way, when a user changes classification rules or the time range, the views update accordingly.
Design considerations include the following:
- Display numbers with necessary precision only, so that the output does not suggest false exactness;
- Choose colors and legends that remain readable for users with color vision differences;
- Show a missing-data marker for periods with insufficient data, rather than plotting zeros that mislead readers.
8. Result Reliability and Verification
AI-generated financial conclusions can be wrong, so the system needs verification mechanisms. The core principle is that every conclusion should be traceable to the original data.
The implementation includes the following measures:
- Transaction traceability: When a user asks for an explanation of a statistic, the system can list all transactions behind that result, including date, amount, merchant, and category.
- Transparent calculation: Totals, averages, and interest calculations should display the formula and input values so that users can verify them by hand.
- Uncertainty labels: Results with low classification confidence, incomplete data, or sync delays should be clearly flagged.
- External reconciliation: Important amounts should be checked against the bank’s official statements or the in-app bill. The system’s output should not replace formal records.
For testing, build a sample set that includes duplicate charges, refunds, cross-month installments, and multi-currency transactions. Check whether the statistical results match manual calculations. Update the test set regularly to cover new merchant formats and billing formats.
9. Neutrality and Scope Statements
A financial analysis tool must remain objective. The system should not recommend specific financial products, and its explanations or suggestions should not include advertising or sponsored content. If the feature does not provide investment advice, the interface and documentation should say so clearly. When a user asks an investment question, the system should state its limits and suggest consulting a licensed financial professional.
In addition, users should know how their data will be used before they grant access. The system should explain which data is read, what it is used for, how long it is retained, and how the user can revoke access. These explanations should appear in plain language on the authorization screen, not buried in long terms of service.
10. Engineering Recommendations
Based on the analysis above, the following checklist can guide implementation:
- Permissions: read-only scope, minimal authorization, centralized credential management, and regular credential rotation;
- Data: a unified data model, idempotent deduplication, stateful updates, and normalization of time zones and currencies;
- Analysis: rules first, model as a supplement, and low-confidence results passed to users for confirmation;
- Rules: configurable thresholds, allowlist support, and cautious wording such as “suspected”;
- Results: transaction traceability, visible calculation steps, and uncertainty labels;
- Monitoring: query logs, alerts for unusual access patterns, and periodic sampling to check analysis accuracy;
- Compliance: clear statements of data use, retention period, and revocation methods, with no embedded promotional content.
Overall, the value of a personal finance analysis feature comes from accuracy, verifiability, and clear boundaries. The technical design should first ensure fund safety and data traceability, and only then pursue deeper analysis and greater convenience in the interaction.
