LLM-Powered Personal Finance Assistant: Technical Architecture and Security Design
This article explains how to build a personal finance assistant on top of large language models (LLMs), covering its four-layer architecture, the read-only account authorization flow based on open banking, natural-language-to-structured-query processing, cross-account data aggregation, anomaly detection, visualization, and privacy and compliance design. It is written for developers and architects who want to turn scattered financial data into understandable insights while keeping sensitive credentials protected and the system strictly read-only.
1. Requirements and Problem Definition
Traditional personal finance management is limited by two core pain points: scattered data and cognitive barriers. A user’s funds are usually spread across multiple banks, several credit cards, and various payment accounts. Answering seemingly simple questions such as “Where did my money go this month?” or “How much usable balance is left before payday?” often requires switching back and forth between apps and manually consolidating everything, which is both inefficient and error-prone. At the same time, financial concepts such as credit card APR, billing cycles, and minimum payments create additional comprehension hurdles for users who are unfamiliar with them.
Large language models offer a new way to address these problems. They can unify scattered, heterogeneous account data beneath a natural-language interaction layer, letting users ask questions in everyday language while the model handles intent understanding, data retrieval, aggregation, and explanation of results. It is worth stressing that the technical positioning of such a system should be “reading the numbers, not moving the money.” In other words, its core is read-only financial information querying, analysis, and explanation, rather than initiating transfers or managing assets on the user’s behalf. Setting this boundary is both a product-positioning decision and the foundation of security and compliance.
2. Overall Technical Architecture
A typical personal finance assistant can be divided into four layers:
- Access layer: establishes secure connections to external financial data sources and retrieves account metadata and transaction records.
- Data layer: handles data storage, cleansing, classification, and indexing, providing a unified view for subsequent queries.
- Intelligence layer: centered on the large language model, responsible for task orchestration, natural-language understanding, tool invocation, and result generation.
- Interaction and presentation layer: handles multi-turn dialogue, chart rendering, and customizable dashboards.
In a cloud deployment, this architecture is typically assembled from general-purpose building blocks. Taking Baidu AI Cloud as an example, its large language model service can power the intelligence layer, object storage can hold raw and processed data, a database or data warehouse can support structured queries, and log services together with monitoring alerts can ensure observability. The sections below expand on the key design of each layer.
3. Account Access and Identity Authorization
Secure access is the first gate for the entire system. The common industry practice is to introduce an independent financial data aggregation service as an intermediate layer that follows a standardized authorization flow similar to open banking. Its core principle is that user credentials never pass through the assistant itself.
A typical authorization flow is as follows:
- The user initiates a “connect account” request on the assistant side.
- The system generates an authorization link and redirects to the data aggregation platform.
- The user completes identity verification on the aggregation platform and logs in to their bank account directly.
- The bank returns the credential verification result to the aggregation platform, not to the assistant; the assistant can never access the user’s bank password.
- The aggregation platform issues a scoped access token to the assistant that grants read-only permission.
Sample code for the flow:
# 1. Start the connection and get the redirect URLdef start_link(user_id: str) -> str:session = create_session(user_id)return build_redirect_url(session.token) # redirect to the aggregation platform# 2. After the user authorizes with the bank, exchange the access token (never touches the bank password)def exchange_token(public_token: str) -> AccessToken:return aggregator_client.exchange(public_token)# 3. Request read-only scope onlySCOPES = ["accounts.read", "transactions.read"]
The key to this design is separation of responsibilities: identity verification is completed by three parties (the user, the bank, and the aggregation platform), while the assistant only receives the resulting token. This minimizes the exposure surface of sensitive credentials as much as possible.
4. Read-Only Permissions and Security Boundaries
The system should be strictly limited to read-only access. This means that even if a token is misused, it cannot initiate transfers, direct debits, investments, or any other operation that changes the state of funds. The scope of accessible data generally follows the principle of least necessity, for example:
- Bank/institution name, account name, and account type;
- The last four digits of the account number (rather than the full number);
- Current balance and credit limit;
- Transaction records within a certain time window (such as up to two years).
At the code level, a capability whitelist can enforce the boundary of tools the model is allowed to call:
ALLOWED_TOOLS = {"get_accounts", # account list and balances"get_transactions", # transaction details"categorize_spending", # spending categorization# deliberately excludes any transfer or payment tools}
Excluding “not-allowed” capabilities at the tool-registration stage is more reliable than blocking them at runtime. This is a concrete application of the defense-in-depth principle.
5. From Natural Language to Structured Queries
Users ask questions in natural language, and the system needs to translate them into precise queries against the underlying data. The mainstream implementation today uses a “large model + tool calling (Function/Tool Calling)” pattern: the model first recognizes the user’s intent and selects the appropriate data tool, the backend executes the actual data retrieval, and the results are handed back to the model for aggregation and phrasing.
For example, when a user asks “Where did my money go this month?”, the processing pipeline roughly runs as follows:
- Intent recognition: classified as a “monthly spending summary” task.
- Parameter extraction: determine the time range as the current month and identify the required categorization dimension.
- Tool invocation: call
get_transactionsandcategorize_spending. - Result generation: the model converts the structured data into a readable summary, broken down by category.
Sample code:
def answer(user_query: str, user_id: str) -> str:plan = llm.route(user_query) # intent and tool selectionraw = dispatch_tools(plan, user_id) # execute read-only queriesreturn llm.summarize(user_query, raw) # generate a natural-language answer
There is an important engineering constraint here: all numeric calculations should be performed on the backend as much as possible, rather than relying on the model to “do the math” itself. For example, “available balance after deducting planned expenses” should be computed by deterministic code based on real transaction data, with the model only responsible for organizing the language. This avoids numerical hallucination.
6. Cross-Account Data Aggregation and Spending Analysis
In multi-account scenarios, the system needs to normalize data from different sources before aggregating it. This involves three steps:
- Data cleansing: unify amount units, time zones, and date formats, and correctly handle refunds and reversals;
- Category mapping: map raw merchant information to standard categories such as dining, rent, utilities, and transportation;
- Aggregate calculation: aggregate across multiple dimensions such as period, category, and account.
A cleaned monthly analysis result might present the total spending for the month, the proportion of each category, the weight of fixed expenses such as rent, and the available balance after deducting several planned expenses. Using sample data, the system can point out that rent and utilities usually account for more than half of spending, dining comes next, and then give the remaining disposable amount. This “overview first, then breakdown” structure helps users build an understanding of their overall financial situation within seconds.
7. Anomaly Detection
Beyond aggregation, the system should have a degree of anomaly detection capability, commonly including:
- Duplicate charges: multiple transactions with the same amount from the same merchant within a short period;
- Unexpected fees: first-time subscription fees, service charges, or platform fees;
- Rising recurring bills: comparing against historical periods to identify fixed expenses that keep increasing.
This capability is essentially a combination of rules and statistical methods and can be implemented with simple logic:
def detect_duplicates(txns):seen = {}for t in txns:key = (t.merchant, t.amount)if key in seen and is_close_in_time(t, seen[key]):yield f"Possible duplicate charge: {t.merchant} {t.amount}"seen[key] = t
Combining deterministic rules with the LLM’s semantic understanding both ensures the accuracy of alerts and allows anomalies to be explained in plain language, helping users quickly pinpoint problems without reading raw transaction logs.
8. Visualization and Interaction Design
For users unfamiliar with financial terminology, the assistant should act as a “translator”: when explaining a concept such as the annual percentage rate (APR), it first provides a plain-language definition and then calculates the actual impact on the user (such as annual interest expense). The system can also support generating weekly spending charts, a bill calendar, and a customizable financial dashboard, and allow users to adjust statistical parameters at any time, forming a “ask—analyze—visualize—adjust” loop. The key to the interaction design is presenting complex data analysis to users at the lowest possible cognitive cost.
9. Privacy Protection and Compliance Design
Privacy is critical to whether such a system can earn user trust. The following principles are recommended:
- Dedicated data isolation: conversations generated within a dedicated financial interaction area are, by default, not used for model training; interactions outside that area follow the user’s standard privacy settings.
- Transparency and control: users can view their connected accounts at any time and disconnect them with a single click; after disconnecting, the system immediately loses access to the corresponding data.
- Data minimization: only retrieve the fields necessary to complete the analysis, following the principles of least necessity and purpose limitation.
- Verifiable results: because model output may contain errors, users should be clearly reminded that bank official information takes precedence when key amounts are involved.
10. Reliability and Risk Control
Finally, engineering robustness calls for attention to:
- Idempotency and retries: data-fetching interfaces should be idempotent to avoid data corruption caused by duplicate requests.
- Credential security: access tokens should be stored encrypted, rotated regularly, and support quick revocation.
- Observability: unified logging and monitoring alerts should track the latency, failure rate, and abnormal invocations along the query pipeline.
- Permission auditing: log an audit record for every data access to facilitate traceability and compliance checks.
In summary, the technical value of an LLM-driven personal finance assistant does not lie in “replacing the user’s decision-making,” but in converting scattered financial data into insights that users can understand and use, in a safe, read-only, and explainable way. Upholding least privilege, separation of responsibilities, and data minimization in architecture, and natural-language interaction and verifiable results in experience design, is what truly balances usability with security and compliance, and builds an intelligent financial analysis system that users can trust.
