The payment decision is inside the agent's reasoning loop, not in the UI layer. The KYCAgentState TypedDict carries payment_status, investigation_depth, doku_link, cypher_query, graph_context, and answer across nodes.
Stack
- FastAPI + Jinja2 — REST API + server-rendered SPA frontend
- LangGraph — agentic workflow orchestration with conditional edges
- GPT-4o — entity extraction, Cypher generation, report synthesis
- Neo4j AuraDB — cloud knowledge graph with Cypher queries
- DOKU Checkout v1 API — real sandbox payments with HMAC-SHA256 signing
- vis.js Network — interactive graph visualisation
- rapidfuzz + jellyfish — ICIJ-inspired entity deduplication
Challenges we ran into
1. Cypher Hallucination — GPT-4o generated invalid Cypher syntax (type(var)-[:REL]->() in RETURN, deprecated size() for Neo4j 5). Built a _sanitize_cypher() sanitiser and extended the system prompt with explicit anti-hallucination rules and Cypher examples.
2. DOKU Webhook Reachability — Microsoft Dev Tunnels requires authentication so DOKU's servers couldn't POST to our local webhook. Built a dual confirmation system: server-side webhook for production + browser redirect (/payment-success) as reliable fallback.
3. Session Loss on Hot-Reload — In-memory _sessions dict wiped on every code change. Solved with localStorage on the frontend + file-backed sessions.json on the backend with session resurrection logic when the server restarts mid-investigation.
4. Chat History Across Payment Redirect — DOKU redirects the browser away and back, wiping JS memory. Persisted _chatHistory (last 50 messages) to localStorage and restored on page load with _resumeAfterPayment flag.
Accomplishments that we're proud of
- Payment as a first-class agent node — not a UI trick, but a real conditional edge in LangGraph that the agent evaluates on every invocation
- Real DOKU sandbox integration working end-to-end with HMAC-SHA256 signature generation, live checkout pages, and payment confirmation flow
- Agent Trace accordion in chat — every LangGraph node's output (query plan, Cypher query, row count, synthesis) is visible and expandable for full transparency
- Production-grade GraphRAG — multi-hop Cypher traversal catches shell company chains that vector similarity search would miss entirely
- Full UI with interactive knowledge graph, drag-to-resize panels, export to HTML report, and persistent chat history — all in under 12 hours
What we learned
- LangGraph conditional edges are the cleanest way to implement business logic gates inside an AI agent — far more maintainable than
if/elsechains in a single prompt - GraphRAG > VectorRAG for structured relationship queries — knowing that Company A directly BORROWS_FROM Company B is more precise than semantic similarity
- Embedding payment confirmation at the agent reasoning level opens entirely new monetisation models for AI SaaS — every capability tier can be a node
- Neo4j AuraDB's Cypher dialect requires careful prompt engineering to avoid Neo4j 4 vs 5 compatibility issues
What's next for FinAgent — B2B KYC & Due Diligence AI
- DOKU production keys — switch from sandbox to live payments for real B2B clients
- Multi-document investigation — cross-reference entities across multiple uploaded documents simultaneously
- Automated red flag alerts — periodic re-analysis that notifies users when new connections appear in the graph
- AML scoring model — fine-tuned risk scoring based on transaction patterns, jurisdiction risk, and network centrality metrics
- API access tier — expose
/api/investigateas a paid B2B API for banks and compliance teams to integrate into their existing workflows - Graph diff view — show what changed in the knowledge graph between two investigation runs
Log in or sign up for Devpost to join the conversation.