Building a Read-Only AI Financial Assistant: Key Design Points and Security Boundaries
This article explains how to build a read-only AI financial assistant that aggregates bank transaction data and answers spending questions in conversation. It covers read-only permission design, safe handling of natural language queries, rules for unifying data across multiple accounts, thresholds for duplicate-charge and subscription price alerts, chart selection, and compliance boundaries. It also identifies the security controls and the results that still need manual review.
Large language models can handle many natural language tasks, and personal finance is one practical use case. Users often switch between several banking apps and check statements by hand, which makes it easy to miss small, repeated charges. A read-only financial assistant can consolidate this data and answer questions such as “Where did my money go this month?” through conversation. The sections below cover the key considerations at each layer of the system.
1. Configuring Read-Only Permissions
The system must first define what it can and cannot do. The recommended permission configuration is as follows:
| Item | Key Configuration |
|---|---|
| Authorization | Use OAuth 2.0 and request only the scopes needed to read transaction records and account balances |
| API allowlist | Allow only query endpoints. Fund transfers, account management, and investment APIs are excluded entirely. |
| Gateway control | Reject non-query requests at the gateway layer and record audit logs |
| Tenant isolation | Attach a tenant ID to every record and enforce it as a condition in every query |
| Encrypted storage | Encrypt sensitive fields with a key management service, and store keys separately from the data |
| Audit logging | Record user ID, timestamp, endpoint, query scope, and number of returned rows. Do not write full card numbers or identity information into logs. |
Read-only design significantly reduces the risk of fund operations, but it cannot guarantee absolute security. Credential leaks, misconfigured permissions, and application vulnerabilities can still expose data. Security testing is required before launch.
2. Handling Natural Language Queries Safely
User questions are converted into data queries. This is the highest-risk step, so the system must follow these rules:
- Intent allowlist: The model can output only predefined actions, such as
spending_summaryandcategory_breakdown. Unknown actions are rejected. - Parameterized queries: Parameters such as time range and account ID are passed as bound variables. Strings are never concatenated into SQL, which prevents SQL injection.
- Read-only database account: Queries run under an account that has only SELECT privileges and cannot execute write or schema-change statements.
- Ownership check: Before each query, the system confirms that the accounts belong to the currently logged-in user.
- Result limits: Limit the number of returned rows and the scope of amount totals. When a result exceeds the limit, ask the user to narrow the query.
The pseudocode below shows how these rules work together:
ALLOWED_ACTIONS = {"spending_summary", "category_breakdown"}def process_financial_query(user_id, query_text):intent = nlu_engine.parse(query_text)if intent.action not in ALLOWED_ACTIONS:return "This type of request is not supported yet."accounts = get_linked_accounts(user_id, read_only=True) # Returns only accounts owned by this userif not accounts:return "No linked accounts found."transactions = fetch_transactions( # Uses parameterized queries internallyaccount_ids=[a.id for a in accounts],start=intent.time_range.start,end=intent.time_range.end,max_rows=5000,)categorized = aggregate_by_category(transactions)prompt = build_prompt(query_text, categorized)return llm.generate_response(prompt)
The LLM receives only aggregated results and never accesses the database directly. RAG retrieval is suitable for finding rule explanations and term definitions, but it is not an access control mechanism. Real isolation depends on tenant validation and auditing in the data access layer.
3. Unifying Data Across Multiple Accounts
Transaction formats vary widely between banks, so the following must be standardized before aggregation:
- Currency: Keep the original currency, record the converted amount, and state the date of the exchange rate used.
- Time zone: Split periods such as “this month” and “this week” according to the user’s local time zone.
- Category mapping: Map each bank’s transaction descriptions to a unified category set, such as dining, transportation, and subscriptions. Transactions that cannot be classified go into “Other,” and users can correct them manually.
- Deduplication key: A transfer between two accounts appears once on each card. The system should identify these records using fields such as time, amount, and counterparty account, and count each transfer only once.
4. Setting Thresholds for Anomalous Charge Alerts
Proactive alerts are more useful than passive Q&A. The rules below are a starting point. Thresholds should be calibrated against each user’s actual data:
- Rapid repeated charges: Trigger an alert when the same merchant charges the account three or more times within 10 minutes.
- Subscription price increase: Trigger an alert when a charge from the same merchant exceeds the average of the previous three billing cycles by more than 10%.
- Duplicate charges: Flag records with the same merchant, amount, date, and card suffix as candidate duplicates.
- False positive handling: Alerts are notifications only and never trigger automatic actions. When a user marks a charge as “normal,” the system lowers the priority of that type of rule for that merchant and keeps the record for review.
These rules cover a limited set of cases. Statistical methods can supplement them. For example, the system can measure how far an amount deviates from its sliding average to find anomalies that the rules miss.
5. Choosing Charts and Handling Insufficient Data
| Need | Recommended Chart | Notes |
|---|---|---|
| Weekly spending changes | Line chart | Shows trends over time |
| Share by category | Pie chart | Easy to read with six categories or fewer. Switch to a bar chart when there are more. |
| Amount comparison across categories | Bar chart | Compares absolute amounts across categories |
| Upcoming bills | Calendar view | Shows amounts and repayment status by date |
When no data exists for a period, the page displays “No transactions in this period” and does not generate an empty chart. When the data volume is large, aggregate by day or week first. When the data exceeds the system limit, prompt the user to narrow the time range. Amounts always display their currency and number of decimal places.
When a user changes the chart type during a conversation, the front end updates only the display parameters. The back end re-queries the data using allowlisted parameters.
6. Result Verification and Compliance Boundaries
The assistant’s responses should stay within factual data. Specifically:
- Do not issue credit cards, provide loans, or recommend investment products.
- Do not insert commercial promotions or recommendation links.
- For terms such as annual percentage rate (APR), first give a plain-language explanation. Then calculate the total interest for the current billing cycle using the account’s actual data.
- Make key amounts expandable into transaction details so users can verify them one by one.
- Add a reminder to every summary conclusion: important amounts should be confirmed against the official bank statement.
- Escalate to manual review when the summary differs from the bank statement by more than a set percentage, or when a single anomalous amount exceeds a threshold the user has set.
Conclusion
A read-only financial assistant turns scattered bills into data that users can query. It also alerts them promptly when duplicate charges appear or subscription prices quietly rise. When building one, start with security controls: minimal permissions, query allowlists, consistent data standards, and a clear manual review process. These measures cannot eliminate every risk, but they make the system’s behavior predictable and auditable.
