A full-stack AI-powered invoice automation system built using:
- π§ Ollama (Local LLM - Qwen2 / Llama3)
- β‘ FastAPI (Backend API)
- π¨ React + Tailwind (Frontend SaaS UI)
- π Recharts (Analytics Dashboard)
- Reduces manual invoice entry time
- Improves extraction accuracy with AI
- Eliminates dependency on external APIs
- Keeps financial data fully local & secure
- Provides analytics for vendor spending insights
- Upload single or multiple invoice PDFs
- Extract:
- Vendor Name
- Invoice Number
- Invoice Date
- Total Amount
- Tax
- Structured JSON output
- Automatic confidence scoring
- Accuracy metric
- Processing time tracking
- Logs storage (JSON)
- CSV export
- Analytics Dashboard:
- Revenue trend
- Vendor revenue
- Confidence visualization
- Fully local LLM using Ollama (No OpenAI API)
- Step-by-Step Execution
- User uploads PDF
- React sends POST request
- FastAPI stores file
- OCR extracts raw text
- Text is chunked
- Each chunk sent to Ollama
- JSON results returned
- Merge structured fields
- Compute confidence + accuracy
- Save to logs
- Return response to frontend
- UI updates dashboard
User
β
βΌ
Upload PDF
β
βΌ
FastAPI Endpoint (/process-invoice)
β
βΌ
OCR Extraction
β
βΌ
Text Chunking
β
βΌ
Ollama LLM Processing
β
βΌ
JSON Extraction
β
βΌ
Confidence + Accuracy Calculation
β
βΌ
Log Storage
β
βΌ
Frontend Dashboard UpdateReact (Cloud)
β
βΌ
API Gateway
β
βΌ
FastAPI (Dockerized)
β
βββ Worker Queue (Celery)
β
βββ Redis (Task Queue)
β
βββ PostgreSQL (Structured Logs)
β
βββ Ollama Server (Dedicated GPU Machine)ollama servecd backend
uvicorn main:app --reload --port 8000cd frontend
npm install
npm run dev| Layer | Technology |
| ------- | ---------------- |
| UI | React + Tailwind |
| Charts | Recharts |
| Backend | FastAPI |
| OCR | PyMuPDF |
| LLM | Ollama |
| Model | Qwen2 / Llama3 |
| Storage | JSON / CSV |- Invoice Upload (Single/Batch)
- Real-time Processing UI
- Dashboard Analytics
- Logs Table
- CSV Export Trigger
- Confidence Visualization
http://localhost:5173Communicates via REST API.
- Accept file uploads
- Store temporary files
- Extract text using OCR
- Chunk large documents
- Send structured prompts to LLM
- Merge extracted data
- Compute:
- Confidence score
- Accuracy metric
- Processing time
- Save logs
- Serve CSV export
Runs on:
http://localhost:8000PyMuPDF (fitz)
- Extract text from PDF pages
- Handle multi-page documents
- Provide raw text to LLM
- Qwen2:1.5b (fast extraction)
- Llama3:8b (higher reasoning)
- Structured field extraction
- JSON-only response
- Invoice understanding
- Vendor detection
Runs locally:
ollama serve- Smart chunking (for large invoices)
- Per-chunk extraction
- Result merging
- Weighted confidence scoring
- JSON logs file
- CSV export
- WebSocket live progress tracking
- Line-item extraction
- Vendor auto-classification
- Multi-user authentication
- Cloud deployment option
- PostgreSQL
- MongoDB
- Vector DB (for semantic invoice search)
- Accounting Firms
- SMEs managing vendor invoices
- Finance Teams
- Freelance Bookkeepers
- Businesses handling bulk PDF invoices


