🛡️ ReconMitra

An Explainable Neuro-Symbolic Generative AI Framework for Automated 3-Way GST Invoice Reconciliation and Statutory Audit Defense.

Rules for Math. AI for Law. Zero ITC Leakage.

Next.js FastAPI AI Stack Database Compliance


📖 Table of Contents

  1. 💡 Inspiration
  2. ⚙️ What It Does
  3. 🏗️ System Architecture
  4. 🛠️ How We Built It
  5. 🚧 Challenges We Ran Into
  6. 🧠 What We Learned
  7. 🚀 What's Next for ReconMitra
  8. 💻 Quick Start & Local Setup
  9. 🏷️ Built With Tags

💡 Inspiration

Every month between the 14th (when GSTR-2B is generated) and the 20th (when GSTR-3B is due), finance teams and Chartered Accountants (CAs) across Indian MSMEs and mid-sized enterprises face a massive operational bottleneck. Companies processing thousands of monthly B2B invoices lose crores in blocked Input Tax Credit (ITC) and working capital because reconciling Purchase Orders (POs), Goods Receipt Notes (GRNs), ERP Purchase Registers (Tally/SAP), and government GSTR-2B portal filings is treated like a manual spreadsheet hunt.

While researching existing accounting and GST tools (such as ClearTax, Masters India, and native ERP plugins), we noticed a fundamental flaw: legacy software treats tax reconciliation strictly as a deterministic string-and-math matching problem. When Invoice_Amount != GSTR2B_Amount or an invoice number drifts from INV/2026-27/0042 to 42, existing tools simply highlight the row in red. They fail to answer why the mismatch happened, cannot interpret statutory rules under the CGST Act (Sections 16 & 17(5)), miss "silent compliance traps" (like matched invoices for ineligible catering or client gifts), and leave human accountants to spend 80+ hours manually investigating disputes and drafting vendor emails.

That gap inspired ReconMitra—an Explainable Neuro-Symbolic Generative AI Framework that shifts the paradigm from Rule-Based Matching to Agentic Financial Forensics, acting as an AI Junior Tax Auditor that investigates, explains, cites exact GST law, and drafts the resolution.


⚙️ What It Does

ReconMitra is an end-to-end GST reconciliation and compliance defense workbench that automates 3-Way + 1 Triangulation across Purchase Orders (PO) $\leftrightarrow$ GRN/Service Entry $\leftrightarrow$ Purchase Register (PR) $\leftrightarrow$ GSTR-2B.

  1. Multi-Source Vision OCR & Normalization: Ingests skewed vendor invoice PDFs, thermal transport bills, Tally/SAP CSV exports, and GSTR-2B JSON files, extracting structured line items and tax breakups into strict JSON schemas.
  2. 3-Tier Cascade Matching Engine:
    • Tier 1 (Deterministic Exact & Tolerance Pass): Instantly clears ~70% of exact matches within a $\pm \text{INR } 2.00$ rounding tolerance in milliseconds.
    • Tier 2 (Heuristic & Fuzzy Pass): Resolves ~15% of volume involving alphanumeric prefix stripping (INV-00123 $\rightarrow$ 123), date swaps (DD/MM vs MM/DD), and swapped tax heads (CGST+SGST vs IGST).
    • Tier 3 (Agentic Semantic & Legal RAG Pass): Handles the complex ~15% exceptions—linking mangled PO-to-Invoice descriptions, diagnosing HSN/SAC rate arbitrage, and investigating missing GSTR-2B filings.
  3. Explainable Root-Cause Forensics & Statutory Citations: Replaces cryptic error flags with natural-language explanations backed by a RAG knowledge base of CBIC notifications and CGST Act Sections 16 & 17.
  4. Section 17(5) "Blocked Credit" Shield: Semantically inspects invoice line items to catch invoices that mathematically match 100% in GSTR-2B but are legally ineligible for ITC (e.g., employee cab services, food/beverages, client gifts, civil construction)—preventing $18\text{--}24\%$ interest and $100\%$ penalty exposure during departmental audits.
  5. 180-Day Payment Rule (Rule 37) & MSME 43B(h) Guard: Tracks invoice aging against Accounts Payable to alert finance teams 15 days before the 180-day statutory ITC reversal cliff.
  6. Human-in-the-Loop (HITL) Workbench & Auto-Drafted Vendor Comms: Routes decisions into Green (Auto-Approve), Amber (Junior Maker Review), and Red (Senior CA Sign-off) lanes with 1-click actions (Accept, Query Vendor, Hold ITC, or Block/Reverse) and pre-drafted WhatsApp/Email Debit Note notices.
  7. Cryptographic Audit Vault: Logs every AI reasoning snapshot and human override into a tamper-proof SHA-256 hash-chained ledger, exporting GSTR-3B Table 4 summaries and Audit Defense Dossiers (PDF/CSV) for DRC-01A / ASMT-10 scrutiny notices.

