-
-
System architecture: Company A → Google ADK agents → MCP Protocol → MongoDB Atlas. Counterparty B responds via secure portal.
-
Real-time B2B reconciliation overview — 15 companies, 8 active discrepancies, agent activity feed. Built on Google Cloud + MongoDB Atlas.
-
AI-detected amount mismatch: side-by-side ledger comparison, Lumina Fix Suggestion, auto-drafted resolution email. Human-in-the-Loop gate.
-
Counterparty secure portal — single-use magic link, ledger entries review, 3-way decision: Agree / Dispute / Let AI Compare.
-
Google ADK 2.0 multi-agent pipeline: orchestrator → reconciliation → analysis → communication agent. Gemini 3.5 Flash + MongoDB MCP.
The Problem
Every month, finance teams across the world lose 3–5 business days manually reconciling inter-company account balances. A typical B2B reconciliation cycle looks like this: export ledgers to Excel, email your counterparty, wait for their response, spot-check line by line, draft resolution emails manually — and repeat for every discrepancy. Human error rates exceed 12%, and there's no audit trail.
This is a $4.7B+ annual problem that nobody has solved with AI agents — until now.
What We Built
Lumina is a production-ready B2B financial reconciliation platform powered by a Google ADK 2.0 multi-agent pipeline, Gemini 3.5 Flash, and MongoDB Atlas as the core data layer — connected to agents via a custom MCP (Model Context Protocol) server over real HTTP/SSE transport.
The entire reconciliation cycle — from ledger import to discrepancy detection to email dispatch — runs in under 8 seconds.
Architecture
ERP / Excel / CSV ↓ FastAPI (Google Cloud Run) + JWT Auth ↓ lumina_orchestrator (Gemini 3.5 Flash) ├── reconciliation_agent → MCP find() → MongoDB ledgers ├── analysis_agent → MCP aggregate() → classify discrepancies └── communication_agent → MCP insert() → draft resolution emails ↓ Human-in-the-Loop approval gate ↓ SMTP email dispatch → case closed
MongoDB is not just storage — it's the agent's superpowers. Every agent decision is a structured MCP tool call (find, aggregate, insert_one, update_one, vector_search) against MongoDB Atlas collections. The agents never see raw data dumps — they query exactly what they need, mid-reasoning.
Key Features
- 🤖 Multi-agent orchestration — 4 specialized agents with defined roles under a root orchestrator
- 🔗 Real MCP server — HTTP/SSE transport at
/mcp/sse, full JSON-RPC handshake, tool discovery - 🔍 Atlas Vector Search — semantic similarity matching via
text-embedding-004for fuzzy record deduplication - 🌐 B2B Portal system — counterparties receive a secure, single-use magic link, review your ledger entries, and respond (Agree / Dispute / Let AI Compare)
- 👤 Human-in-the-Loop — every AI-drafted email requires explicit approval before dispatch (critical for financial contexts)
- 🏭 Local ERP Agent — downloadable agent for SAP, Logo, Mikro — syncs on-premise data to MongoDB Atlas automatically
- 📊 Real-time dashboard — discrepancy feed, trend heatmap, agent execution timeline
- 💱 Multi-currency support — TRY, USD, EUR, AUD, NOK, CNY with sign-aware matching
How We Built It
Backend: FastAPI on Google Cloud Run, Motor async MongoDB driver, Google ADK 2.0 SDK, custom MCP ASGI app mounted at /mcp/sse.
Frontend: Next.js 14 on Vercel, TanStack Query, D3.js world map, real-time AgentIsland execution panel.
AI: Gemini 3.5 Flash via Google Cloud Agent Builder SDK for all agent reasoning; text-embedding-004 for vector embeddings.
Data: MongoDB Atlas with 7 collections (ledgers, companies, discrepancies, master_balances, reconciliation_sessions, agent_runs, file_objects), Atlas Vector Search index on ledger descriptions.
Challenges We Faced
1. MCP over HTTP/SSE in production — Most examples use subprocess transport. We implemented a real HTTP/SSE MCP server as an ASGI app inside FastAPI, with proper session lifecycle and JSON-RPC message routing. Getting this to survive Google Cloud Run cold starts required OpenSSL SECLEVEL patches and Motor async connection pooling.
2. MongoDB Atlas TLS on Cloud Run — OpenSSL 3.0 cipher incompatibilities caused silent SSL failures. Fixed with SECLEVEL=1 patch, certifi CA bundle, and python:3.12-bookworm base image.
3. Agents hallucinating financial figures — Early versions would invent amounts when context was sparse. Solved by routing all data through MCP tool calls — agents never receive raw data in prompts, only structured tool results from MongoDB.
4. Human-in-the-Loop UX — Getting the approval gate to feel natural (not like an obstacle) required significant UI iteration. The final design shows side-by-side amount diffs, AI fix suggestions, and the auto-drafted email — all in one modal — so approving takes one click with full context.
What We Learned
- MCP as a data bridge is genuinely transformative for agent accuracy. Structured tool calls eliminate hallucination on numerical data better than any prompt engineering.
- Google ADK's agent hierarchy (root orchestrator → sub-agents) maps perfectly to real enterprise workflows where different "departments" (matching, analysis, communication) have distinct responsibilities.
- MongoDB Atlas is an ideal agent data layer — the same database serves real-time queries, vector search, aggregation pipelines, and audit logs, all through one connection.
- Financial AI requires Human-in-the-Loop — not as a safety measure, but as a product feature. Accountants trust the AI more when they have final say.
Impact
| Metric | Manual Process | Lumina |
|---|---|---|
| Time per reconciliation cycle | 3–5 business days | < 8 seconds |
| Human error rate | > 12% | < 1% |
| Audit trail | Spreadsheets | Full MongoDB history |
| Email drafting | Manual, inconsistent | AI-generated, professional |
Lumina targets the 400M+ SMEs globally that run reconciliation manually — a segment too large for enterprise ERPs, too complex for spreadsheets.
Built With
- d3.js
- fastapi
- gemini-3.5-flash
- googlecloudadk
- googlecloudrun
- mcp
- mongodb-atlas
- mongodb-vector-search
- motor
- next.js
- python
- tanstack-query
- typescript
- vercel
Log in or sign up for Devpost to join the conversation.