🏛️

Solution Architecture & System Design

Institutional Fiduciary Autonomous Engine • 100% On-Device Privacy

🛡️ System Architecture Overview

Air-Gapped Privacy Deterministic Math Core Local LLM (Metal GPU)

The Personal Fiduciary Agent is an institutional-grade financial intelligence engine engineered for Apple Silicon macOS. Unlike traditional fintech apps that stream confidential banking data to cloud servers or hallucinate arithmetic using generic LLMs, this harness enforces a strict Three-Tier Separation Architecture: 1. Air-Gapped Data Ingestion with automatic PII masking, 2. Zero-Hallucination Deterministic Python Core for all calculations (runway, tax traps, bills), and 3. Grounded Local AI Reasoning running on Apple Silicon Metal GPU with real-time Grounding Guardrails.

Full Solution Architecture Topology

Complete end-to-end data pipelines from bank statements to local AI inference

Interactive Vector Diagram
flowchart TB
    subgraph INGESTION["1. INGESTION & PRIVACY LAYER"]
        PDF["UK Bank PDF Statements
(NatWest, Barclays, HSBC)"] --> PDFP["On-Device PDF Parser
(pypdf in-memory extraction)"] CSV["Bank CSV Exports
(Revolut, Chase, Lloyds)"] --> CSVP["CSV Banking Importer"] TL["TrueLayer Open Banking API
(Read-Only Account Token)"] --> TLP["TrueLayer Sync Client"] WISE["Wise Multi-Currency API
(Direct Read-Only Token)"] --> WCL["Wise Sync Client"] PDFP --> PII["PII Privacy Shield
• Sort Code: ••-••-XX
• Account: ••••XXXX"] CSVP --> PII TLP --> PII WCL --> PII end subgraph STORAGE["2. LOCAL AIR-GAPPED STORAGE"] PII --> DB[("SQLite Engine (data/financial.db)
• accounts
• transactions
• recurring_bills
• net_worth_snapshots
• llm_traces
• oauth_tokens (90d Refresh Tokens)
• credit_profile (CRA Scores & Electoral Roll)")] end subgraph CORE["3. DETERMINISTIC PYTHON CORE (ZERO MATH HALLUCINATION)"] DB --> TP["Transaction Profiler
• 30-Day Living Burn Rate
• Exact Liquid Runway Days
• Inbound Funding Patterns"] DB --> WD["Financial Watchdog
• Subscription Detection
• Stealth Price Hikes
• Duplicate Charge Audits"] DB --> TAX["UK Tax Optimizer
• 60% Marginal Tax Trap
• PSA Interest Drag
• SIPP Pension Sacrifice"] DB --> SWEEP["Smart Sweeper Engine
• 1st-of-Month Float Plan
• Consumer Rights 2015 Notices"] DB --> NW["Whole Balance Sheet
• Multi-Asset Net Worth
• Class Allocation (Cash/ISA/Pots)"] DB --> CREDIT["Credit & Affordability Engine
• FCA MCOB 11 Cash Flow (UMI/DTI)
• BNPL & Returned DD Radar
• 4.5x Mortgage Capacity & Stress
• 0–100 Readiness Score"] end subgraph AI["4. LOCAL OLLAMA REASONING & GUARDRAIL PIPELINE (100% PRIVATE)"] TP --> CTX["Financial Context Aggregator"] WD --> CTX TAX --> CTX SWEEP --> CTX NW --> CTX CREDIT --> CTX WEB["Multi-Tier Web Knowledge Engine
• Tier 1: Statutory HMRC Schedules
• Tier 2: Google Search / Serper API
• Tier 3: Live UK Organic Web Search"] --> CTX VRAG["Local Semantic Vector RAG
• Statutory HMRC Rules (ISA, SIPP, CGT)
• FCA MCOB 11 Guidelines
• Cosine Similarity (TF-IDF weighted)"] --> CTX WEB --> TOOL_OBS["Tool Execution Tracker
• Latency (ms), URL/Source, Payload
• tools_used_json stored in trace"] VRAG --> TOOL_OBS TOOL_OBS --> TRACE CTX --> PROMPT["Grounded Dynamic Prompt
(Pruned context: ~300 tokens)"] DB --> TXR["Itemised Transaction Retriever
• Bank filter (revolut / wise / natwest)
• 'last N' count detection
• Numbered newest-first rows"] TXR --> PROMPT PROMPT --> PII_ANON["Reversible PII Anonymizer
• Sort Codes: [SORT_CODE_1]
• Account Nums: [ACCOUNT_NUM_1]
• Lossless Roundtrip Deanonymization"] PII_ANON --> LLM_CLIENT["Unified LLM Client"] LLM_CLIENT -->|"Primary Default (100% Offline)"| OLLAMA["Ollama Local Engine (:11434)
(qwen3.5:4b / llama3.2 on Metal GPU)
• think: false (Sub-second)
• keep_alive: 0 (Zero RAM leak)"] LLM_CLIENT -.->|"Alternative Local"| LMSTUDIO["LM Studio Local Endpoint (:1234)
(Meta-Llama-3.1-8B)"] LLM_CLIENT -.->|"Enterprise AI Gateway (Opt-in)"| GATEWAY["AI Gateway / LiteLLM Proxy (:4000)
(OpenAI-compatible router & cache)"] LLM_CLIENT -.->|"Dormant Adapter (Opt-in only)"| GEMINI["Google Gemini Cloud API
(Zero egress by default)"] OLLAMA --> REACT["Autonomous ReAct Agent Engine
• Thought → Action → Observation
• Dynamic MCP Tool Calling
• Max 4 steps safety ceiling"] REACT --> PREFLIGHT["Pre-Flight Fiduciary Evaluator & Self-Correction Gate
• Extracts all £, %, days
• Audits FCA Consumer Duty & Invariants
• Auto-Repairs Hallucinations Pre-Delivery (<2ms)"] LMSTUDIO -.-> PREFLIGHT GATEWAY -.-> PREFLIGHT GEMINI -.-> PREFLIGHT PREFLIGHT --> TRACE["Observability Logger
• Latency (ms)
• Grounding Score
• llm_traces Table"] TRACE -.->|"On demand: ./f judge"| JUDGE["Layer 2: LLM-as-a-Judge
(Ollama :11434 with think: false)
• Faithfulness / Relevance / Fiduciary
• Auto-unloaded after evaluation"] JUDGE -.->|"judge_result_json"| TRACE TRACE -.->|"./f eval"| BENCHMARK["Enterprise EVAL Benchmark Suite
• 6-Dimension Golden Dataset
• Grade A+ Production Gate"] end subgraph INTERFACES["5. CLIENT PRESENTATION INTERFACES"] PREFLIGHT --> FASTAPI["FastAPI Local Server (127.0.0.1:8080)"] TRACE --> FASTAPI FASTAPI --> MACAPP["Native macOS App
(/Applications/Fiduciary.app)"] FASTAPI --> BROWSER["Local Web Dashboard
(http://localhost:8080)
• Live Transactions tab
• Credit & Borrowing tab
• Traces & EVAL modal"] FASTAPI --> CLI["Interactive Terminal CLI
(./f eval, ./f react, ./f rag, ./f copilot --react, ./f tx, ./f judge)"] end style INGESTION fill:#064e3b,stroke:#059669,stroke-width:2px,color:#ecfdf5 style STORAGE fill:#1e293b,stroke:#475569,stroke-width:2px,color:#f8fafc style CORE fill:#1e1b4b,stroke:#6366f1,stroke-width:2px,color:#e0e7ff style AI fill:#581c87,stroke:#a855f7,stroke-width:2px,color:#faf5ff style INTERFACES fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#f0f9ff
1. Complete Privacy Air-Gap

Confidential PDF statements and transaction records are parsed and stored locally. Zero raw financial data ever traverses the internet.

2. Deterministic Accuracy

The AI never calculates balances or taxes. Pure Python mathematical algorithms calculate verified figures and inject them as hard facts.

3. Continuous Guardrails

The Grounding Auditor scans every generated response, verifying that every financial citation matches ground truth.

Technical Privacy & Air-Gap Verification

You can physically verify that zero financial data leaves your laptop using two standard macOS technical procedures:

1. Offline Air-Gap Test (Airplane Mode)

Turn off Wi-Fi on your Mac completely. Run:

./f copilot "What is my liquid balance?"

The agent answers immediately via local Ollama on Metal GPU with zero network connectivity.

2. Network Socket Inspection

Check active TCP connections from Python and local runners:

lsof -iTCP -sTCP:ESTABLISHED -n -P | grep -E "python|8080|11434|1234"

All connections are local loopbacks (127.0.0.1). Zero outbound external packets.