AWS Builder Center
Building DhanSetu.AI: How We Tamed India's ₹10.7L Cr Delayed Payments on AWS Serverless

Building DhanSetu.AI: How We Tamed India's ₹10.7L Cr Delayed Payments on AWS Serverless

An architectural deep-dive into how we built an automated MSME debt recovery and commercial reconciliation engine using Amazon Textract, Bedrock Claude 3 Haiku, Step Functions, and DynamoDB for Bharat Builds 2026.

India's 63 million MSMEs contribute over 30% of the national GDP, yet they remain paralyzed by an estimated ₹10.7 Lakh Crore in delayed payments.
While Section 16 of the MSMED Act mandates a compounding penal interest rate at three times the RBI Bank Rate (16.50% p.a.) and Section 43B(h) of the Income Tax Act levies a direct 30% corporate tax penalty on delinquent buyers, over 90% of recovery claims fail in practice.
We built DhanSetu.AI for the AWS Bharat Builds Hackathon (First Commit Tour 2026) to bridge the chasm between formal legal statutes and the messy ground realities of Indian commerce.



1. The Problem: The Factory Floor vs. The Statute Book

Traditional debt collection and legal drafting tools assume a sanitized world of digital PDFs, cooperative buyers, and clean transaction ledgers. Real Indian trade operates very differently:
  1. Physical Paperwork Chaos: Small factories rely on 3rd-copy carbon paper bills, smudged transporter biltys, and handwritten spot margin deductions (Katoti).
  1. Commercial Ledger Mismatches: Unallocated running account lump sums, arbitrary debit notes, and unverified defect liability retentions lead to contested claims.
  1. Statutory Legal Traps: Complex Supreme Court precedents (like Silpi Industries on Udyam registration timing and Gurpreet Singh on partial payment appropriation) routinely get supplier claims dismissed with costs when handled without legal precision.



2. The Stack: Event-Driven AWS Serverless Pipeline

To achieve sub-second document intelligence and manage multi-day dispute resolution workflows with zero server maintenance, we architected DhanSetu on AWS:
  • Amazon Textract ( AnalyzeExpense ): Ingests multi-page invoices, carbon bill sheets, and transporter biltys, extracting vendor details, tax amounts, line items, and grand totals in ~380ms.
  • Amazon Bedrock (Claude 3 Haiku): Analyzes unstructured debtor WhatsApp deflection messages, classifying stalling excuses (e.g., audit delays, director traveling) and generating statutory counter-reasoning under Section 2(b) deemed acceptance in ~540ms.
  • AWS Step Functions: Orchestrates the multi-day recovery state machine (Tier 1 Amicable Notice → Tier 2 Section 43B(h) Tax Disallowance Warning → Tier 3 MSEFC Samadhaan Filing) with built-in grace period evaluation.
  • Amazon DynamoDB: Single-table design storing immutable claim records, ledger reconciliation states, and audit trails with sub-15ms latencies.
  • Amazon SES & S3: Multi-channel legal notice delivery with verified delivery tracking, paired with S3 encrypted storage for binding settlement deeds and India Post RPAD slips.
  • Amazon CloudWatch: Transparent, real-time structured telemetry stream exposed via an in-app HUD.
  • Next.js 16 (Turbopack) & Tailwind CSS: Delivers a high-engagement frontend with an interactive Time-Decay penalty slider and a debtor direct-resolution portal.



3. What Fought Back: Conquering Real-World Edge Cases

Building DhanSetu was an engineering journey through the friction points of real-world Indian trade:

Challenge A: The Faded Carbon Bill & OCR Digit Hallucination

  • The Struggle: Cheap yellow and pink carbon paper invoices frequently cause OCR models to drop faint strokes or miss a zero—turning a ₹4,50,000 claim into ₹45,000. Citing the wrong figure on a legal demand notice immediately destroys the claimant's credibility.
  • The AWS Solution: We built an automated math checksum layer:  abs((Subtotal + Tax) - Grand Total) < 2.0 . If arithmetic inconsistency is detected, DhanSetu flags an immediate OCR digit hallucination warning and prompts human-in-the-loop verification before drafting legal notices.

Challenge B: The "Kacha Bill" vs. "Pakka Bill" Precedence

  • The Struggle: Goods are often delivered on an informal delivery memo or Bilty (Kacha Bill) on Day 1, while the formal GST invoice (Pakka Bill) is issued 25 days later. Anchoring interest to the invoice date forfeits weeks of statutory interest.
  • The AWS Solution: Per Section 15 of the MSMED Act, the 45-day timer legally anchors to the "appointed day" (the physical delivery date). Our dual-date ingestion engine anchors the statutory clock to the delivery challan date while maintaining full GST compliance.

Challenge C: Handwritten Margin Adjustments ("Katoti")

  • The Struggle: Receiving clerks routinely write margin notes in ballpoint pen: "20 boxes damaged, Katoti -₹3,000". Claiming the unadjusted gross total in court allows the buyer's counsel to dismiss the suit for bad-faith inflated billing.
  • The AWS Solution: Our reconciliation engine parses handwritten margin katoti and unverified TDS deductions, adjusting the legal principal so the claim remains legally bulletproof.

Challenge D: The Supreme Court's Silpi Industries Precedent

  • The Struggle: In Silpi Industries v. KSRTC (2021), the Supreme Court ruled that an enterprise must be registered under MSMED on the date of supply to claim Section 16 penal interest.
  • The AWS Solution: DhanSetu automatically validates Udyam registration dates against invoice dates. If supply pre-dates Udyam registration, it seamlessly pivots the recovery claim to Section 73 of the Indian Contract Act.

Challenge E: Evidence Act Overhaul (Bharatiya Sakshya Adhiniyam, 2023)

  • The Struggle: In mid-2024, Section 65B of the Indian Evidence Act was repealed and replaced by Section 63 of the Bharatiya Sakshya Adhiniyam (BSA). Submitting electronic evidence without a valid Section 63 certificate renders WhatsApp logs and PDFs inadmissible.
  • The AWS Solution: DhanSetu's Tier 3 Dossier generator embeds an automated Section 63 BSA Digital Evidence Certificate complete with SHA-256 cryptographic hashes of all Textract PDFs and WhatsApp logs.



Conclusion & Impact

By combining the speed of AWS Serverless Architecture with ground-level Indian trade realities, DhanSetu AI turns uncollectible invoices into predictable cash flow for Bharat's builders.
  • Live Video Demo: [Included in Hackathon Submission]
  • Built For: AWS Bharat Builds Tour — First Commit 2026
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article