🏗️ System Architecture

+-----------------------------------------------------------------------------------+
|                        FRONTEND: NEXT.JS 14 + SHADCN/UI                           |
|  [Ingestion Dropzone]  [Recon Workbench]  [Explainability Drawer]  [Audit Vault]  |
+-----------------------------------------+-----------------------------------------+
                                          | REST / SSE Streaming
+-----------------------------------------v-----------------------------------------+
|                        BACKEND ORCHESTRATOR: FASTAPI                              |
|                                                                                   |
|  +-----------------------+   +------------------------+   +--------------------+  |
|  | 1. Ingestion Pipeline |   | 2. Deterministic Engine|   | 3. Agentic RAG     |  |
|  | - PDF/OCR (Vision LLM)|-->| - Exact Key Matching   |-->| - Chroma/Pinecone  |  |
|  | - GSTR-2B JSON Parser |   | - Tolerance Math (+-2) |   | - CBIC GST Law KB  |  |
|  | - Pydantic Validation |   | - GSTIN Checksum Verif.|   | - Historical Cases |  |
|  +-----------------------+   +------------------------+   +--------------------+  |
+-----------------------------------------+-----------------------------------------+
                                          |
+-----------------------------------------v-----------------------------------------+
|                    DATA & PERSISTENCE LAYER (SUPABASE / POSTGRESQL)               |
|  [Transactional Tables]  [Immutable Audit Ledger (Hash-Chained)]  [pgvector/Store]|
+-----------------------------------------------------------------------------------+

🛠️ How We Built It

We architected ReconMitra using a Neuro-Symbolic Hybrid Stack—ensuring that deterministic Python/SQL handles all arithmetic while LLMs and RAG handle semantic linking, legal interpretation, and communication drafting:

  • Frontend & Interactive Workbench: Built with Next.js 14 (App Router), React, TypeScript, Tailwind CSS, and shadcn/ui (alongside a portable, zero-dependency interactive prototype console in index.html). We designed high-density financial data grids, split-screen PDF bounding-box evidence viewers, interactive SVG Donut analytics, and keyboard-first review workflows (J/K navigation, A to accept, Q to query).
  • Backend Orchestration & Matching Pipeline: Built on FastAPI (Python) and Next.js API Routes. Vectorized data frames (Pandas/Polars) execute Tier-1 and Tier-2 deterministic and fuzzy Levenshtein matching across thousands of rows before routing unresolved exceptions to the AI agent.
  • Document Processing & Anti-Hallucination Math Check: Combines PyMuPDF with GPT-4o / Claude 3.5 Sonnet Vision enforced via Pydantic strict JSON schemas. Before reconciliation begins, a deterministic pre-check verifies:

$$\sum_{i=1}^{n} \text{Taxable_Value}_i + \text{CGST} + \text{SGST} + \text{IGST} + \text{Cess} = \text{Total_Invoice_Amount}$$

  • Agentic RAG & Vector Memory: Powered by LangChain / LlamaIndex connected to PostgreSQL (pgvector) / Chroma / Pinecone housing two distinct vector collections:
    • gst_statutory_kb: Chunked CGST Act sections, CBIC tariff schedules, and HSN chapters.
    • historical_resolutions_kb: Continuous learning memory of past Senior CA overrides for specific vendor patterns.
  • Composite Confidence Scoring ($C_{\text{total}}$): Instead of letting an LLM guess its own confidence, ReconMitra computes a mathematically defensible weighted score:

$$C_{\text{total}} = 0.30 \cdot C_{\text{OCR}} + 0.35 \cdot C_{\text{Deterministic}} + 0.20 \cdot C_{\text{Semantic}} + 0.15 \cdot C_{\text{Historical}}$$

  • Database & Immutable Ledger: Supabase / PostgreSQL stores normalized financial documents, reconciliation cases, and an append-only audit log where each state transition computes:

$$H_k = \text{SHA256}(H_{k-1} \parallel \text{Case_ID} \parallel \text{New_State} \parallel \text{Timestamp})$$


