Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Smart Invoice Classifier (Python + Machine Learning)

A machine learning–based system that automatically extracts text from invoices, processes it using NLP, and classifies invoices into categories such as Rent, Utilities, Supplies, etc.
It provides a REST API for uploading invoices and retrieving classified results, and securely stores all data in a database for analysis.


📌 Project Overview

This project demonstrates how to build an end-to-end invoice classification system using:

  • OCR (Tesseract) to extract text from PDFs
  • NLP + Machine Learning to classify text into categories
  • Flask REST API to expose endpoints for uploading and retrieving invoices
  • MongoDB to store extracted text and classification results
  • Secure data handling (temporary storage, masking sensitive fields)

📂 Project Structure

smart-invoice-classifier/
│
├── data/
│   ├── dummy_invoices/          # Generated sample invoices
│   └── labels.csv               # Ground truth labels for training
│
├── src/
│   ├── extract/
│   │   └── pdf_extractor.py     # OCR and text extraction scripts
│   ├── model/
│   │   └── classifier.py        # Training and inference models
│   ├── api/
│   │   └── routes.py            # Flask API endpoints
│   ├── utils/
│   │   └── __init__.py          # Helper functions
│   └── database/
│       └── mongo_db.py          # DB configuration and operations
│
├── tmp_uploads/                 # Temporary storage for uploaded files
├── requirements.txt
├── README.md
└── main.py                      # Main application entry point

🔧 Key Components

1. Data Extraction (src/extract/pdf_extractor.py)

  • Uses Tesseract OCR for text extraction from PDF invoices
  • Handles various invoice formats and layouts
  • Preprocesses images for better OCR accuracy

2. Machine Learning Model (src/model/classifier.py)

  • NLP preprocessing (tokenization, TF-IDF, word embeddings)
  • Multi-class classification (SVM, Random Forest, or Neural Networks)
  • Model training and evaluation pipelines

3. REST API (src/api/routes.py)

  • POST /upload - Upload invoice PDFs WhatsApp Image 2025-10-09 at 20 49 53_d4608ce1

  • GET /classified - Display invoices from database WhatsApp Image 2025-10-09 at 20 49 15_7951dc53

4. Database (src/database/mongo_db.py)

  • MongoDB integration for storing invoice data
  • Secure storage of extracted text and classifications
  • Efficient querying and retrieval operations image

Demo Video

demo.video.mp4

Commit History

image

Note

  • The project configuration (e.g., port number, MongoDB URL, etc.) is hardcoded instead of using an .env file to allow the recruiter to run the code directly without additional setup.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages