Day 06Productivity & FinanceOCRFinanceExcel

FinExtract OCR Agent — AI Agent for receipt data extraction

Automates bookkeeping by extracting receipt data to structured formats.

Impact

Automates bookkeeping by extracting receipt data to structured formats.

Mechanism

OCR + Structured Data Parser

DAY 06
Full README · Case Study

FinExtract AI

Tiny tool to read money from invoices. Fast. Friendly.

Quick demo

  • You drop a PDF invoice.
  • The app finds invoice number, date, vendor, subtotal, tax, and total.
  • You click one big green button. It gives you a CSV.

Start in 3 minutes

Copy these 4 lines. Done.

bash
python -m venv .venv
# Windows
.\.venv\Scripts\pip install -U pip
.\.venv\Scripts\pip install -r requirements.txt
.\.venv\Scripts\python -m streamlit run app.py

Mac/Linux users:

bash
python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -r requirements.txt && streamlit run app.py

Super simple setup (for beginners)

  1. Install Python 3.10 or newer.
  2. Open your terminal.
  3. Paste the 4 commands above.
  4. Put your PDFs ready.
  5. Open the app link in your browser. Smile 🙂

How to use

  1. Upload your invoice PDF.
  2. Click the big button: "Extract & Download CSV".
  3. Save the CSV to your computer.

UI / UX specs

  • Put your mockup here:

    • UI Mockup
      UI Mockup
  • Streamlit Theme (copy to .streamlit/config.toml)

toml
[theme]
base = "light"
primaryColor = "#10B981"          # green
backgroundColor = "#FFFFFF"
secondaryBackgroundColor = "#F7F7F8"
textColor = "#111827"
font = "sans serif"
  • Google Fonts (Inter / Poppins)
html
  • Button style guidance

    • Color: Green (#10B981).
    • Corner radius: 8–12px.
    • Text: Bold, white.
    • Size: Big. Easy to click.
    • Focus ring: Clear, 2px outline.
  • Big green button (HTML/CSS preview)

html

  Extract & Download CSV

Large, friendly, accessible

  • ASCII button (if images not possible)
╔══════════════════════════════════════╗
║          Extract & Download CSV      ║
╚══════════════════════════════════════╝
  • Accessibility
    • aria-label: "Extract and download CSV"
    • Keyboard: Enter/Space triggers button. Tab shows focus ring.

Prompt / LangChain / OpenAI usage

Short prompt for extraction (example):

text
You are a careful extraction bot.
Read the invoice text below and return ONLY valid JSON.
If a value is unknown, omit that key.

Expected JSON keys:
{
  "invoice_number": "string",
  "date": "YYYY-MM-DD",
  "vendor": "string",
  "subtotal": 0.0,
  "tax": 0.0,
  "total_amount": 0.0,
  "line_items": [
    {"description": "string", "qty": 0, "unit_price": 0.0, "amount": 0.0}
  ]
}

Document:
{{document_text}}

Short prompt for classification:

text
You classify this document. Return ONLY JSON:
{"type": "Invoice" | "Receipt" | "Purchase Order" | "Statement"}

Text:
{{document_text}}

Example JSON schema for extracted fields:

json
{
  "invoice_number": "INV-00123",
  "date": "2025-03-17",
  "vendor": "Acme Pvt Ltd",
  "subtotal": 1000.00,
  "tax": 90.00,
  "total_amount": 1090.00,
  "line_items": [
    {"description": "Widget A", "qty": 2, "unit_price": 500.00, "amount": 1000.00}
  ]
}

Export / CSV

Sample CSV header:

csv
doc_type,invoice_number,date,vendor,subtotal,tax,total_amount,_filename

Sample row:

csv
Invoice,INV-00123,2025-03-17,Acme Pvt Ltd,1000.00,90.00,1090.00,invoice_1.pdf

Local CSV download (Streamlit snippet)

python
import pandas as pd
import json
import streamlit as st

# fields is a dict with extracted values
df = pd.json_normalize(fields)
csv_bytes = df.to_csv(index=False).encode("utf-8")

st.download_button(
    label="Download CSV",
    data=csv_bytes,
    file_name="finextract.csv",
    mime="text/csv"
)

st.download_button(
    label="Download JSON",
    data=json.dumps(fields, indent=2).encode("utf-8"),
    file_name="finextract.json",
    mime="application/json"
)

Troubleshooting

  • App does not start
    • Close old Streamlit tabs. Run the command again.
  • Nothing happens after upload
    • Click the big button. Wait a few seconds.
  • Wrong total
    • Check invoice has "Subtotal", "Tax", "Total". Try a clearer PDF.
  • Missing invoice number
    • Look for "Invoice No" or "INV #" near the top. Try another file.
  • OpenAI key issues
    • Create and set OPENAI_API_KEY in your environment, then restart.

FAQ

  • Do I need internet?
    • Yes, for OpenAI. No for pure regex-only mode.
  • Can I use this with Tally?
    • Export CSV and import to Tally or other tools.
  • Does it read images?
    • Focus is PDF. Images may work, but PDF is best.
  • Can I add my own fields?
    • Yes. Update the schema and UI.
  • Is my data safe?
    • Keep keys local. Do not share sensitive docs.

Contributing / Contact / License

  • Pull requests welcome.
  • Open an issue to discuss features.
  • License: MIT

MIT line:

MIT License — do what you want, just include the license.

Images & assets

  • Put mockups here:
    • assets/ui-mockup.png
    • assets/button.png

Folder guide:

project/
  assets/
    ui-mockup.png
    button.png

Quick Theme (copy to .streamlit/config.toml)

toml
[theme]
base = "light"
primaryColor = "#10B981"
textColor = "#111827"
backgroundColor = "#FFFFFF"
secondaryBackgroundColor = "#F7F7F8"
font = "sans serif"

Minimal requirements.txt

txt
streamlit==1.39.0
openai>=1.40.0
langchain>=0.2.12
pytesseract>=0.3.10
pandas>=2.2.2
pillow>=10.4.0

What to change for production

  • Use a secrets manager for OPENAI_API_KEY and any keys.
  • Add document redaction and logging controls.
  • Add tests with a small set of known PDFs and expected outputs.

If stuck, drop a message — I'll help. 🟢

Explore more agents

30 open-source systems · full registry

Browse All 30 Agents