How shivamkrsingh01/invoice_automation works
AI Invoice Automation polls Outlook, extracts and normalizes invoice data, deduplicates it, and stores it in PostgreSQL; an authenticated React dashboard exposes invoice browsing, validation, sync controls, and Q&A. The README documents the end-to-end processing stages, while excerpts show API dispatch, session authentication, extraction helpers, and frontend API calls. Several backend internals are unsampled, so their documented connections use README evidence. A separate watchdog monitors application/database health and can alert through Telegram.
Main entry points: invoice_processor.py Invoice pipeline · client.js API client · routes.py API routes · postgres_storage_service.py Invoice storage
Components 28
Email processing
- Invoice pipeline
app/services/invoice_processor.py - Mail connector
app/services/graph_service.py - Document reader
app/services/document_processor.py - Gemini extraction
app/services/gemini_extraction_service.py - OCR extraction backup
app/services/free_extraction_service.py - Table extraction
app/utils/table_extraction.py
Invoice backend
- App runtime
app/main.py - Field validation
app/utils/validation.py - Invoice deduplication
app/utils/document_dedup_tracker.py - Sync checkpoint
app/utils/timestamp_tracker.py - Invoice model
app/models/invoice.py - Invoice storage
app/services/postgres_storage_service.py - App settings
app/config/settings.py
API and access
- API routes
app/api/routes.py - Session authentication
app/services/auth_service.py - Invoice Q&A
app/services/qa_service.py
Admin dashboard
- API client
invoice-ui/src/api/client.js - Protected routes
invoice-ui/src/components/RequireAuth.jsx - Dashboard
invoice-ui/src/pages/Dashboard.jsx - Invoice pages
invoice-ui/src/pages/Invoices.jsx - Validation page
invoice-ui/src/pages/Validation.jsx - Q&A page
invoice-ui/src/pages/QA.jsx
Stability monitoring
- Health watchdog
stability_monitor/monitor.py - Telegram notifier
stability_monitor/telegram_notifier.py
Other components
- Outlook mailbox
- PostgreSQL
- Admin user
- Telegram
Connections 29
- App runtime → API routes: mounts routes
app/main.py - App runtime → Invoice pipeline: runs polling
app/main.py - App runtime → App settings: reads settings
app/main.py - Outlook mailbox → Mail connector: provides mail
- Invoice pipeline → Mail connector: fetches emails
- Invoice pipeline → Document reader: reads attachments
- Invoice pipeline → Gemini extraction: extracts fields
app/services/gemini_extraction_service.py - OCR extraction backup → Table extraction: parses tables
app/services/free_extraction_service.py - Invoice pipeline → Field validation: normalizes fields
- Invoice pipeline → Invoice deduplication: checks duplicates
- Invoice pipeline → Sync checkpoint: advances checkpoint
- Invoice pipeline → Invoice storage: stores invoices
- Invoice storage → PostgreSQL: reads and writes
- Invoice pipeline → Invoice model: uses invoice records
- API routes → Session authentication: checks sessions
app/api/routes.py - API routes → Invoice pipeline: triggers processing
app/api/routes.py - API routes → Invoice storage: queries invoices
app/api/routes.py - API routes → Invoice Q&A: dispatches questions
app/api/routes.py - Invoice Q&A → Invoice storage: reads invoice data
- Admin user → API client: uses dashboard
- API client → API routes: calls API
invoice-ui/src/api/client.js - Protected routes → API client: checks session
invoice-ui/src/components/RequireAuth.jsx - Dashboard → API client: requests dashboard data
- Invoice pages → API client: requests invoice data
- Validation page → API client: requests validation data
- Q&A page → API client: submits questions
- Health watchdog → PostgreSQL: checks database
stability_monitor/monitor.py - Health watchdog → Telegram notifier: sends alerts
stability_monitor/monitor.py - Telegram notifier → Telegram: delivers messages
stability_monitor/telegram_notifier.py