AI and automation application that processes digital receipts (images and PDFs), extracts key data via OCR, manages states in a database, and coordinates approval flows through interactive emails.
Table of Contents
This application automates receipt processing and approval using modern Computer Vision and AI technologies. It facilitates the receipt lifecycle from reception to final resolution.
Key Features:
- Intelligent Processing: Text extraction from images and PDFs and identification of fields (Amount, Date, Vendor) using Tesseract OCR and RegEx.
- State Management: SQLite database to track the lifecycle ("In Process" → "Approved" / "Rejected").
- Interactive Notifications: HTML email delivery with functional buttons to approve or reject receipts directly.
- RESTful API: Backend built with FastAPI to upload files and handle decision Webhooks.
- Audit: Automatic recording of timestamps and justification comments.
Follow these steps to set up the project locally.
- Python 3.8 or higher.
- Tesseract OCR: Must be installed on the operating system.
- Windows: Download installer here. Important: Select "Spanish" (spa) language in "Additional script data" during installation.
- Poppler for Windows: Required to convert PDFs to images. Ensure the path matches
POPPLER_PATHinocr_engine.py. - Gmail Account: With a generated "App Password" for email sending.
- Clone the repo
git clone https://github.com/jerichd4c/receipt-manager.git
- Create and activate virtual environment
python -m venv venv .\venv\Scripts\Activate # Windows: .\venv\Scripts\Activate, Linux/Mac: source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
Create a .env file in the root (based on .env.sample) and configure your variables:
| Variable | Description | Example |
|---|---|---|
DATABASE_URL |
DB connection string | sqlite:///./receipts.db |
SMTP_SERVER |
Email server | smtp.gmail.com |
SENDER_EMAIL |
Your email (sender) | youremail@gmail.com |
SENDER_PASSWORD |
App Password (16 characters) | abcd efgh ijkl mnop |
API_URL |
Base URL where the API runs | http://localhost:8000 |
EMAIL_GERENTE |
Email that will receive requests | manager@example.com |
- Start the server:
python run.py
- Access the interface:
Open your browser at
http://127.0.0.1:8000/docsto see the Swagger UI. - Full Flow:
- Upload a receipt via
POST /api/upload. - Receive email notification with decision buttons.
- Click "Approve" or "Reject" and verify the state change in the database.
- Upload a receipt via
For more details on the architecture, check ocr_engine.py and notifications.py files.
- FastAPI - Modern and fast backend.
- Tesseract OCR - Text recognition engine.
- SQLAlchemy - Robust database management.
- OpenCV - Image processing.