Google ADK Java
AI Finance Advisor: Executive Presentation
Slide 1 of 4 • Industry Problem & Strategic Opportunity

The Financial Decision-Support Dilemma

Why investors and wealth advisers struggle to connect fragmented market data with personal portfolio realities.

For Individual Investors: Information Overload

Retail investors face fragmented tools: brokerage statements show static numbers, financial portals stream uncurated headlines, and generic AI chatbots hallucinate financial math.

  • Disconnected Context: Holdings in one app, quarterly earnings in another, risk calculations nowhere.
  • Math Hallucinations: Standard LLMs generate inaccurate PnL, weighted returns, and DCF models.
  • Emotional Drift: Difficulty evaluating how a rate change or sector selloff impacts their personal holdings.
Fragmented Tools Unverified News Ungrounded Math
For Wealth Advisers: Repetitive Research Overhead

Advisers spend 60%+ of their client prep time assembling manual portfolio review packets, cross-referencing earnings notes, and formatting sensitivity tables.

  • Manual Portfolio Reviews: Hours spent aggregating cost basis, calculating drift, and drafting review summaries.
  • Lack of Real-Time Evidence: Sourcing audit-ready citations for macro catalysts and forward scenarios is tedious.
  • Strict Compliance Requirements: Every client interaction requires clear non-advice guardrails and risk disclosures.
High Prep Time Manual Sensitivity Compliance Burden
The Solution: An evidence-backed, portfolio-aware AI assistant that pairs deterministic Java financial math with grounded web research.
Zero Math Hallucination
Slide 2 of 4 • Verified Implementation

What We Built: The Verified System

A responsive React/TypeScript experience powered by an autonomous, multi-milestone Google ADK Java engine.

Portfolio & Concentration

Relational customer holding ingestion from SQLite database. Tracks symbols, buy prices, quantities, and cash basis across multiple multi-turn sessions.

• Customer 1001: RELIANCE & TCS
• Customer 1002: INFY (Alert >25%)
Live SQLite WAL Java Math Engine
Evidence & Search Grounding

Google Search tool grounding isolates fact retrieval for recent quarterly earnings, regulatory filings, analyst targets, and corporate announcements.

• Primary Sources: SEC & Releases
• Structured Evidence References
Google Search Tool Knowledge Docs
Multi-Scenario Stress Testing

Generates 3-case structured projections (Baseline, Upside Catalyst, Downside Stress) paired with Two-Stage DCF valuation and sensitivity bounds.

• INFY.NS Fair Value: 1,520 INR
• Downside Stress: 1,380 INR
Deterministic DCF Sample Quotes (MCP)
✓ Grounded Verification: Math calculations (PnL, allocation weights, DCF formulas) are strictly executed in Java code—never in model weights. Real customer holdings are loaded from SQLite.
• Data Attribution Transparency: Current V14 MCP server quotes (INFY.NS, TCS.NS, AAPL) operate on educational sample data; automated trading is strictly prohibited by guardrails.
Slide 3 of 4 • Production Architecture

How It Works: End-to-End Architecture

A decoupled, defensive system pairing a reactive React frontend with a secure Google ADK Java backend.

1. Presentation & State
React 18 SPA (Vite) V14
Dark/Light terminal UI deployed to Firebase Hosting. Renders executive markdown & scenario cards.
AG-UI State Memory Live
Displays active session context: customer ID, holdings, active ticker, and capital.
Cloud Firestore Debounced
Batched atomic commits (5-min inactivity / session switch) saving 80%+ database write I/O.
Hybrid Auth & Security Guard
Dynamic X-API-Key resolution with CORS OPTIONS preflight bypass and rate limiting.
2. Google ADK Java Core
Javalin 6 REST/SSE Port 8089
High-throughput gateway exposing /query and Server-Sent Events (SSE) /stream endpoints.
FinanceAdvisorAgentV14 LlmAgent
Powered by Gemini 2.5 Flash with prompt engineering and session persistence.
Specialist Workflows V6 & V7
Sequential chains, parallel CompletableFuture fan-out, and iterative compliance critic loops.
Safety Callbacks (V8) 5 Hooks
PII scrubbing, prompt-injection defense, ticker validation, and mandatory disclaimer enforcement.
3. Tools & Data Engines
PortfolioMathTool Java Math
Deterministic arithmetic for PnL, cost basis, percentage allocation, and concentration risk (>25%).
SQLite Holdings DB WAL Mode
Relational customer and holding tables automatically seeded and loaded via LoadCustomerPortfolioTool.
MCP Server (V13) Stdio/RPC
Exposes get_quote, get_company_profile, and Two-Stage DCF valuation model.
Google Search Grounding ADK Tool
Real-time web retrieval via isolated stockmarket_researcher sub-agent for breaking news & filings.
Slide 4 of 4 • Technical Deep Dive

End-to-End Architecture: Frontend to Backend Integration

How the Firebase-hosted React app, the Cloud Run gateway, the Google ADK Java runtime and its model, search, MCP and data integrations connect.

End-to-end architecture: frontend to backend integration The React app on Firebase sends HTTPS requests with an API key to the Cloud Run gateway, which applies security headers, rate limiting and hybrid authentication before routing to the agent registry. The Google ADK Java runtime runs FinanceAdvisorAgentV14 inside lifecycle callbacks and makes guarded calls to Gemini, Google Search, the Finance MCP server, PortfolioMathTool and SQLite. Responses stream back to the app over SSE, which syncs chat history to Cloud Firestore. GitHub Actions deploys the frontend to Firebase Hosting and the backend to Cloud Run or Docker. FRONTEND · FIREBASE GATEWAY · CLOUD RUN :8089 GOOGLE ADK JAVA RUNTIME INTEGRATIONS & DATA Firebase Auth Google OAuth sign-in approval gate (APPROVED) React 18 SPA Vite + TypeScript useAgUiChat SSE hook report + JSON views Cloud Firestore /users/{uid}/threads 5-min debounced batch Other Clients ADK Dev UI :8080 CLI consoles A2A agent card ID token 5 chat sync Security Headers SecurityHeadersFilter CSP · HSTS · X-Frame DENY Rate Limiter TokenBucketRateLimiter 60 req/min · Retry-After Hybrid Auth + RBAC X-API-Key or IAM OIDC JWT role-based access control Dynamic Router /api/v1/agents/{id}/query /stream · /api/adk (AG-UI) Agent Registry finance_advisor_v14 · v13 · v12 social_poster /healthz · /.well-known/agent.json FinanceAdvisorAgentV14 LlmAgent · V11 scoped rules V12 outputSchema + repair Lifecycle Callbacks BeforeAgent · injection halt BeforeModel · PII scrub BeforeTool · trade block, ticker check AfterTool · evidence capture AfterModel · fact audit + disclaimer Orchestration V6 AgentTool specialists V7 Sequential · Parallel · Loop Observability & Evaluation V10 ExecutionTrace (exec-id) V9 faithfulness + fidelity Gemini 2.5 Flash Vertex AI / AI Studio or Ollama (OllamaOpenAiLlm) LLM Google Search stockmarket_researcher isolated AgentTool turn search Finance MCP Server V13 · JSON-RPC 2.0 stdio get_quote · DCF valuation MCP PortfolioMathTool PnL · weights · >25% alert Java SQLite (WAL) holdings · execution traces JDBC 3 guarded calls 1 HTTPS POST X-API-Key REST/A2A 2 runAsync (session) 4 SSE stream AG-UI DELIVERY · GITHUB ACTIONS CI/CD cicd-frontend-deployment.yml typecheck · unit tests · deploy to Firebase Hosting cicd-backend-adk.yml build · test · Agent Platform / Cloud Run or Docker Dockerfile Temurin 21 JRE · non-root UID 10001 · port 8089

Swipe sideways to explore the full diagram.

1App calls the gateway with an API key 2Perimeter passed, router dispatches to the agent 3Hooked agent makes guarded model and tool calls 4Validated answer streams back over SSE 5App syncs the thread to Firestore request response deployment blocking guard