Autonomous Payment Ingestion, Dual OCR/LLM Extraction, Deterministic Bank Ledger Parsing, and Multi-Tier Reconciliation Workbench
In high-volume peer-to-peer (P2P), merchant, and remittance ecosystems, operators receive thousands of payment screenshots daily across communication channels like WhatsApp. Manual verification against official bank accounts is agonizingly slow, prone to oversight, and highly susceptible to forged receipts, recycled transaction IDs (UTRs), and duplicate claims.
FinAudit AI solves this with an end-to-end, multi-stage, zero-trust verification pipeline:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β 1. Ingestion β ββββΊ β 2. Dual Extract β ββββΊ β 3. Bank Parser β
β WhatsApp Web β β OCR + LLM Intel β β PDF / CSV Ledgerβ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββββ βββββββββββββββββββ βΌ
β 6. Owner Report β ββββ β 5. Review UI β ββββ βββββββββββββββββββ
β Executive Audit β β Next.js Ranking β β 4. Arbiter β
βββββββββββββββββββ βββββββββββββββββββ β Multi-Tier Matchβ
βββββββββββββββββββ
- π΅οΈ Real-Time WhatsApp Ingestion: Automated, resumable scraper capturing messages, timestamps, sender profiles, and full-resolution screenshot media.
- ποΈ Hybrid Computer Vision & OCR: Image thresholding, contrast enhancement, and multi-engine OCR (PaddleOCR / EasyOCR / Tesseract) extracting raw transaction tokens.
- π§ Dual-Brain Entity Refinement:
- Fast Heuristic Extractor: Direct pattern matching for instantaneous UTR, UPI, Amount, and Date discovery.
- LLM Intelligence Router: Structured JSON generation powered by Gemini, GPT-4o, Claude 3.5, or Groq with confidence scoring and self-healing schema normalization.
- π¦ Deterministic Bank Statement Standardization: Extracts and normalizes complex tabular statement PDFs (Yes Bank, HDFC, ICICI, SBI) and Google Pay exports into standardized daily transaction ledgers.
- βοΈ Multi-Tiered Reconciliation Arbiter: Links payment claims against official bank ledger rows using exact reference matching, tokenized fuzzy sender-name matching, amount windows, and timestamp tolerances.
- π‘οΈ Anti-Fraud & Duplicate Prevention: Automatically flags duplicate UTRs across dates/groups, detects recycled transaction screenshots, and isolates altered amounts.
- π₯οΈ Interactive Operator Workbench (Next.js 15 + Tailwind + FastAPI):
- Side-by-side evidence viewer with zoom and metadata inspector
- AI Candidate Ranking: Intelligently scores and ranks potential bank statement matches for unmatched claims
- Non-Destructive Overlays: Append-only manual corrections and overrides without altering immutable raw upstream evidence
- π Executive & Owner Reporting: Generates comprehensive daily settlement reports, discrepancy audits, and printable statements for administrative submission.
flowchart TD
subgraph INGESTION["1. Ingestion Zone (WhatsApp Scraper)"]
W[WhatsApp Web DOM] -->|Playwright Scraper| SC[Message & Media Parser]
SC -->|Store RAW JSON| M[messages.json]
SC -->|Preserve Evidence| IMG[HD Screenshots / Media]
end
subgraph EXTRACTION["2. Extraction Zone (OCR & Heuristics)"]
IMG --> CV[OpenCV Preprocessing]
CV --> OCR[OCR Engine]
OCR --> DIR[Direct Regex Extractor]
DIR --> OCRR[ocr_results.json]
end
subgraph INTELLIGENCE["3. Intelligence Zone (LLM Refiner)"]
OCRR --> ROUTER{Confidence Router}
ROUTER -->|Low Confidence / Complex| LLM[LLM Refiner: Gemini / OpenAI / Groq]
ROUTER -->|High Confidence| PASS[Pass-Through]
LLM --> LLMR[llm_refined.json]
PASS --> LLMR
end
subgraph LEDGER["4. Ledger Zone (Bank Statement Engine)"]
PDF[Bank Statement PDFs / CSVs] --> BP[Bank Processor Engine]
BP -->|Camelot / PDFPlumber| STD[Account Normalizer]
STD --> LEDGER_JSON[Standardized Ledger JSON]
end
subgraph ARBITER["5. Reconciliation Arbiter"]
LLMR --> MATCH[Multi-Tier Matching Engine]
LEDGER_JSON --> MATCH
MATCH --> DUP[Duplicate & Fraud Detector]
DUP --> RECON[Auto-Reconciliation Summary]
end
subgraph WORKBENCH["6. Human-in-the-Loop Workbench (Next.js + FastAPI)"]
RECON --> API[FastAPI Backend /api/*]
API --> UI[Next.js 15 Review Workbench]
UI --> RANK[Candidate Suggestion Engine]
UI --> CORR[Append-Only Manual Overlays]
UI --> AUDIT[Immutable Audit Trail]
end
subgraph REPORT["7. Executive Reporting"]
AUDIT --> REP[Executive Owner Report & PDF Statement]
end
classDef ing fill:#e1f5fe,stroke:#0288d1,stroke-width:2px;
classDef ext fill:#fff3e0,stroke:#f57c00,stroke-width:2px;
classDef intel fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px;
classDef led fill:#e8f5e9,stroke:#388e3c,stroke-width:2px;
classDef arb fill:#fce4ec,stroke:#c2185b,stroke-width:2px;
classDef work fill:#ede7f6,stroke:#512da8,stroke-width:2px;
classDef rep fill:#e0f2f1,stroke:#00796b,stroke-width:2px;
class INGESTION ing;
class EXTRACTION ext;
class INTELLIGENCE intel;
class LEDGER led;
class ARBITER arb;
class WORKBENCH work;
class REPORT rep;
The system uses a strict Date-First Architecture (data/{YYYY-MM-DD}/) ensuring complete temporal isolation, crash safety, and compliance-grade auditability:
data/
βββ {YYYY-MM-DD}/ # Root Date Scope
βββ whatsapp/
β βββ {group_name}/
β βββ messages.json # Raw Ingested Chat Metadata
β βββ img_001.jpg # Full-Resolution Transaction Screenshot
β βββ ocr_results.json # Raw OCR Tokens & Heuristic Extractions
β βββ llm_refined.json # AI-Refined Canonical JSON Data
βββ statements/
β βββ YES_BANK_0913.json # Normalized Bank Ledger (YES Bank)
β βββ HDFC_CORP_4821.json # Normalized Bank Ledger (HDFC)
β βββ gpay-PRIMARY_0000.json # Normalized Google Pay Ledger
βββ reconciliation/
βββ ocr_reconciliation.json # Auto Phase-1 Matching Artifact
βββ final_reconciliation.json # Auto Phase-2 Matching Artifact
βββ manual_reconciliation.json # Non-Destructive Manual Operator Links
βββ manual_corrections.json # Field Correction Patches (Applied at Read)
βββ review_actions.json # Append-Only Event & Audit Log
π‘οΈ Zero-Destruction Guarantee: Raw evidence is NEVER overwritten. Manual corrections and matches are stored as append-only event streams merged dynamically at runtime.
- Headless & Visible Playwright Automation: Robust WhatsApp Web session controller.
- Resumable Extraction: Remembers message markers; recovers instantly upon network blips.
- Media Preservation: Captures pristine HD images, audio voice notes, and contextual reply quotes.
- Adaptive Image Preprocessing: Grayscale filtering, contrast equalization, and noise removal.
- Multi-Engine Pipeline: PaddleOCR, Tesseract, and EasyOCR fallbacks.
- Direct Heuristic Parser: Regex mining for 12-digit Indian Financial System UTRs, UPI Reference IDs, βΉ Amounts, and Timestamps.
- Multi-Provider Support: Pluggable backends for Google Gemini (Flash / Pro), OpenAI (GPT-4o / GPT-4o-mini), Groq (Llama-3), and Anthropic (Claude 3.5).
- Batch Processing & Token Optimization: Batches noisy OCR text into structured JSON schemas.
- Self-Healing Normalization: Cleans OCR character misreads (e.g.,
Ovs0,Ivs1, currency symbol variations).
- Multi-Bank Format Parsers: Native extractors for Yes Bank, HDFC, ICICI, SBI, Axis, Kotak, and Google Pay Business.
- Hybrid PDF Extraction: Combines
pdfplumber,camelot-py, and OCR for non-selectable scanned PDFs. - Narrative Classifier: Dissects complex bank statement strings into Payer Name, Bank UPI Reference, Remitter Account, and Mode (IMPS/NEFT/UPI/RTGS).
- Multi-Tier Matching:
- Tier 1 (Exact UTR Match): 100% confidence link on 12-digit reference.
- Tier 2 (Amount + Fuzzy Name + Time Window): Tokenized name similarity scoring (
SequenceMatcher+ token intersections) within configured time tolerances. - Tier 3 (Account-Level Routing): Segregates deposit vs withdrawal streams.
- Fraud & Duplicate Prevention: Flags recycled screenshots, double-claimed transactions, and timestamp anomalies.
- Modern Next.js 15 UI: Built with React 19, TypeScript, TanStack React Query, and Tailwind CSS.
- Candidate Suggestion Engine: Automatically ranks top bank statement matches for unverified claims with confidence badges.
- Side-by-Side Verification: Inspect high-res receipt images right next to bank statement rows.
- Field Patching & Overrides: Correct OCR misread amounts or UTRs on the fly with reversible audit logging.
- Generates clean operational summaries with total volume, matched counts, unmatched amounts, and flagged fraud cases.
- Exportable and printable daily accounting reconciliation sheets.
| Layer | Technologies |
|---|---|
| Backend & Core | Python 3.10+, FastAPI, Pydantic v2, Uvicorn, Playwright |
| Data & Financial Processing | Camelot-py, pdfplumber, OpenCV, NumPy, Pandas, Loguru |
| OCR & AI Extraction | PaddleOCR, Tesseract, EasyOCR, Google Gemini API, OpenAI API, Groq |
| Frontend Dashboard | Next.js 15.1, React 19, TypeScript, Tailwind CSS, TanStack Query |
| State & Artifacts | Date-Partitioned Atomic JSON Filesystem, Append-Only Event Logs |
# Clone the repository
git clone https://github.com/your-username/finaudit-ai.git
cd finaudit-ai
# Create and activate Python virtual environment
python -m venv .venv
# On Windows PowerShell:
.\.venv\Scripts\Activate.ps1
# On Linux/macOS:
source .venv/bin/activate
# Install Python dependencies
pip install -r requirements.txt
playwright install chromiumCreate a config.json in the root directory (never commit this file):
{
"ENVIRONMENT": "production",
"LLM_PROVIDER": "gemini",
"GEMINI_API_KEY": "YOUR_GEMINI_API_KEY_HERE",
"OPENAI_API_KEY": "YOUR_OPENAI_API_KEY_HERE",
"GROQ_API_KEY": "YOUR_GROQ_API_KEY_HERE",
"DATA_DIR": "./data",
"INPUT_STATEMENTS_DIR": "./input_statements",
"SCRAPER": {
"HEADLESS": false,
"BROWSER_TIMEOUT_MS": 60000,
"SCROLL_DELAY_MS": 1200
},
"RECONCILIATION": {
"TIME_TOLERANCE_HOURS": 24,
"FUZZY_NAME_THRESHOLD": 0.75
}
}cd frontend
npm install
npm run build# Scrapes designated WhatsApp groups for a specific date
python apps/scrape.py --group "Main Payment Group" --date 2026-08-22# Extracts raw text and heuristic markers from all downloaded screenshots
python apps/run_ocr.py --date 2026-08-22# Refines noisy OCR outputs into validated structured JSON
python apps/run_refiner.py --date 2026-08-22# Drop your PDF / CSV bank statements in ./input_statements/ and process:
python apps/run_bank_processor.py --date 2026-08-22# Run auto-matching arbiter across claims and bank statement ledgers
python apps/reconcile.py --date 2026-08-22 --phase final# Start FastAPI backend (port 8000)
python apps/review_api.py
# In a separate terminal, start Next.js frontend (port 3000)
cd frontend
npm run devVisit http://localhost:3000 in your browser to access the interactive review workbench!
| Metric / Capability | β Manual Auditing | β‘ FinAudit AI Platform | |
|---|---|---|---|
| Speed (1,000 claims) | 6 - 8 Hours | 15 - 20 Minutes | < 60 Seconds |
| Noisy Screenshot Handling | High Human Fatigue | Fails on font/layout changes | Dual CV + LLM Self-Healing |
| Bank Statement Parsing | Manual CSV cross-check | Broken by multi-page PDFs | Multi-bank deterministic engine |
| Fraud & Duplicate Detection | High Risk of Oversight | Basic exact matches only | Cross-date UTR & fuzzy detection |
| Candidate Ranking | None | None | Algorithmic top-N ranked match cards |
| Audit Provenance | None | Overwrites data | 100% Immutable Append-Only Event Trail |
- Financial Data Isolation: All raw images, bank statement PDFs, and financial ledgers are kept inside local date-partitioned storage (
data/andinput_statements/), which are strictly excluded via.gitignore. - Zero Raw Data in Commits: Never commit client bank records, customer phone numbers, or active session cookies to public repositories.
- Redaction Ready: The LLM prompt builder includes automated token masking for non-essential PII.
Contributions, feature requests, and issue reports are warmly welcomed!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Made with β€οΈ for high-throughput, fraud-proof financial operations.