# jaanunan/smartinvoiceai architecture

> Architecture diagram of the GitHub repository jaanunan/smartinvoiceai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jaanunan/smartinvoiceai
- Repository: https://github.com/jaanunan/smartinvoiceai

## Overview

Smart Invoice Parser is a Streamlit application for extracting structured invoice data from images, then reviewing, correcting, and exporting it. Its enhanced interface adds batch processing, invoice-type classification, fraud checks, and chat; analytics.py provides separate invoice visualizations and z-score anomaly analysis. The excerpts show app entry points calling shared utilities and the Groq client calling the external model service. Analytics wiring and some enhanced-interface internals are not fully shown, so those connections are omitted rather than inferred.

Main entry points: [`app.py`](https://github.com/jaanunan/smartinvoiceai/blob/main/app.py) (Standard interface), [`enhanced_ui.py`](https://github.com/jaanunan/smartinvoiceai/blob/main/enhanced_ui.py) (Enhanced interface), [`utils.py`](https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py) (Groq client), [`analytics.py`](https://github.com/jaanunan/smartinvoiceai/blob/main/analytics.py) (Invoice analytics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Invoice workflow"]
  node_standard_app["Standard interface<br/>[app.py]"]
  node_enhanced_app["Enhanced interface<br/>[enhanced_ui.py]"]
  node_image_inputs["Image input<br/>[utils.py]"]
  node_preprocessing["Image preprocessing<br/>[utils.py]"]
  node_extraction["Invoice extraction<br/>[app.py]"]
  node_invoice_types["Invoice classification<br/>[enhanced_ui.py]"]
  node_review["Results and editing<br/>[utils.py]"]
  node_csv_export["CSV export<br/>[utils.py]"]
  node_batch_processing["Batch processing<br/>[enhanced_ui.py]"]
  node_chat_assistant["Chat assistant<br/>[utils.py]"]
end

subgraph group_services["AI and shared services"]
  node_invoice_data["Invoice data model<br/>[utils.py]"]
  node_groq_client["Groq client<br/>[utils.py]"]
  node_groq_service{{"Groq model API"}}
end

subgraph group_insights["Invoice insights"]
  node_fraud_detection["Fraud detection<br/>[enhanced_ui.py]"]
  node_analytics["Invoice analytics<br/>[analytics.py]"]
  node_anomaly_detection["Anomaly detection<br/>[analytics.py]"]
end

node_user(("Invoice user"))
node_image_host{{"Image URL host"}}

node_user -->|"uses"| node_standard_app
node_user -.->|"uses"| node_enhanced_app
node_standard_app -->|"selects input"| node_image_inputs
node_standard_app -->|"preprocesses"| node_preprocessing
node_standard_app -->|"requests extraction"| node_extraction
node_standard_app -->|"creates client"| node_groq_client
node_standard_app -->|"validates data"| node_invoice_data
node_standard_app -->|"displays and edits"| node_review
node_standard_app -->|"exports data"| node_csv_export
node_standard_app -->|"runs assistant"| node_chat_assistant
node_enhanced_app -->|"preprocesses"| node_preprocessing
node_enhanced_app -->|"creates client"| node_groq_client
node_enhanced_app -->|"classifies invoice"| node_invoice_types
node_enhanced_app -->|"processes batch"| node_batch_processing
node_enhanced_app -->|"checks fraud"| node_fraud_detection
node_enhanced_app -->|"queries assistant"| node_chat_assistant
node_image_inputs -->|"fetches image"| node_image_host
node_groq_client -->|"sends requests"| node_groq_service
node_analytics -->|"reads invoice fields"| node_invoice_data
node_anomaly_detection -->|"reads invoice fields"| node_invoice_data

click node_standard_app "https://github.com/jaanunan/smartinvoiceai/blob/main/app.py"
click node_enhanced_app "https://github.com/jaanunan/smartinvoiceai/blob/main/enhanced_ui.py"
click node_image_inputs "https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py"
click node_preprocessing "https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py"
click node_extraction "https://github.com/jaanunan/smartinvoiceai/blob/main/app.py"
click node_invoice_types "https://github.com/jaanunan/smartinvoiceai/blob/main/enhanced_ui.py"
click node_invoice_data "https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py"
click node_groq_client "https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py"
click node_review "https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py"
click node_csv_export "https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py"
click node_batch_processing "https://github.com/jaanunan/smartinvoiceai/blob/main/enhanced_ui.py"
click node_fraud_detection "https://github.com/jaanunan/smartinvoiceai/blob/main/enhanced_ui.py"
click node_chat_assistant "https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py"
click node_analytics "https://github.com/jaanunan/smartinvoiceai/blob/main/analytics.py"
click node_anomaly_detection "https://github.com/jaanunan/smartinvoiceai/blob/main/analytics.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_standard_app,node_enhanced_app,node_image_inputs,node_preprocessing,node_extraction,node_invoice_types,node_review,node_csv_export,node_batch_processing,node_chat_assistant,node_user toneBlue
class node_invoice_data,node_groq_client,node_groq_service toneAmber
class node_fraud_detection,node_analytics,node_anomaly_detection toneMint
class node_image_host toneIndigo
```

## Components

### Invoice workflow

- [Standard interface](https://github.com/jaanunan/smartinvoiceai/blob/main/app.py): `app.py`
- [Enhanced interface](https://github.com/jaanunan/smartinvoiceai/blob/main/enhanced_ui.py): `enhanced_ui.py`
- [Image input](https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py): `utils.py`
- [Image preprocessing](https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py): `utils.py`
- [Invoice extraction](https://github.com/jaanunan/smartinvoiceai/blob/main/app.py): `app.py`
- [Invoice classification](https://github.com/jaanunan/smartinvoiceai/blob/main/enhanced_ui.py): `enhanced_ui.py`
- [Results and editing](https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py): `utils.py`
- [CSV export](https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py): `utils.py`
- [Batch processing](https://github.com/jaanunan/smartinvoiceai/blob/main/enhanced_ui.py): `enhanced_ui.py`
- [Chat assistant](https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py): `utils.py`

### AI and shared services

- [Invoice data model](https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py): `utils.py`
- [Groq client](https://github.com/jaanunan/smartinvoiceai/blob/main/utils.py): `utils.py`
- **Groq model API**

### Invoice insights

- [Fraud detection](https://github.com/jaanunan/smartinvoiceai/blob/main/enhanced_ui.py): `enhanced_ui.py`
- [Invoice analytics](https://github.com/jaanunan/smartinvoiceai/blob/main/analytics.py): `analytics.py`
- [Anomaly detection](https://github.com/jaanunan/smartinvoiceai/blob/main/analytics.py): `analytics.py`

### Other components

- **Invoice user**
- **Image URL host**

## Connections

- Invoice user → Standard interface: uses (evidence: `README.md`)
- Invoice user → Enhanced interface: uses
- Standard interface → Image input: selects input (evidence: `app.py`)
- Standard interface → Image preprocessing: preprocesses (evidence: `app.py`)
- Standard interface → Invoice extraction: requests extraction (evidence: `app.py`)
- Standard interface → Groq client: creates client (evidence: `app.py`)
- Standard interface → Invoice data model: validates data (evidence: `app.py`)
- Standard interface → Results and editing: displays and edits (evidence: `app.py`)
- Standard interface → CSV export: exports data (evidence: `app.py`)
- Standard interface → Chat assistant: runs assistant (evidence: `app.py`)
- Enhanced interface → Image preprocessing: preprocesses (evidence: `enhanced_ui.py`)
- Enhanced interface → Groq client: creates client (evidence: `enhanced_ui.py`)
- Enhanced interface → Invoice classification: classifies invoice (evidence: `enhanced_ui.py`)
- Enhanced interface → Batch processing: processes batch (evidence: `enhanced_ui.py`)
- Enhanced interface → Fraud detection: checks fraud (evidence: `enhanced_ui.py`)
- Enhanced interface → Chat assistant: queries assistant (evidence: `enhanced_ui.py`)
- Image input → Image URL host: fetches image (evidence: `utils.py`)
- Groq client → Groq model API: sends requests (evidence: `utils.py`)
- Invoice analytics → Invoice data model: reads invoice fields (evidence: `analytics.py`)
- Anomaly detection → Invoice data model: reads invoice fields (evidence: `analytics.py`)
