DEV Community

Nitin Sharma
Nitin Sharma

Posted on

ParchiPay: Channeling Your Inner Sloth with Gemma & LangGraph to Turn Messy Scribbled "Parchis" into Instant Paid Invoices

Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady


What I Built

Tomorrow is International Sloth Day, and sloths have life figured out: move at your own pace, conserve energy, and let the world spin without stressing out.

If there is one person on earth who desperately deserves to channel their inner sloth, it’s the independent trade contractor and hardware merchant (electricians, plumbers, carpenter shops, fabrication subcontractors).

Every day, contractors lose hours to the single most dreaded, brain-draining task in their business: manual estimating and quoting.

  • Job materials are hastily scribbled on torn scrap slips of paper called "parchis" (often crinkled, covered in grease or cement dust).
  • Details are rattled off in 10-second bilingual or Hinglish voice notes ("Bhaiya 5 coil Finolex 2.5 wire, 10 Anchor switch aur PVC pipe note kar lo").
  • Contractors then spend 45 minutes manually deciphering handwriting, opening Excel sheets, looking up catalog SKUs, calculating 18% GST, checking warehouse shelves to see if they're out of stock, and manually drafting restock orders to suppliers.
  • Worst of all, they suffer severe revenue leakage: they quote ₹25,000 worth of wire and conduit pipes, but completely forget to bill for concealing labor and wire-pulling charges.

We built ParchiPay (powered by QuoteFlow AI) — an autonomous, human-in-the-loop quoting and inventory agent that lets contractors be totally lazy.

What ParchiPay Does in 15 Seconds:

  1. Snap & Speak: Take a quick photo of the messy paper parchi and/or record a voice note.
  2. Multimodal Cognition with Gemma: Open-weight Gemma parses the handwritten slip, cross-reconciles it with the audio transcript, and fuzzy-matches raw vernacular descriptions into standardized catalog SKUs.
  3. Deterministic Inventory & GST Math: Checks stock across a 3-Tier Storage Matrix (HEALTHY, THRESHOLD_WARNING, INSTANT_DEFICIT) and computes line-item GST without LLM math hallucinations.
  4. Cognitive Revenue Guard: Gemma audits the quoted materials, spots missing companion services (e.g., "You quoted wiring and conduits but forgot installation labor"), and suggests billable add-ons.
  5. Autonomous Supplier Purchase Orders: If materials are out of stock, it automatically groups deficits by supplier and drafts Restock Purchase Orders.
  6. Human-In-The-Loop Approval & Dispatch: The contractor glances at the dashboard, toggles the suggestions with one tap, and approves. ParchiPay immediately generates a customer portal link, sends a Brevo transactional email, and prepares a WhatsApp wa.me instant invoice link.

Demo

graph TD
    A[Messy Paper Parchi / Image] --> B[OpenCV Image Preprocessor]
    C[Hinglish Voice Note / Audio] --> D[Speech Transcription]
    B --> E[Node 1: Gemma Multimodal Extractor]
    D --> E
    E --> F[Catalog SKU Fuzzy Matcher]
    F --> G[Node 2: Deterministic 3-Tier Inventory & GST Engine]
    G --> H[Node 3: Gemma Cognitive Revenue Guard & Python PO Drafter]
    H --> I{HITL Interrupt Gate<br/>Neon PostgresSaver}
    I -->|Merchant Review & 1-Tap Toggle| J[Node 4: Execute & Dispatch Engine]
    J --> K[Atomic DB Commit]
    J --> L[WhatsApp wa.me Invoice Link]
    J --> M[Brevo Email Dispatch]
    J --> N[Customer Self-Serve Payment Portal]

Visual Walkthrough:

  • Technician Portal: Technicians capture paper parchis or speak into the microphone on-site.
  • Merchant Review Dashboard: Displays the itemized breakdown, confidence scores for messy handwriting, stock deficit alerts, and AI revenue add-on suggestions.
  • Customer Portal: Clean, mobile-friendly invoice portal with line items, tax breakdowns, and one-tap approval.

Code


The repository is modularly structured into three core components:

  • /Agent: Python 3.11 LangGraph state machine, Gemma multimodal LLM factory, Pydantic contracts, and Neon PostgreSQL checkpointing.
  • /Backend: Node.js / Express TypeScript service handling API routing, Brevo transactional email dispatch, WhatsApp link generation, and database pooling.
  • /frontend: React 19 + Vite + Tailwind CSS dashboard providing responsive Technician, Merchant Admin, and Client Self-Serve Portals.
  • render.yaml: Infrastructure-as-Code for zero-downtime deployment on Render.

How I Built It

ParchiPay is engineered from the ground up around open-source AI and transparent agent orchestration:

1. Open-Weight Vision & Reasoning: Gemma

We used Google's open-weight Gemma family (gemma-4-26b-a4b-it) via Google AI Studio. Gemma is the cognitive core responsible for:

  • Reading low-contrast, cursive, and vernacular handwriting on paper parchis.
  • Cross-reconciling discrepancies between the image and speech transcripts (e.g., if the slip says "2 coils" but the voice note says "make that 5 coils", Gemma resolves the true customer intent).
  • Semantic catalog mapping from messy trade slang to strict SKU IDs (SKU-WIRE-25, SKU-PVC-25).
  • Performing the Cognitive Revenue Guard audit to identify missing installation labor and accessories.

2. Open-Source Agent Harness: LangGraph StateGraph

Instead of unpredictable autonomous loops, we structured the pipeline into a 4-node deterministic LangGraph state machine:

builder = StateGraph(QuoteFlowState)

