Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

78 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’° Fold

AI-Powered Multi-Modal Expense Tracking for India

Track expenses naturallyβ€”just speak, snap a receipt, or type. Fold understands Hinglish, extracts transaction details automatically, and maintains professional double-entry accounting. Built specifically for the Indian payment ecosystem.

πŸš€ Live Demo

[!WARNING]
The backend hosted on Hugging Face Spaces is currently down. As a result, AI extraction, database operations, and other backend functionalities are unavailable. You can, however, still explore the static frontend interface.


⚑ Project at a Glance (For Recruiters)

Fold is a production-grade, multi-modal financial extraction platform that simplifies personal expense management. This project showcases:

  • Advanced AI/ML Pipeline: Integrates local Speech-to-Text (OpenAI Whisper), computer vision and text parsing (PaddleOCR + logo detection), and a custom-trained DistilBERT NLP classifier with 3 classification heads.
  • Accounting Engine: Implements a professional double-entry ledger database schema ensuring transaction integrity, balance protection, and clean audit logs.
  • Hinglish & UPI Ecosystem Specialization: Custom-trained to understand code-mixed Hinglish voice/text and resolve payment profiles (e.g. debiting HDFC Bank when GPay is mentioned).
  • Production-Ready & Cloud-Native: Dockerized with a security-hardened, non-root runner user configuration and automated deploy workflow using GitHub Actions OIDC to Hugging Face Spaces.

πŸ—οΈ How It Works (System Architecture)

Fold uses a sophisticated multi-stage pipeline to extract financial data from any input modality. The system is built for ultra-low latency with synchronous processingβ€”no queues, no polling, just instant results.

Fold System Architecture

Processing Flow:

  1. Input Layer: Text, voice notes, or images (receipts/UPI screenshots)
  2. Extraction Pipeline: Modality-specific processing (STT for audio, OCR for images)
  3. NLP Classification: Custom-trained DistilBERT model predicts category, payment method, and bank account
  4. Ledger System: Professional double-entry accounting with balance validation
  5. Response: Instant confirmation with transaction details

✨ Core Features & Showcase

Fold isn't just an expense trackerβ€”it's a complete financial management system with AI-powered intelligence.

1. Multi-Modal Input Processing

Fold accepts expenses in any format you preferβ€”no forms, no dropdowns, just natural input.

Text Input Demo

🎀 Voice Input: Record voice notes in Hindi, English, or Hinglish. Fold uses OpenAI Whisper to transcribe and automatically extracts transaction details.

Voice Input Demo

πŸ“Έ Image Input:

  • UPI payment screenshots (GPay, PhonePe, Paytm, etc.)
  • Physical receipts and bills
  • Bank statements

Fold automatically detects payment provider logos, extracts amounts, merchants, and payment methods using computer vision + OCR.

Image Input Demo


2. Intelligent AI Extraction & Categorization

Fold's custom-trained NLP model understands the Indian payment ecosystem and Hinglish naturally.

What Fold Extracts:

  • βœ… Amount: Handles β‚Ή symbol, Hindi number words (ΰ€Ήΰ€œΰ€Ύΰ€°, ΰ€²ΰ€Ύΰ€–), currency formats
  • βœ… Category: 10 categories (food, travel, shopping, entertainment, healthcare, education, utilities, EMI, investment, friends)
  • βœ… Payment Method: UPI, card, cash
  • βœ… Payment Provider: GPay, PhonePe, Paytm, Slice, Jupiter, Fi, Niyo, CRED, etc.
  • βœ… Bank/Account: HDFC, ICICI, SBI, Axis, Kotak, and 15+ other Indian banks
  • βœ… Merchant/Description: What the expense was for
  • βœ… Cash Flow: Automatically detects expense vs income

The NLP Engine:

  • Model: Fine-tuned DistilBERT with 3 classification heads
  • Training Data: 42,500+ custom-generated examples
  • Accuracy: ~94% category, ~98% payment method, ~91% bank account
  • Languages: English, Hindi, Hinglish (code-mixed)

NLP Classification


3. Smart Account Resolution & Payment Profiles

Fold automatically figures out which account to charge based on payment method.

Example:

  • You say: "Paid via GPay"
  • Fold knows: Your GPay is linked to HDFC Bank
  • Result: HDFC Bank account is automatically debited

Account Types:

  • πŸ’³ Bank Accounts: Savings/current with institution name and last 4 digits
  • πŸ’° Cash Wallets: Physical cash tracking
  • 🏦 Credit Cards: Debt tracking (can have negative balances)
  • πŸ“± UPI Apps: Linked to bank accounts (GPay β†’ HDFC, PhonePe β†’ Axis, etc.)

Supported Payment Providers: GPay, PhonePe, Paytm, BHIM, CRED, BharatPe, Amazon Pay, Slice, Jupiter, Fi, Niyo, Freecharge, Mobikwik

Account Management


4. Professional Double-Entry Accounting

Fold implements real double-entry bookkeepingβ€”the same system used by accountants and businesses.

Every transaction creates balanced journal entries:

  • Expense: Debit "Expense Account" β†’ Credit "Funding Account" (bank/UPI/cash)
  • Income: Debit "Destination Account" β†’ Credit "Income Account"
  • Investment: Debit "Investment Portfolio" β†’ Credit "Funding Account"
  • Transfer: Debit "To Account" β†’ Credit "From Account"

Why This Matters:

  • βœ… Accuracy: Every rupee is accounted for (debits always equal credits)
  • βœ… Audit Trail: Complete history of where money came from and went to
  • βœ… Professional: Same system used by businesses and accountants
  • βœ… Integrity: Database constraints prevent data corruption
  • βœ… Reporting: Easy to generate balance sheets, income statements, cash flow reports

Balance Protection (3-Layer Guardrails):

  1. Database constraint prevents negative balances on cash/bank accounts
  2. Application layer validates balance before every transaction
  3. Frontend shows clear error messages

Transaction History

Balance Validation: Fold prevents overspending by validating account balances before processing transactions. If your bank balance is less than the expense amount, the transaction is rejected with a clear error message.

Balance Validation


5. Comprehensive Reports & Analytics

Get instant insights into your spending patterns with beautiful visualizations.

Weekly Reports:

  • 7-day rolling window
  • Total income, expenses, investments, net savings
  • Top spending categories
  • Breakdown by payment method
  • Top 5 individual expenses

Monthly Reports:

  • Current month-to-date
  • Same metrics as weekly
  • Longer-term trend analysis

Dashboard Visualizations:

  • πŸ“Š Category pie charts
  • πŸ“ˆ Daily spending trends
  • πŸ’Ή Income vs expense comparison
  • πŸ’³ Account balance cards
  • πŸ” Top expenses list
  • πŸ“‹ Transaction history table

Reports Dashboard


6. Multi-Platform Access

πŸ€– Telegram Bot: Full-featured interface with inline keyboards and wizards.

Commands:

  • /expense β€” Quick expense posting
  • /income β€” Record income
  • /investment β€” Track investments
  • /transfer β€” Transfer between accounts
  • /balance β€” Check account balances
  • /weekly β€” 7-day spending report
  • /monthly β€” Month-to-date report

Features:

  • Voice note support (Hinglish/Hindi/English)
  • Image upload for receipts
  • Interactive category correction
  • Inline dashboard with action buttons
  • Onboarding wizard for account setup

🌐 Web Dashboard: Modern Next.js interface with Clerk authentication.

Features:

  • Real-time dashboard with charts and graphs
  • Transaction history with filtering
  • Account management (add banks, link UPI apps)
  • Period toggle (weekly/monthly views)
  • Responsive design for mobile/desktop
  • Multi-modal input (text, audio, image upload)

πŸ”Œ REST API: Full programmatic access for developers.


πŸ“Š The Complete Pipeline

Text Processing (~1 second)

User Input: "450 rupay Swiggy GPay"
    ↓
NLP Extraction (DistilBERT)
    β”œβ”€β”€ Amount: β‚Ή450
    β”œβ”€β”€ Category: food
    β”œβ”€β”€ Payment Method: upi
    β”œβ”€β”€ Payment Provider: gpay
    └── Bank: hdfc (from GPay profile)
    ↓
Ledger Posting (Double-Entry)
    β”œβ”€β”€ Debit: expense_operating β‚Ή450
    └── Credit: hdfc_bank β‚Ή450
    ↓
Response: "Saved food expense of β‚Ή450. Paid from: HDFC Bank (via GPay). Journal #142."

Voice Processing (~3-5 seconds)

User Input: Voice note "bees rupay ka chai piya"
    ↓
Whisper STT (Speech-to-Text)
    ↓ Transcript: "bees rupay ka chai piya"
    ↓
NLP Extraction (DistilBERT)
    β”œβ”€β”€ Amount: β‚Ή20 (Hindi number word)
    β”œβ”€β”€ Category: food
    β”œβ”€β”€ Payment Method: cash
    └── Bank: cash_wallet
    ↓
Ledger Posting
    ↓
