# essamdev47/-ai-invoice-processor architecture

> Architecture diagram of the GitHub repository essamdev47/-ai-invoice-processor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/essamdev47/-ai-invoice-processor
- Repository: https://github.com/essamdev47/-ai-invoice-processor

## Overview

AI Invoice Processor is a Streamlit application for uploading invoices and other documents, extracting text and structured fields, and reviewing and storing results. Its main path runs from upload through OCR and AI parsing to invoice persistence; the app also provides dashboard/history views and Excel export. Batch processing is a separate supported route. Source excerpts establish the batch calls and app dependencies, but omit most app control flow, so several UI-to-service links are documented or unverified rather than asserted as direct calls.

Main entry points: [`app.py`](https://github.com/essamdev47/-ai-invoice-processor/blob/main/app.py) (Streamlit app), [`batch_processor.py`](https://github.com/essamdev47/-ai-invoice-processor/blob/main/batch_processor.py) (Batch processor), [`ai_extractor.py`](https://github.com/essamdev47/-ai-invoice-processor/blob/main/ai_extractor.py) (AI field extraction), [`data_handler.py`](https://github.com/essamdev47/-ai-invoice-processor/blob/main/data_handler.py) (Invoice database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["Streamlit app<br/>[app.py]"]
  node_dashboard["Dashboard and history<br/>[app.py]"]
end

subgraph group_processing["Document processing"]
  node_batch["Batch processor<br/>[batch_processor.py]"]
  node_ocr["OCR and PDF reader<br/>[ocr_engine.py]"]
  node_extract["AI field extraction<br/>[ai_extractor.py]"]
end

subgraph group_persistence["Persistence and export"]
  node_cache[("Extraction cache<br/>[cache_manager.py]")]
  node_store[("Invoice database<br/>[data_handler.py]")]
  node_excel["Excel export<br/>[data_handler.py]"]
end

node_user(("User"))
node_groq{{"Groq AI service"}}

node_user -->|"uploads documents"| node_app
node_app -.->|"extracts text"| node_ocr
node_app -.->|"parses fields"| node_extract
node_app -.->|"dispatches batch"| node_batch
node_batch -->|"extracts text"| node_ocr
node_batch -->|"parses text"| node_extract
node_batch -->|"saves batch"| node_store
node_extract -->|"reads and writes"| node_cache
node_extract -->|"requests extraction"| node_groq
node_app -.->|"reads and writes"| node_store
node_app -.->|"exports records"| node_excel
node_store -.->|"supplies invoice data"| node_dashboard
node_user -.->|"views records"| node_dashboard

click node_app "https://github.com/essamdev47/-ai-invoice-processor/blob/main/app.py"
click node_batch "https://github.com/essamdev47/-ai-invoice-processor/blob/main/batch_processor.py"
click node_ocr "https://github.com/essamdev47/-ai-invoice-processor/blob/main/ocr_engine.py"
click node_extract "https://github.com/essamdev47/-ai-invoice-processor/blob/main/ai_extractor.py"
click node_cache "https://github.com/essamdev47/-ai-invoice-processor/blob/main/cache_manager.py"
click node_store "https://github.com/essamdev47/-ai-invoice-processor/blob/main/data_handler.py"
click node_excel "https://github.com/essamdev47/-ai-invoice-processor/blob/main/data_handler.py"
click node_dashboard "https://github.com/essamdev47/-ai-invoice-processor/blob/main/app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_dashboard,node_user toneBlue
class node_batch,node_ocr,node_extract toneAmber
class node_cache,node_store,node_excel toneMint
class node_groq toneIndigo
```

## Components

### User interface

- [Streamlit app](https://github.com/essamdev47/-ai-invoice-processor/blob/main/app.py): `app.py`
- [Dashboard and history](https://github.com/essamdev47/-ai-invoice-processor/blob/main/app.py): `app.py`

### Document processing

- [Batch processor](https://github.com/essamdev47/-ai-invoice-processor/blob/main/batch_processor.py): `batch_processor.py`
- [OCR and PDF reader](https://github.com/essamdev47/-ai-invoice-processor/blob/main/ocr_engine.py): `ocr_engine.py`
- [AI field extraction](https://github.com/essamdev47/-ai-invoice-processor/blob/main/ai_extractor.py): `ai_extractor.py`

### Persistence and export

- [Extraction cache](https://github.com/essamdev47/-ai-invoice-processor/blob/main/cache_manager.py): `cache_manager.py`
- [Invoice database](https://github.com/essamdev47/-ai-invoice-processor/blob/main/data_handler.py): `data_handler.py`
- [Excel export](https://github.com/essamdev47/-ai-invoice-processor/blob/main/data_handler.py): `data_handler.py`

### Other components

- **User**
- **Groq AI service**

## Connections

- User → Streamlit app: uploads documents (evidence: `README.md`)
- Streamlit app → OCR and PDF reader: extracts text (evidence: `app.py`)
- Streamlit app → AI field extraction: parses fields (evidence: `app.py`)
- Streamlit app → Batch processor: dispatches batch (evidence: `app.py`)
- Batch processor → OCR and PDF reader: extracts text (evidence: `batch_processor.py`)
- Batch processor → AI field extraction: parses text (evidence: `batch_processor.py`)
- Batch processor → Invoice database: saves batch (evidence: `batch_processor.py`)
- AI field extraction → Extraction cache: reads and writes (evidence: `ai_extractor.py`)
- AI field extraction → Groq AI service: requests extraction (evidence: `ai_extractor.py`)
- Streamlit app → Invoice database: reads and writes (evidence: `app.py`)
- Streamlit app → Excel export: exports records (evidence: `app.py`)
- Invoice database → Dashboard and history: supplies invoice data (evidence: `app.py`)
- User → Dashboard and history: views records
