# anujgoyal239/ocr_model_idfc_bank architecture

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

- Interactive diagram: https://gitdiagram.com/anujgoyal239/ocr_model_idfc_bank
- Repository: https://github.com/anujgoyal239/ocr_model_idfc_bank

## Overview

This repository implements invoice/document OCR and structured field extraction, with a Streamlit interface for uploading, processing, reviewing, and exporting results. The principal workflow runs from upload validation through the frontend processing service into the document pipeline, which preprocesses documents, performs OCR, extracts fields, and returns results for display and history. Source-index references support the pipeline’s main dependencies; unsampled evaluation and some UI behavior are represented only where the tree and references establish a distinct capability.

Main entry points: [`IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py) (Pipeline orchestrator), [`streamlit_frontend/main.py`](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/main.py) (Streamlit app), [`IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/hybrid_ocr_engine.py`](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/hybrid_ocr_engine.py) (Hybrid OCR), [`streamlit_frontend/services/processor.py`](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/services/processor.py) (Processing service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["User interface"]
  node_ui["Streamlit app<br/>[main.py]"]
  node_upload["Upload validation<br/>[upload.py]"]
  node_views["Results and history"]
  node_export["Export results<br/>[export.py]"]
  node_cache_history["Cache and history"]
  node_processor["Processing service<br/>[processor.py]"]
  node_backend["Flask backend"]
end

subgraph group_pipeline["Document pipeline"]
  node_core["Pipeline orchestrator<br/>[main.py]"]
  node_preprocess["Document preprocessing<br/>[preprocessor.py]"]
  node_pdf["PDF conversion<br/>[pdf_converter.py]"]
  node_enhance["Image enhancement<br/>[image_enhancer.py]"]
end

subgraph group_recognition["OCR and vision"]
  node_hybrid["Hybrid OCR"]
  node_paddle["PaddleOCR engine"]
  node_tesseract["Tesseract engine"]
  node_ocr_result["OCR result model<br/>[ocr_result.py]"]
  node_vision["Stamp and signature detection<br/>[vision_detector.py]"]
end

subgraph group_extraction["Field extraction"]
  node_fields["Field extraction<br/>[field_extractor.py]"]
  node_dealer["Dealer extraction"]
  node_model["Model extraction"]
  node_horsepower["Horsepower extraction"]
  node_asset_cost["Asset cost extraction"]
  node_optimizers["Field optimizers"]
  node_fuzzy["Fuzzy matching<br/>[fuzzy_matcher.py]"]
end

subgraph group_support["Quality and support"]
  node_confidence["Confidence scoring"]
  node_evaluation["Evaluation metrics"]
  node_gemini["Gemini fallback<br/>[gemini_fallback.py]"]
  node_cost["Cost tracking<br/>[cost_tracker.py]"]
end

node_user(("Document user"))

node_user -->|"submits document"| node_upload
node_ui -->|"renders"| node_upload
node_ui -->|"requests processing"| node_processor
node_ui -->|"checks and records"| node_cache_history
node_ui -->|"renders results"| node_views
node_ui -->|"renders export"| node_export
node_processor -->|"posts document"| node_backend
node_processor -->|"processes locally"| node_core
node_backend -->|"invokes pipeline"| node_core
node_core -->|"preprocesses document"| node_preprocess
node_preprocess -->|"converts PDFs"| node_pdf
node_preprocess -->|"enhances images"| node_enhance
node_core -->|"recognizes text"| node_hybrid
node_hybrid -->|"dispatches OCR"| node_paddle
node_hybrid -->|"dispatches OCR"| node_tesseract
node_paddle -->|"returns blocks"| node_ocr_result
node_tesseract -->|"returns blocks"| node_ocr_result
node_hybrid -->|"returns OCR result"| node_ocr_result
node_core -->|"extracts dealer"| node_dealer
node_core -->|"extracts model"| node_model
node_core -->|"extracts horsepower"| node_horsepower
node_core -->|"extracts asset cost"| node_asset_cost
node_core -->|"optimizes fields"| node_optimizers
node_core -->|"detects document marks"| node_vision
node_core -->|"scores extraction"| node_confidence
node_dealer -->|"matches names"| node_fuzzy
node_model -->|"matches models"| node_fuzzy
node_core -->|"uses fallback"| node_gemini
node_core -->|"tracks processing cost"| node_cost

click node_ui "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/main.py"
click node_upload "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/components/upload.py"
click node_views "https://github.com/anujgoyal239/ocr_model_idfc_bank/tree/main/streamlit_frontend/components"
click node_export "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/components/export.py"
click node_cache_history "https://github.com/anujgoyal239/ocr_model_idfc_bank/tree/main/streamlit_frontend/services"
click node_processor "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/services/processor.py"
click node_backend "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/backend_server_flask.py"
click node_core "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py"
click node_preprocess "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/preprocessor.py"
click node_pdf "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/pdf_converter.py"
click node_enhance "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/image_enhancer.py"
click node_hybrid "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/hybrid_ocr_engine.py"
click node_paddle "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/paddle_ocr_engine.py"
click node_tesseract "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/tesseract_ocr_engine.py"
click node_ocr_result "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/ocr_result.py"
click node_vision "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/vision/vision_detector.py"
click node_fields "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/field_extractor.py"
click node_dealer "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/dealer_name_extractor.py"
click node_model "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/unified_model_extractor.py"
click node_horsepower "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/horse_power_extractor.py"
click node_asset_cost "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/asset_cost_extractor.py"
click node_optimizers "https://github.com/anujgoyal239/ocr_model_idfc_bank/tree/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction"
click node_fuzzy "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/fuzzy_matcher.py"
click node_confidence "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/confidence/confidence_scorer.py"
click node_evaluation "https://github.com/anujgoyal239/ocr_model_idfc_bank/tree/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/evaluation"
click node_gemini "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/utils/gemini_fallback.py"
click node_cost "https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/utils/cost_tracker.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_ui,node_upload,node_views,node_export,node_cache_history,node_processor,node_backend,node_user toneBlue
class node_core,node_preprocess,node_pdf,node_enhance toneAmber
class node_hybrid,node_paddle,node_tesseract,node_ocr_result,node_vision toneMint
class node_fields,node_dealer,node_model,node_horsepower,node_asset_cost,node_optimizers,node_fuzzy toneRose
class node_confidence,node_evaluation,node_gemini,node_cost toneIndigo
```

## Components

### User interface

- [Streamlit app](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/main.py): `streamlit_frontend/main.py`
- [Upload validation](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/components/upload.py): `streamlit_frontend/components/upload.py`
- [Results and history](https://github.com/anujgoyal239/ocr_model_idfc_bank/tree/main/streamlit_frontend/components): `streamlit_frontend/components`
- [Export results](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/components/export.py): `streamlit_frontend/components/export.py`
- [Cache and history](https://github.com/anujgoyal239/ocr_model_idfc_bank/tree/main/streamlit_frontend/services): `streamlit_frontend/services`
- [Processing service](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/services/processor.py): `streamlit_frontend/services/processor.py`
- [Flask backend](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/streamlit_frontend/backend_server_flask.py): `streamlit_frontend/backend_server_flask.py`

### Document pipeline

- [Pipeline orchestrator](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`
- [Document preprocessing](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/preprocessor.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/preprocessor.py`
- [PDF conversion](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/pdf_converter.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/pdf_converter.py`
- [Image enhancement](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/image_enhancer.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/image_enhancer.py`

### OCR and vision

- [Hybrid OCR](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/hybrid_ocr_engine.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/hybrid_ocr_engine.py`
- [PaddleOCR engine](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/paddle_ocr_engine.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/paddle_ocr_engine.py`
- [Tesseract engine](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/tesseract_ocr_engine.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/tesseract_ocr_engine.py`
- [OCR result model](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/ocr_result.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/ocr_result.py`
- [Stamp and signature detection](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/vision/vision_detector.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/vision/vision_detector.py`

### Field extraction

- [Field extraction](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/field_extractor.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/field_extractor.py`
- [Dealer extraction](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/dealer_name_extractor.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/dealer_name_extractor.py`
- [Model extraction](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/unified_model_extractor.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/unified_model_extractor.py`
- [Horsepower extraction](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/horse_power_extractor.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/horse_power_extractor.py`
- [Asset cost extraction](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/asset_cost_extractor.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/asset_cost_extractor.py`
- [Field optimizers](https://github.com/anujgoyal239/ocr_model_idfc_bank/tree/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction`
- [Fuzzy matching](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/fuzzy_matcher.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/fuzzy_matcher.py`

### Quality and support

- [Confidence scoring](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/confidence/confidence_scorer.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/confidence/confidence_scorer.py`
- [Evaluation metrics](https://github.com/anujgoyal239/ocr_model_idfc_bank/tree/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/evaluation): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/evaluation`
- [Gemini fallback](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/utils/gemini_fallback.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/utils/gemini_fallback.py`
- [Cost tracking](https://github.com/anujgoyal239/ocr_model_idfc_bank/blob/main/IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/utils/cost_tracker.py): `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/utils/cost_tracker.py`

### Other components

- **Document user**

## Connections

- Document user → Upload validation: submits document
- Streamlit app → Upload validation: renders (evidence: `streamlit_frontend/main.py`)
- Streamlit app → Processing service: requests processing (evidence: `streamlit_frontend/main.py`)
- Streamlit app → Cache and history: checks and records (evidence: `streamlit_frontend/main.py`)
- Streamlit app → Results and history: renders results (evidence: `streamlit_frontend/main.py`)
- Streamlit app → Export results: renders export (evidence: `streamlit_frontend/main.py`)
- Processing service → Flask backend: posts document (evidence: `streamlit_frontend/services/processor.py`)
- Processing service → Pipeline orchestrator: processes locally (evidence: `streamlit_frontend/services/processor.py`)
- Flask backend → Pipeline orchestrator: invokes pipeline (evidence: `streamlit_frontend/backend_server_flask.py`)
- Pipeline orchestrator → Document preprocessing: preprocesses document (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
- Document preprocessing → PDF conversion: converts PDFs (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/preprocessor.py`)
- Document preprocessing → Image enhancement: enhances images (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/preprocessing/preprocessor.py`)
- Pipeline orchestrator → Hybrid OCR: recognizes text (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
- Hybrid OCR → PaddleOCR engine: dispatches OCR (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/hybrid_ocr_engine.py`)
- Hybrid OCR → Tesseract engine: dispatches OCR (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/hybrid_ocr_engine.py`)
- PaddleOCR engine → OCR result model: returns blocks (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/paddle_ocr_engine.py`)
- Tesseract engine → OCR result model: returns blocks (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/tesseract_ocr_engine.py`)
- Hybrid OCR → OCR result model: returns OCR result (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/ocr/hybrid_ocr_engine.py`)
- Pipeline orchestrator → Dealer extraction: extracts dealer (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
- Pipeline orchestrator → Model extraction: extracts model (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
- Pipeline orchestrator → Horsepower extraction: extracts horsepower (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
- Pipeline orchestrator → Asset cost extraction: extracts asset cost (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
- Pipeline orchestrator → Field optimizers: optimizes fields (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
- Pipeline orchestrator → Stamp and signature detection: detects document marks (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
- Pipeline orchestrator → Confidence scoring: scores extraction (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
- Dealer extraction → Fuzzy matching: matches names (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/dealer_name_extractor.py`)
- Model extraction → Fuzzy matching: matches models (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/extraction/unified_model_extractor.py`)
- Pipeline orchestrator → Gemini fallback: uses fallback (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
- Pipeline orchestrator → Cost tracking: tracks processing cost (evidence: `IIT_GUWAHATI_CONVOLVE_TRACK-OCR-main/src/main.py`)