Response: "Recorded β‚Ή20.00 β€” chai. Category: food. Paid from: Cash Wallet."

Image Processing (~5-7 seconds)

User Input: UPI screenshot or receipt photo
    ↓
Stage 1: UPI Logo Detection (Roboflow) ~500ms
    └── Detects: GPay logo β†’ Provider: gpay
    ↓
Stage 2: OCR Text Extraction (PaddleOCR) ~2-3s
    β”œβ”€β”€ Extracts all text lines
    β”œβ”€β”€ Spatial sorting
    β”œβ”€β”€ Keyword scanning (Total, Amount, β‚Ή)
    └── Heuristic parsing (amount, payment method, last4)
    ↓
Stage 3: LLM Structuring (Ollama, optional) ~1-2s
    β”œβ”€β”€ Converts raw OCR to structured JSON
    β”œβ”€β”€ Handles typos and OCR noise
    └── Extracts: amount, merchant, payment details
    ↓
Stage 4: NLP Classification (DistilBERT) ~500ms
    β”œβ”€β”€ Category prediction (10 classes)
    β”œβ”€β”€ Payment method validation
    └── Bank account prediction
    ↓
Stage 5: Result Merging <100ms
    β”œβ”€β”€ Amount: Ollama β†’ OCR β†’ NLP (priority)
    β”œβ”€β”€ Payment Provider: UPI detection β†’ Ollama β†’ OCR
    β”œβ”€β”€ Category: NLP (most accurate)
    └── Bank: Ollama β†’ NLP
    ↓
Ledger Posting
    ↓
Response: Full transaction details with extracted data

Why This Complex Pipeline?

  • UPI screenshots: Clean, structured β†’ Ollama excels
  • Physical receipts: Noisy, varied layouts β†’ OCR heuristics catch edge cases
  • Robustness: Multiple extraction methods provide fallbacks
  • Accuracy: Each stage specializes in what it does best

βš™οΈ Technology Stack

Backend

  • Language: Python 3.11
  • Framework: FastAPI (async web framework)
  • Database: PostgreSQL (Supabase-hosted)
  • Server: Uvicorn (ASGI server)

Machine Learning

  • NLP Model: DistilBERT (HuggingFace Transformers)
  • Framework: PyTorch
  • OCR: PaddleOCR 2.10
  • STT: OpenAI Whisper (local "small" model)
  • Computer Vision: Roboflow Inference API
  • LLM: Ollama (local, llama3.2:3b model)

Frontend

  • Framework: Next.js 16 (React 19)
  • Styling: Tailwind CSS 4
  • Charts: Recharts
  • Authentication: Clerk (OAuth, magic links)
  • Language: TypeScript

Infrastructure & Cloud Architecture

  • Containerization: Docker (custom production-optimized debian-slim image, non-root run user UID 1000)
  • CI/CD Pipeline: GitHub Actions (OIDC-based automated deployment to Hugging Face Spaces)
  • Bot Platform: Telegram Bot API
  • Processing Model: Synchronous low-latency pipeline (no queues, no polling)
  • Deployment Platform: Hugging Face Spaces (Docker SDK)

🎯 Target Users

1. Students

Track daily expenses, manage pocket money, stay within budget. No manual entryβ€”just snap a receipt or say "50 rupees chai."

2. Everyday Users

Monitor household spending, bills, and personal finances. Consolidates all payment methods (bank, UPI, cash, credit cards) in one place.

3. Small Business Owners / Freelancers

Maintain detailed financial records, analyze spending patterns, export data for accounting. Professional-grade accounting without complex software.

4. Hinglish Speakers

Communicate naturally in mixed Hindi-English. No need to translateβ€”speak/type as you normally would.


πŸš€ Key Capabilities at a Glance

  • Multi-Modal Input: Text, voice, and images processed with equal intelligence
  • Hinglish Support: Natural language understanding of code-mixed Hindi-English
  • Indian Payment Ecosystem: Built specifically for UPI, Indian banks, and payment apps
  • Smart Account Resolution: Automatically figures out which account to charge
  • Professional Accounting: Double-entry ledger system with balance validation
  • Privacy-Focused: All ML models run locally, no data sent to cloud AI services
  • Zero Learning Curve: Natural language input, no forms or categories to remember
  • Continuous Learning: Gets smarter from user corrections
  • Real-Time Processing: Synchronous pipeline with instant feedback (<7s for images)
  • Multi-Platform: Telegram bot + Web dashboard + REST API

Built to make expense tracking effortless for India.

Track naturally. Understand instantly. Stay in control.

About

A project to replicate the functionality of fold.money

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages