Sovereign Intelligence: The Complete 25,000 Word Blueprint (Download)
This 12-part series has walked through the full architecture of Pocket Analyst—the local-first financial AI that keeps your data on your device and sends only a sanitized snapshot to the cloud. Here is the one-page recap and where to get the full blueprint.
Architecture recap
- Data Chasm — Raw ledger stays on device; only a token-bounded summary (totals, top N holdings) crosses the wire. The context builder (
buildPortfolioContext) is the funnel.
- Split Brain — Memory (trades, positions, conversation) in the browser; reasoning (LLM, search grounding) on the server. The API is stateless: (context, message, attachment) → stream.
- Token Funnel — 10,000 trades → aggregation → top N + totals → context string (≤4K tokens). Signal preserved; PII and noise excluded.
- Dual source — "My Portfolio" (local context) + "The Market" (Gemini search grounding). Model cites which source it used.
- Guardrails — System prompt constrains to finance only; red lines (no advice, no execution, no invented data); polite redirect for off-topic.
- Transient attachments — File parsed in browser; only text sent; not stored on server. Browser-Side ETL: Extract → Transform → Load (into prompt).
- Streaming & UX — Vercel AI SDK (
useChat, streamText); FAB, glassmorphism modal, optimistic UI, usage badge.
- Economics — Tiered quotas (free N/month, paid unlimited); Firestore for usage; cost per query and break-even modeled.
- Model choice — Gemini Flash default (speed, cost, grounding); Pro for upgrade; benchmarked vs. GPT-4o.
- Agent loop — Future: model proposes action → user confirms → client executes. Human in the loop always for financial actions. No autonomous execution.
The full blueprint
The complete technical reference—every chapter, every figure, implementation paths, and appendices—is the book:
Sovereign Intelligence: Building Local-First RAG for Finance
Single canonical URL for SEO and deep links: https://www.pocketportfolio.app/book/sovereign-intelligence. ~25,000 words. Ten chapters in five parts, plus Conclusion and Appendix. All diagrams (Data Chasm, Hybrid Architecture, Token Funnel, Grounding Flow, Prompt Engineering, Browser-Side ETL, Component Tree, Cost/Unit Economics, Benchmark, Agent Loop) are in the book and on the site.
- Pocket Analyst implementation report:
docs/POCKET-ANALYST-IMPLEMENTATION-REPORT.md
- Production checklist:
docs/POCKET-ANALYST-PROD.md
- Vercel env (Pocket Analyst):
docs/VERCEL-ENV-SUPPORT-ADMIN.md
Part 12 of Sovereign Intelligence Serial — the complete series adapted from Sovereign Intelligence: Building Local-First RAG for Finance.
Read the full Sovereign Intelligence or Try the app.