Skip to content
simpliarjunPublic

About

Automated fuel receipt data extraction and expense validation system using Tesseract OCR and Streamlit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Receipt Data Extractor v2.0 - Fuel Edition

Professional fuel receipt data extraction system for Indian businesses with AI-powered validation using Google Gemini API.

Features

  • Multiple Fuel Types: Support for Petrol, Diesel, CNG, Electric, and LPG
  • Fuel-Specific Fields: Each fuel type has optimized data extraction (quantity, price per unit, vehicle registration, odometer reading)
  • Multiple Input Sources: Manual entry, image upload, camera capture, or JSON import
  • AI-Powered Processing: Google Gemini Vision API for intelligent data extraction
  • Live Photo Capture: Take fuel receipt photos directly from the app using your device camera
  • Data Validation: Cross-validation between manual entry and AI extraction
  • Export Options: JSON and CSV formats
  • Record Management: Store, manage, and retrieve fuel expense records
  • Data Backup: Backup and restore functionality

Supported Fuel Types

  1. Petrol (Liters) - Standard petrol station receipts
  2. Diesel (Liters) - Diesel pump receipts
  3. CNG (Kilograms) - Compressed Natural Gas receipts
  4. Electric (kWh) - EV charging station receipts
  5. LPG (Kilograms) - LPG autorickshaw/vehicle receipts

Setup Instructions

1. Install Requirements

pip install -r requirements.txt

2. Configure Gemini API Key (Optional)

The app can work without Gemini API, but for full functionality:

  1. Get your Gemini API key from Google AI Studio
  2. Run the app: streamlit run streamlit_app.py
  3. Go to Settings tab
  4. Enter your API key in the "Gemini API Key" field
  5. Click "Save API Key"

Alternatively, create a .env file:

cp .env.example .env
# Edit .env and add your actual API key

3. Run the Application

streamlit run streamlit_app.py

The app will open at http://localhost:8501

Usage

Select Fuel Type

  1. Open the app
  2. Look at the sidebar on the left
  3. Choose your fuel type: Petrol, Diesel, CNG, Electric, or LPG
  4. The app will adapt all fields for your selected fuel type

Manual Entry

  1. Go to "Extract & Edit" tab
  2. Select "Manual Entry"
  3. Fill in receipt details including:
    • Fuel pump/station name
    • Total amount and tax
    • Quantity of fuel purchased
    • Price per unit
    • Vehicle registration (optional)
    • Odometer reading (optional)
  4. Click "Save & Submit"

Image Processing (Requires Gemini API)

  1. Go to "Extract & Edit" tab
  2. Select "Upload Image"
  3. Upload a fuel receipt image (JPG/PNG)
  4. Gemini will automatically extract fuel-specific data
  5. Review and confirm the extracted data

Camera Capture (Requires Gemini API)

  1. Go to "Extract & Edit" tab
  2. Select "Capture Photo"
  3. Click the camera input to capture photo using your device camera
  4. Gemini will automatically extract data from the photo
  5. Review and confirm the extracted data

JSON Import

  1. Go to "Extract & Edit" tab
  2. Select "Upload JSON"
  3. Upload JSON file with fuel receipt data
  4. Optionally validate with Gemini
  5. Review and submit

View & Export Records

  1. Go to "View Records" tab
  2. See all submitted fuel receipts organized by type
  3. Export as JSON or CSV
  4. Delete specific records

Settings

  • Configure Gemini API key
  • Manage data backups
  • Import existing records

Data Format

All fuel receipt data uses this JSON schema:

{
    "fuel_type": "string (Petrol|Diesel|CNG|Electric|LPG)",
    "merchant_name": "string (Fuel pump/station name)",
    "total_amount": "float (numeric only, no currency)",
    "tax_amount": "float (numeric only, no currency)",
    "quantity": "float (in liters, kg, or kWh depending on fuel type)",
    "price_per_unit": "float (price per liter, kg, or kWh)",
    "date": "string (YYYY-MM-DD format)",
    "address": "string (pump/station address)",
    "vehicle_registration": "string (optional: vehicle number plate)",
    "odometer_reading": "integer (optional: current odometer in km)"
}

Fuel Type Units

  • Petrol: Liters (L)
  • Diesel: Liters (L)
  • CNG: Kilograms (kg)
  • Electric: Kilowatt-hours (kWh)
  • LPG: Kilograms (kg)

File Structure

Image Proc/
├── streamlit_app.py           # Main Streamlit application
├── extract_receipt.py         # Receipt extraction module
├── export_to_form.py          # HTML form generation
├── requirements.txt           # Python dependencies
├── .env.example              # Example environment file
├── .streamlit/
│   └── config.toml           # Streamlit configuration
└── README.md                 # This file

Getting Gemini API Key

  1. Visit Google AI Studio
  2. Click "Create API Key"
  3. Copy the generated API key
  4. Paste it in the Settings page of the app

Troubleshooting

"Gemini API key not configured"

  • Go to Settings and add your API key
  • Ensure the key is valid and has necessary permissions

Image processing fails

  • Ensure image is clear and readable
  • Supported formats: JPG, PNG
  • File size should be reasonable

JSON import errors

  • Verify JSON format matches the schema
  • Use sample_receipt.json as reference

Data Privacy

  • Your API key is stored only in the application session
  • Receipts are processed only when you explicitly submit them
  • No automatic data collection or telemetry
  • All data is stored locally in your Streamlit session

Support

For issues or questions about:

Version

Fuel Receipt Data Extractor v2.0 - Built for Indian Fuel Businesses

About

Automated fuel receipt data extraction and expense validation system using Tesseract OCR and Streamlit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages