Read-Only Financial Data Integration and Intelligent Analysis: A Practical Architecture

    This article outlines a practical technical architecture for building a personal finance intelligence system that combines read-only data access, transaction normalization, and natural language Q&A. It covers five key layers—data ingestion, normalization, analysis, Q&A, and presentation—along with security best practices for handling sensitive financial information, a unified transaction data model, and a code example for normalizing heterogeneous transaction records. The design emphasizes deterministic computation for financial calculations and the use of language models only for interpreting user questions and explaining results.

    Problem Background

    The challenge in personal financial management is not calculation—it is data fragmentation. A single individual may hold multiple savings accounts, credit cards, and e-wallets, each with different transaction descriptions, amount formats, and accounting conventions. To answer a simple question like “Where did my money go this month?”, a user often has to open each app individually, export transaction logs, and merge them manually.

    Combining natural language Q&A with financial data is a viable technical direction. Such a system needs to solve three problems: securely fetching transaction data, normalizing heterogeneous data into a unified structure, and answering questions in an explainable manner. This article discusses each of these aspects in turn and provides concrete design considerations for direct reference.

    Overall Architecture

    We recommend splitting the system into five layers, each with a single responsibility for easier testing and substitution.

    • Data Ingestion Layer: Fetches account balances and transaction records through open APIs or aggregation services with read-only permissions.
    • Normalization Layer: Converts fields from different sources into a unified transaction model.
    • Analysis Layer: Performs categorization, statistics, anomaly detection, and interest calculation.
    • Q&A Layer: Maps natural language questions to queries over the analysis layer and organizes responses.
    • Presentation Layer: Generates charts, billing calendars, and custom dashboards.

    The analysis layer should consist of deterministic program logic. Language models are well-suited for understanding questions and explaining results, but monetary calculations must be handled by code, with the computation basis preserved so users can verify the output.

    Permission and Security Design

    Financial data is highly sensitive, and permission design should follow the principle of least privilege.

    1. Read-Only Authorization: The integration only requests permission to query account balances and transaction records; it does not request permission to transfer funds, make payments, or modify account details. This limits the potential impact even if a token is compromised.
    2. Token Management: Authorization tokens should be stored in a key management service, never in code, configuration files, or logs. Tokens should have an expiration period and support user revocation at any time.
    3. Data Minimization: The context needed for Q&A only includes aggregated results and the necessary transaction fields. Card numbers, ID numbers, and other sensitive information should be masked (e.g., retaining only the last four digits) or not stored at all before being written to the database.
    4. Encryption in Transit and at Rest: TLS encryption is used for all data transmission, and static data is stored with encryption.
    5. Audit Logs: Every data access event should record the time, purpose, and requesting party. The logs themselves should not contain sensitive details such as transaction amounts.

    Transaction Data Normalization

    Transaction structures returned by different institutions vary significantly. Some use negative numbers to represent expenses, while others use positive numbers with a direction field. Dates may include time zones, or only have dates without times. Merchant names often include IDs and addresses. Normalization should eliminate these discrepancies before data enters the analysis layer.

    The unified model should include the following fields: account identifier, transaction time (converted to UTC while retaining the original time zone), amount (a signed decimal), currency, raw description, cleaned merchant name, category, whether the transaction is a transfer, and whether it is income.

    Example code:

    1. from dataclasses import dataclass
    2. from datetime import datetime
    3. from decimal import Decimal, ROUND_HALF_UP
    4. import re
    5. @dataclass
    6. class Transaction:
    7. account_id: str
    8. occurred_at: datetime
    9. amount: Decimal # Positive for income, negative for expense
    10. currency: str
    11. raw_desc: str
    12. merchant: str
    13. is_transfer: bool = False
    14. is_income: bool = False
    15. def clean_merchant(raw_desc: str) -> str:
    16. text = raw_desc.upper()
    17. text = re.sub(r"\d{4,}", "", text) # Remove long numeric IDs
    18. text = re.sub(r"[*#_\-]+", " ", text) # Unify delimiters
    19. text = re.sub(r"\s+", " ", text).strip()
    20. return text
    21. def normalize_amount(value: str, is_debit: bool) -> Decimal:
    22. # Assume the amount field is a plain string; parse to Decimal
    23. amount = Decimal(value).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
    24. # If is_debit is True, the transaction is an expense, so make it negative
    25. return -amount if is_debit else amount

    Analysis Layer

    The analysis layer reduces normalized data into structured, queryable dimensions. Categorization rules can be applied based on cleaned merchant names and description keywords, while anomaly detection can be implemented deterministically—for example, flagging transactions that deviate significantly from historical averages or recurring spending patterns. Interest calculations, if applicable, should use the raw transaction timestamps and the account’s rate schedule, executed entirely in code with results stored for audit and review.

    The key principle is that the analysis layer must be reproducible. Every statistical result or category assignment should be traceable back to its input data and processing rules, enabling users to verify or challenge the output.

    Q&A Layer

    The Q&A layer translates user questions into structured queries. For example, the question “How much did I spend on dining last month?” becomes a query over the analysis layer: filter by category, date range, and sign (negative amount), then aggregate. The language model’s role is limited to extracting the user’s intent, mapping it to the query structure, and generating a natural-language response that cites the underlying data and computation path.

    For questions that cannot be answered from the available data or fall outside the scope of the aggregated context, the system should explicitly state the limitation rather than hallucinate an answer. It is also good practice to provide the user with the option to view the raw transactions behind any answer for verification.

    Presentation Layer

    The presentation layer renders the analysis results as charts, billing calendars, or custom dashboards. It should offer drill-down capabilities so users can always navigate from a summary figure to the underlying transactions. Since the Q&A layer and the presentation layer share the same underlying analysis data, users can choose to interact with charts or ask questions, with both views remaining consistent.

    Summary

    A practical personal finance intelligence system should be built around three pillars: read-only secure data access, deterministic transaction normalization and analysis, and explainable natural language interfaces. By keeping computation in deterministic code and using language models only for interpretation, a balance can be struck between correctness and usability. The architecture described here provides a modular, testable foundation that can be extended with additional data sources or analytical capabilities over time.