🚧 Challenges We Ran Into

  1. Preventing LLM Arithmetic Hallucinations: Early experiments showed that passing raw invoice tables directly to an LLM occasionally resulted in hallucinated tax differences or rounding errors. We solved this by strictly separating responsibilities: Python calculates every rupee difference ($\Delta \text{Tax} = \text{Tax}{\text{PR}} - \text{Tax}{\text{2B}}$) and injects immutable numbers into the prompt context, accompanied by a post-generation regex validator that rejects any LLM output citing numbers absent from the source JSON.
  2. High Latency & Token Costs on Large Invoice Batches: Running GPT-4o/Claude 3.5 across 10,000 monthly invoices would be slow and expensive for MSMEs. Designing the 3-Tier Cascade Funnel allowed us to filter out $85\%$ of invoices using ultra-fast deterministic and fuzzy rules, invoking the LLM+RAG agent only on the complex $15\%$ exceptions—cutting inference costs by nearly $6\times$.
  3. Handling Messy Indian B2B Invoice Formats: Vendor invoice numbers vary wildly across ERP exports and GSTR-1 filings (e.g., INV/2026-27/0089 vs 26-27/89), and multi-state enterprises frequently suffer from Place of Supply (PoS) errors where CGST+SGST is billed instead of IGST. Building a multi-anchor normalization algorithm that combines GSTIN checksum verification, alphanumeric stripping, and semantic line-item matching was critical to eliminating false-positive rejections.
  4. Designing a High-Density UI Without Visual Clutter: Accountants need to see 3-way diffs, PDF bounding boxes, statutory citations, and vendor emails simultaneously without feeling overwhelmed. Iterating on a clean, airy fintech layout with expandable rows and a slide-over Explainability Drawer kept the workflow fast and intuitive.

🧠 What We Learned

  • Neuro-Symbolic AI is the Gold Standard for Fintech: In regulated domains like taxation and accounting, pure generative AI is too unpredictable, while pure rule-based code is too brittle. Combining deterministic code for math with RAG-grounded LLMs for statutory reasoning delivers both $100\%$ numerical accuracy and human-grade explainability.
  • Nuances of Indian GST Law: Deep-diving into CGST Section 16(2)(aa) (GSTR-2B communication rules), Section 17(5) (blocked credit categories), Rule 36(4), and Rule 37 (180-day payment reversals) taught us how compliance edge cases directly impact an enterprise's working capital and cash flow.
  • Human-in-the-Loop (HITL) Builds Auditor Trust: Finance leaders and CAs will never trust a "black-box" auto-approver for high-value tax decisions. Implementing materiality routing:

$$\text{Auto-Approve if } C_{\text{total}} \ge 0.95 \land |\Delta \text{Tax}| \le \text{INR } 500$$

while routing high-risk anomalies to a Maker-Checker queue with cited law badges turned AI from a liability into an auditable copilot.


🚀 What's Next for ReconMitra

  • Direct GSP (GST Suvidha Provider) & ERP Connectors: Live two-way API integrations with the GSTN portal (auto-fetching GSTR-2B/2A and pushing GSTR-3B Table 4) alongside real-time Tally Prime TDL plugins, Zoho Books, and SAP B1 connectors.
  • Autonomous WhatsApp Business Bot for Vendors: Allowing vendors to reply directly to ReconMitra's automated WhatsApp discrepancy notices with a revised invoice PDF or credit note, triggering instant re-reconciliation.
  • Predictive Vendor Compliance Scoring & Working Capital Financing: Using historical filing delays to predict which QRMP or late-filing vendors will block ITC next month, enabling enterprises to dynamically withhold GST component payments until GSTR-1 filing is verified.

💻 Quick Start & Local Setup

1. Run the Interactive Standalone Prototype

You can launch the full interactive prototype (index.html) directly in any modern browser with zero build steps:

git clone https://github.com/your-org/reconmitra.git
cd reconmitra
open index.html

2. Run the Full-Stack Next.js + FastAPI Environment

# 1. Start the FastAPI Neuro-Symbolic Engine
cd backend
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

# 2. Start the Next.js 14 Frontend Workbench
cd ../frontend
npm install
npm run dev

🏷️ Built With Tags

nextjs react typescript javascript tailwindcss shadcn-ui html5 css3 python fastapi pydantic pandas langchain llamaindex gpt-4o claude-3-5-sonnet postgresql supabase pgvector chromadb pinecone pymupdf ocr rag vercel

Built With

Share this project:

Updates

Submission history