Intelligent Q&A for Personal Finance Data: Read-Only Architecture and Privacy Protection Practices

    This article explores the architectural design of a read-only intelligent Q&A system for personal financial data. It covers defining system boundaries, implementing a six-layer architecture, enforcing least privilege authorization, ensuring data minimization, and building core analytical capabilities such as cross-account summarization and anomaly detection. The focus is on providing natural language querying convenience while strictly protecting sensitive financial information.

    1. Background: From Multiple App Switching to Unified Q&A

    When managing income and expenses, personal users typically switch back and forth between multiple bank applications, credit card statements, and accounting tools. Each entry point only displays partial data, making it difficult for users to quickly answer cross-account questions like “Where did my money go this month?” or “How much money can I allocate before my next payday?” Large Language Models (LLMs) possess natural language understanding and information summarization capabilities, making them suitable as a unified query entry point. However, financial data is highly sensitive. While these applications bring convenience, they also impose higher requirements on authorization methods, data scope, privacy protection, and result reliability.

    This article uses a “read-only personal finance Q&A” as an example to illustrate the design approach for such systems. The architecture and code in this text are generic illustrations and do not involve implementation details of any specific product.

    2. Defining Boundaries First: Read Data, Do Not Operate Funds

    The first step in engineering design is to clearly define the capability boundaries. A read-only assistant should satisfy three principles:

    1. Query only, no write: It does not initiate transfers, modify account settings, or execute investment operations on behalf of the user.
    2. Explain only, no decision making: The output consists of factual summaries and trend analysis; actions involving funds remain entirely up to the user.
    3. Use only authorized data: Accounts not explicitly selected by the user cannot be read.

    Clearer boundaries make security audits easier to pass and reduce the blast radius of failures. Since the system cannot trigger fund movements, even if the model outputs an error, the worst-case scenario is usually that the user misunderstands a number, rather than funds being misappropriated. This should be explicitly stated in the product documentation and user agreement.

    3. Overall Architecture

    A typical personal finance Q&A system can be divided into six layers:

    • Authorization Layer: Responsible for user identity verification and account authorization, issuing read-only access tokens.
    • Data Ingestion Layer: Pulls account information, balances, and transaction records through compliant data aggregation services or open banking APIs.
    • Standardization Layer: Unifies field formats from different institutions, mapping amounts, currencies, dates, and transaction categories.
    • Analysis Layer: Completes cross-account summarization, category statistics, available balance estimation, and anomaly detection.
    • Interaction Layer: Receives natural language questions, converts them into structured calls to the Analysis Layer, and generates answers and charts.
    • Audit and Governance Layer: Records access logs, manages data retention periods, and handles unbinding and deletion requests.

    The data flow should remain unidirectional. The Authorization Layer does not touch transaction details, and the Interaction Layer does not directly access bank APIs. As a result, permissions for each layer can be tightened individually. If an issue occurs in one layer, the impact can be contained within that layer.

    4. Account Authorization and Least Privilege

    Applications should not ask users for their bank login passwords. A more robust approach is: the user completes identity verification on the bank’s or a trusted aggregator’s page, which then issues a read-only token to the application. The application only stores the token and never touches the credentials themselves.

    The following illustrative code shows how an authorization request implements the principle of least privilege:

    1. authorization_request = {
    2. "user_id": "u_10023",
    3. "scopes": ["accounts:read", "transactions:read"], # No write or transfer permissions
    4. "account_selection": ["acc_checking_01", "acc_card_02"], # Only includes user-selected accounts
    5. "history_days": 730, # Max 2 years of transaction history retained
    6. "token_ttl_seconds": 3600 # Short-lived token, requires re-auth upon expiry
    7. }

    Three points should be noted during implementation. First, the permission scope must be locked at token issuance and should not rely solely on application-layer judgments. Second, account selection requires per-account confirmation by the user, with no default “select all.” Third, tokens must be encrypted at rest and have a validity period. Upon user revocation of authorization, the system should immediately invalidate the token and stop any subsequent data fetching tasks.

    5. Data Scope and Minimized Collection

    Financial Q&A usually does not require all available information. Answering “How much did I spend on dining this month?” only requires the transaction amount, date, and category, not the full account number. Therefore, the Standardization Layer should actively trim fields:

    • Keep only the last four digits of the account number for display; do not store full account numbers in the database.
    • Balances and credit limits should be retained as they are used to calculate available funds.
    • Transaction records are saved within time windows and automatically cleaned up after exceeding the user-defined or business-required period.
    • Memo fields may contain personal information such as names and addresses, and should be desensitized before database insertion.

    Minimized collection has two direct benefits. First, the impact scope is smaller in the event of a data breach. Second, compliance audits are easier to pass because the total volume of data that needs protection is reduced.

    6. Implementation Approach for Core Analytical Capabilities

    6.1 Cross-Account Summarization and Categorization

    Categorization can first use rule-matching for merchant names and transaction codes, followed by a model to handle long-tail cases not covered by the rules. The rule layer provides stable and highly explainable results, making it a suitable baseline.

    1. def summarize_spending(transactions, month):
    2. total = 0
    3. by_category = {}
    4. for tx in transactions:
    5. if tx["month"] != month or tx["amount_cents"] <= 0:
    6. continue # Exclude income and refunds, adjustable based on needs
    7. category = tx.get("category", "Uncategorized")
    8. by_category[category] = by_category.get(category, 0) + tx["amount_cents"]
    9. total += tx["amount_cents"]
    10. return {"total_cents": total, "by_category": by_category}

    Amounts should be represented as integer cents to avoid floating-point errors. In multi-currency scenarios, the exchange rate source and conversion timing must be clearly defined and noted in the answer.

    6.2 Available Balance Estimation

    Questions like “How much money is left before payday?” require combining multiple data sources: current balance, known pending deductions, and expected future income. The basic relationship for estimation is as follows:

    Available Balance = Current Available Balance - Total Planned Spending Before Payday

    Here, planned spending relies on the identification of periodic bills, and the result is an estimate. The answer should explain the basis, for example, “Estimated based on periodic deduction records from the past three months,” rather than providing a seemingly precise single number.

    6.3 Anomaly and Duplicate Charge Detection

    Common anomalies include: duplicate charges from the same merchant within a short period, continually increasing periodic bills, and unprecedented large single purchases. A simple detection approach is to compare the historical amount distribution for the same merchant:

    ```python
    def flag_anomalies(history, new