# 4 Specialized Nodes
builder.add_node("multimodal_extractor_node", multimodal_extractor_node)
builder.add_node("inventory_and_billing_analyzer_node", inventory_and_billing_analyzer_node)
builder.add_node("revenue_and_procurement_node", revenue_and_procurement_node)
builder.add_node("execute_dispatch_node", execute_dispatch_node)

# Linear flow with HITL interrupt before final dispatch
builder.add_edge(START, "multimodal_extractor_node")
builder.add_edge("multimodal_extractor_node", "inventory_and_billing_analyzer_node")
builder.add_edge("inventory_and_billing_analyzer_node", "revenue_and_procurement_node")
builder.add_edge("revenue_and_procurement_node", "execute_dispatch_node")
builder.add_edge("execute_dispatch_node", END)

# Pauses state in Neon PostgreSQL for vendor review
graph = builder.compile(interrupt_before=["execute_dispatch_node"])
Enter fullscreen mode Exit fullscreen mode

3. Separation of Cognition and Arithmetic (Zero Math Hallucination)

A classic flaw in AI billing apps is letting the LLM calculate sums and taxes — leading to rounding errors and hallucinations. In ParchiPay:

  • Gemma does strictly what it's best at: Perception, unstructured text parsing, fuzzy matching, and creative companion service auditing.
  • Python & PostgreSQL do the math: GST rates (5%, 12%, 18%), line totals, 3-tier deficit formulas (order_qty = deficit_qty + reorder_threshold), and rate-card pricing are executed deterministically.
  • All structured outputs are bound via strict Pydantic schemas (ExtractionOutput, RevenueAuditOutput).

4. Image Preprocessing with OpenCV

Real parchis are taken under bad lighting with shadows. We use OpenCV with CLAHE (Contrast Limited Adaptive Histogram Equalization) and single-tile 768px downscaling to boost handwriting contrast and save ~38,000 unnecessary tokens.


Why Does Open Innovation Matter?

Open innovation is what makes ParchiPay viable for real-world small businesses:

  1. Privacy & Data Sovereignty for Local Merchants: Small contractors and hardware suppliers operate on confidential trade margins, private client phone numbers, and negotiated supplier wholesale costs. Feeding proprietary customer lists and invoices into opaque, closed commercial APIs poses real vendor-lockin and confidentiality risks. Open-weight models like Gemma give businesses the freedom to run inference in private VPCs or on on-premises workstations.
  2. Architectural Freedom & Modularity: Closed APIs force developers into rigid, proprietary tool-use ecosystems. Open frameworks like LangGraph paired with open models allow us to intercept state, pause execution in our own PostgreSQL checkpointer (PostgresSaver), and inject human decisions without relying on proprietary platform lock-in.
  3. Economics for Micro-Businesses: Tradespeople run on tight margins. When processing dozens of daily estimates, closed commercial API fees destroy unit economics. Open weights allow high-throughput batching, fine-tuning on regional handwriting (such as Devanagari numerals and local trade terms), and predictable operational costs.

The Lazy Payoff

International Sloth Day is all about doing the least work for the maximum reward. Here is how ParchiPay turns hours of dreaded manual labor into effortless sloth mode:

Traditional Contractor Quoting The ParchiPay Sloth Workflow
Time: 30 to 45 minutes per quote Time: Under 30 seconds total
Squinting at dirty paper slips & deciphering numbers AI reads messy handwriting & voice notes instantly
Manually typing items into Excel or billing software Automatic SKU mapping to local warehouse catalog
Calculating GST rates and line totals on a desk calculator Instant deterministic math with zero human errors
Walking to the warehouse to check stock levels 3-Tier inventory alerts tell you what’s in stock
Forgetting installation labor (revenue lost!) Revenue Guard alerts you to missed billable labor
Calling suppliers to restock missing items Auto-drafted Restock Purchase Orders grouped by vendor
Manually composing emails or messaging customers 1-Click WhatsApp & Brevo email delivery to client

Real-world impact: Instead of coming home exhausted after a 10-hour job on-site only to sit in front of a laptop doing paperwork until midnight, the contractor takes a photo, speaks a voice note while drinking evening chai, clicks "Approve", and lets ParchiPay do the rest.


Prize Categories

1. Best Use of Gemma

ParchiPay relies on Gemma (gemma-4-26b-a4b-it) as the central cognitive engine across multiple stages:

  • Multimodal Handwriting Perception: Transcribes complex, low-quality physical paper estimate slips (parchis).
  • Cross-Modal Reconciliation: Resolves discrepancies between speech transcripts and written text.
  • Catalog SKU Mapping: Fuzzy-maps colloquial phrasing into structured catalog SKUs.
  • Cognitive Revenue Guard: Audits quoted materials against missing trade services and accessory items to prevent revenue leakage, returning strictly validated Pydantic JSON schemas.

2. Best Use of Render

ParchiPay is configured for full cloud deployment via Render using our declarative Infrastructure-as-Code render.yaml:

  • quoteflow-backend: Express & TypeScript web service with built-in health check monitoring (/health), connecting to cloud serverless Neon PostgreSQL.
  • quoteflow-frontend: React 19 / Vite static web service with single-page app rewrites (/* -> /index.html) and automatic environment variable binding from the backend host.

Team Submissions

Built with ❤️ for Hacktoberfest 2026 by:

  • Nitin (@n1t1n-cyber) - Backend Architecture, Email Services (Brevo), WhatsApp Integration & APIs
  • Siddharth Gupta (@siddg1161) - LangGraph Agent Orchestration, Gemma Factory & Neon DB Pipeline
  • Ravi Bhawsar (@raviggbhawsar9090) - Frontend Architecture, Dashboards & Portals

Top comments (0)