# muhammadmaaz200/ai-document-intelligence-system architecture

> Architecture diagram of the GitHub repository muhammadmaaz200/ai-document-intelligence-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/muhammadmaaz200/ai-document-intelligence-system
- Repository: https://github.com/muhammadmaaz200/ai-document-intelligence-system

## Overview

This is a Streamlit document-intelligence demo. Users upload a PDF or image, start processing, and receive extracted text, classified document fields, and downloadable JSON, CSV, or Excel results. PDF text is read directly when available, with OCR used for scanned pages; images use OCR. Results and a deduplicated history are held in temporary session state. The architecture is concentrated in app.py; the graph separates its main workflow stages. Evidence is limited to the sampled app.py, so external library internals are not represented.

Main entry points: [`app.py`](https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py) (Format Dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Upload and Processing"]
  node_upload["Upload and Process UI<br/>[app.py]"]
  node_processor["Format Dispatcher<br/>[app.py]"]
end

subgraph group_extraction["Text and Fields"]
  node_pdf_reader["PDF Text Reader<br/>[app.py]"]
  node_pdfium["PyMuPDF"]
  node_ocr["Tesseract OCR"]
  node_field_extractor["Classification and Fields<br/>[app.py]"]
end

subgraph group_results["Results and Session"]
  node_session["Session Results and History<br/>[app.py]"]
  node_display["Results Display<br/>[app.py]"]
  node_exports["JSON CSV Excel Export<br/>[app.py]"]
end

node_user(("Document User"))

node_user -->|"uploads file"| node_upload
node_upload -->|"starts processing"| node_processor
node_processor -->|"reads PDF"| node_pdf_reader
node_processor -->|"OCRs image"| node_ocr
node_pdf_reader -->|"reads pages"| node_pdfium
node_pdf_reader -->|"OCRs scanned pages"| node_ocr
node_processor -->|"extracts fields"| node_field_extractor
node_processor -->|"stores result"| node_session
node_processor -->|"updates history"| node_session
node_session -->|"provides result"| node_display
node_display -->|"offers downloads"| node_exports
node_session -->|"provides history"| node_display

click node_upload "https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py"
click node_processor "https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py"
click node_pdf_reader "https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py"
click node_field_extractor "https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py"
click node_session "https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py"
click node_display "https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py"
click node_exports "https://github.com/muhammadmaaz200/ai-document-intelligence-system/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_upload,node_processor,node_user toneBlue
class node_pdf_reader,node_pdfium,node_ocr,node_field_extractor toneAmber
class node_session,node_display,node_exports toneMint
```

## Components

### Upload and Processing

- [Upload and Process UI](https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py): `app.py`
- [Format Dispatcher](https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py): `app.py`

### Text and Fields

- [PDF Text Reader](https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py): `app.py`
- **PyMuPDF**
- **Tesseract OCR**
- [Classification and Fields](https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py): `app.py`

### Results and Session

- [Session Results and History](https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py): `app.py`
- [Results Display](https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py): `app.py`
- [JSON CSV Excel Export](https://github.com/muhammadmaaz200/ai-document-intelligence-system/blob/main/app.py): `app.py`

### Other components

- **Document User**

## Connections

- Document User → Upload and Process UI: uploads file (evidence: `app.py`)
- Upload and Process UI → Format Dispatcher: starts processing (evidence: `app.py`)
- Format Dispatcher → PDF Text Reader: reads PDF (evidence: `app.py`)
- Format Dispatcher → Tesseract OCR: OCRs image (evidence: `app.py`)
- PDF Text Reader → PyMuPDF: reads pages (evidence: `app.py`)
- PDF Text Reader → Tesseract OCR: OCRs scanned pages (evidence: `app.py`)
- Format Dispatcher → Classification and Fields: extracts fields (evidence: `app.py`)
- Format Dispatcher → Session Results and History: stores result (evidence: `app.py`)
- Format Dispatcher → Session Results and History: updates history (evidence: `app.py`)
- Session Results and History → Results Display: provides result (evidence: `app.py`)
- Results Display → JSON CSV Excel Export: offers downloads (evidence: `app.py`)
- Session Results and History → Results Display: provides history (evidence: `app.py`)
