FinanceGuard AI โ€” Devpost Submission ๐ŸŒŸ Inspiration Every 5 seconds, a fraudulent transaction happens somewhere in the world โ€” costing the global economy over $485 billion annually. Meanwhile, loan officers spend days reviewing applications that AI could assess in seconds, and 67% of retail investors receive no personalised financial advice because wealth management is too expensive.

We were inspired by a simple but powerful question: What if AI could act as a financial guardian for everyone โ€” not just the ultra-wealthy?

The convergence of three technologies made this the right moment to build it:

Gemini 2.0 Flash โ€” capable of multi-step reasoning and function calling at zero cost MongoDB Atlas Vector Search โ€” enabling semantic similarity over millions of financial records in milliseconds GitLab MCP โ€” providing a versioned, auditable trail for every AI decision (crucial for regulated industries) Traditional fraud systems use rigid rule-based engines that miss novel attack patterns. Traditional loan underwriting is slow, biased, and opaque. We wanted to build an agent that reasons like a senior analyst, acts like an automated system, and leaves a complete audit trail โ€” automatically.

๐Ÿค– What It Does FinanceGuard AI is an autonomous financial intelligence agent with three production-ready capabilities:

๐Ÿ” Real-Time Fraud Detection Submit any transaction โ€” the agent:

Converts it to a semantic vector using Gemini text-embedding-004 Searches MongoDB Atlas Vector Search for the 5 most similar historical fraud cases Gemini 2.0 Flash reasons across 8 fraud indicators (geographic anomaly, amount pattern, device mismatch, time-of-day, merchant category risk, velocity, IP country mismatch) Returns a 0โ€“100 risk score with a detailed plain-English explanation For scores โ‰ฅ 70 โ†’ automatically creates a GitLab issue titled "๐Ÿšจ Fraud Alert" with full forensic analysis, labeled priority::critical ๐Ÿ’ฐ AI Wealth Advisor Enter a user ID โ€” the agent:

Loads the investor's portfolio from MongoDB (risk tolerance, holdings, net worth, goals) Finds 5 similar investor profiles via vector search to ground recommendations in real data Gemini generates 4โ€“5 hyper-specific investment recommendations (naming real ETFs, allocations, rationale) Automatically commits a full Markdown report to GitLab โ€” versioned and auditable forever ๐Ÿ“‹ 7-Step Loan Underwriting Fill out a loan application โ€” the agent autonomously:

Computes the Debt-to-Income (DTI) ratio Embeds the applicant profile Vector searches 10 similar historical loans (approved/rejected) Analyses approval/rejection patterns Computes a composite risk score (DTI 30% + Credit Score 40% + Pattern Match 30%) Generates and commits a structured underwriting report to GitLab Creates a GitLab issue for human review with the appropriate risk label Every action is streamed in real-time via Server-Sent Events, so users watch the agent think step by step.

๐Ÿ› ๏ธ How We Built It Architecture

Next.js Dashboard โ†’ FastAPI (SSE Streaming) โ†’ Gemini 2.0 Flash โ†’ MongoDB Atlas Vector Search
โ†’ GitLab REST API / MCP Technology Stack Layer Technology Why AI Brain Gemini 2.0 Flash (free tier) Best reasoning at zero cost Embeddings Gemini text-embedding-004 (768-dim) Native integration, no extra service Database MongoDB Atlas + Motor (async) Vector Search built-in, no separate vector DB Backend FastAPI + SSE Streaming Real-time agent trace, async-native Frontend Next.js 14 + Framer Motion App Router, SSE consumption, animations DevOps GitLab MCP (gitlab-orbit) + REST API Versioned reports, issue tracking, graph queries Charts Recharts Portfolio visualisation Key Implementation Decisions Why MongoDB Vector Search instead of Pinecone/Weaviate? MongoDB Atlas lets us store operational data AND vector embeddings in one place. No ETL pipeline, no sync lag, no extra service to manage. The fraud detection query is a single $vectorSearch aggregation stage.

Why stream agent steps as SSE? Financial decisions need transparency. Showing each reasoning step live (embed โ†’ search โ†’ analyse โ†’ decide โ†’ persist โ†’ alert) makes the AI explainable โ€” a regulatory requirement in financial services.

Why GitLab for audit trails? Every loan report and fraud alert is committed as a versioned Markdown file in Git. This creates an immutable, diff-able history of every AI decision โ€” critical for compliance with regulations like GDPR, Basel III, and the EU AI Act.

Why Gemini 2.0 Flash (free tier)? We wanted to prove that enterprise-grade financial AI is achievable without a massive AI budget. Every inference in this project runs on Gemini's free tier.

Data Pipeline Seeded MongoDB with 500 synthetic transactions (40 fraudulent), 50 loan applications, and 20 investor portfolios All records embedded with text-embedding-004 at seed time 3 Atlas Vector Search indexes created: transaction_vector_index, loan_vector_index, portfolio_vector_index ๐Ÿ˜ค Challenges We Ran Into

  1. MongoDB MCP Server Authentication The MongoDB MCP server required the connection string to be set at the config level, not at runtime via the connect tool call in our environment. We worked around this by using pymongo + motor directly in the backend while leveraging the MCP schema for data modelling decisions.

  2. Gemini API Rate Limits on Seeding Generating 570 embeddings (500 transactions + 50 loans + 20 portfolios) in sequence hit the free-tier rate limit. We added exponential backoff with tenacity and batched embedding requests to stay within quota.

  3. Atlas Vector Search Index Creation Atlas Vector Search indexes cannot be created via the standard MongoDB driver โ€” they require the Atlas Admin API or the Atlas UI. We built a create_indexes.py script that attempts programmatic creation via SearchIndexModel and falls back to detailed UI instructions if the cluster tier doesn't support it.

  4. Making SSE Work with Next.js App Router The App Router's fetch implementation has quirks with streaming responses. We had to implement a custom ReadableStream consumer that correctly splits on \n\n boundaries and handles [DONE] termination signals โ€” mimicking how OpenAI's streaming works.

  5. Keeping Gemini JSON Responses Reliable Gemini occasionally wraps JSON in markdown code blocks or adds preamble text. We built a robust JSON extraction utility that strips ```json wrappers, handles trailing commas, and retries with a stricter prompt on parse failure.

๐Ÿ† Accomplishments That We're Proud Of Full agentic loop โ€” the system doesn't just generate text; it reads from MongoDB, writes to MongoDB, creates GitLab issues, and commits files โ€” all autonomously 3 complete, production-quality agent pipelines built and integrated in one hackathon Zero external vector database โ€” MongoDB Atlas does everything, proving the "unified data platform" value proposition 100% free AI โ€” the entire project runs on Gemini's free tier, making it accessible to any developer Real-time transparency โ€” every agent reasoning step is streamed live, making AI decisions explainable and auditable Immutable audit trail โ€” every loan decision and fraud alert becomes a permanent, versioned document in GitLab Dual partner integration โ€” MongoDB AND GitLab are both deeply integrated, not just "hello world" usage ๐Ÿ“š What We Learned MongoDB Atlas Vector Search is genuinely competitive with dedicated vector databases for financial use cases โ€” the cosine similarity results on transaction embeddings were remarkably accurate at finding semantically similar fraud patterns

Gemini's function-calling + reasoning is ready for financial workloads โ€” the risk scoring and underwriting rationale was coherent, specific, and referenced actual data points from the retrieved similar cases

Text-embedding-004 produces highly meaningful embeddings for financial data โ€” even though transaction descriptions are short, the 768-dimensional embeddings captured meaningful semantic relationships (e.g., "casino" transactions clustering with other "gambling" frauds regardless of merchant name)

Audit trails are not optional in finance โ€” the GitLab integration went from "nice to have" to "essential feature" as we realized that every financial AI decision needs a versioned, immutable record

SSE streaming dramatically improves perceived AI quality โ€” users watching step-by-step reasoning trusted the output more than seeing an instant answer, even when the final result was identical

Gemini 2.0 Flash punches well above its "free tier" weight class โ€” for structured JSON generation and multi-criteria reasoning, it performed comparably to much larger models

๐Ÿš€ What's Next for FinanceGuard AI Short-term (Next 30 days) Real-time transaction streaming via MongoDB Change Streams โ€” instead of submitting transactions manually, monitor a live feed and flag fraud automatically Multi-user authentication with JWT and role-based access (analyst, manager, compliance officer) Webhook integration โ€” push fraud alerts to Slack/PagerDuty in addition to GitLab Medium-term (3 months) Gemini Live API integration โ€” allow analysts to talk to the fraud agent using voice for hands-free investigation Portfolio backtesting โ€” simulate recommendation performance against historical data stored in MongoDB GitLab CI/CD pipeline โ€” auto-run a "model drift" check whenever new fraud patterns are committed to the repo Long-term Vision Regulatory compliance automation โ€” auto-generate Basel III and EU AI Act compliance reports from the GitLab audit trail Cross-bank consortium โ€” anonymised fraud pattern sharing across institutions using MongoDB Atlas Data Federation On-device inference โ€” run lightweight fraud scoring locally (edge computing) for offline card terminals, with MongoDB Atlas as the sync layer Business Model FinanceGuard AI is designed to replace three expensive SaaS tools:

Fraud detection platforms ($50Kโ€“500K/year enterprise contracts) Robo-advisors (0.25โ€“0.5% AUM annually) Loan origination systems ($200K+ implementations) By building on free-tier Gemini + MongoDB Atlas, the marginal cost per decision approaches zero โ€” making it viable for credit unions, community banks, and fintech startups that can't afford enterprise software.

Built with โค๏ธ using Gemini 2.0 Flash ยท MongoDB Atlas ยท GitLab MCP ยท FastAPI ยท Next.js

Built With

Share this project:

Updates