# ajai-r/sensitive_document_privacy_protection architecture

> Architecture diagram of the GitHub repository ajai-r/sensitive_document_privacy_protection, 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/ajai-r/sensitive_document_privacy_protection
- Repository: https://github.com/ajai-r/sensitive_document_privacy_protection

## Overview

This repository implements sensitive-document detection and redaction, exposed through a Flask upload interface. The user selects an image, the browser submits it to the web app, and the app’s inference core classifies it and can redact Aadhaar or PAN regions using OCR and blurring. Separate scripts cover document-image preparation, augmentation, model training, standalone prediction, and evaluation. The upload endpoint’s implementation is not shown in the excerpts, so the graph does not assert its internal call sequence.

Main entry points: [`Web_app/static/script.js`](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/static/script.js) (Upload and results UI), [`Web_app/app.py`](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/app.py) (Upload web app), [`Web_app/ml_core.py`](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/ml_core.py) (Inference core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_browser["Upload and results UI<br/>[script.js]"]
  node_flask["Upload web app<br/>[app.py]"]
end

subgraph group_inference["Image inference"]
  node_core["Inference core<br/>[ml_core.py]"]
  node_ocr["OCR redaction<br/>[ml_core.py]"]
end

subgraph group_lifecycle["Model lifecycle"]
  node_pdfprep["PDF image preparation<br/>[data_prep.py]"]
  node_augmentation["Image augmentation<br/>[data_generation.py]"]
  node_training["Classifier training<br/>[model.py]"]
  node_standalone["Standalone prediction<br/>[prediction.py]"]
  node_evaluation["Classification evaluation<br/>[metrices.py]"]
end

node_user(("Document user"))

node_user -->|"selects image"| node_browser
node_browser -->|"posts upload"| node_flask
node_flask -->|"imports inference"| node_core
node_core -->|"redacts text"| node_ocr

click node_browser "https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/static/script.js"
click node_flask "https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/app.py"
click node_core "https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/ml_core.py"
click node_ocr "https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/ml_core.py"
click node_pdfprep "https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Data_preprocessing/data_prep.py"
click node_augmentation "https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Data_preprocessing/data_generation.py"
click node_training "https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Model/model.py"
click node_standalone "https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Model/prediction.py"
click node_evaluation "https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Outputs/metrices.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_browser,node_flask,node_user toneBlue
class node_core,node_ocr toneAmber
class node_pdfprep,node_augmentation,node_training,node_standalone,node_evaluation toneMint
```

## Components

### Web interface

- [Upload and results UI](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/static/script.js): `Web_app/static/script.js`
- [Upload web app](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/app.py): `Web_app/app.py`

### Image inference

- [Inference core](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/ml_core.py): `Web_app/ml_core.py`
- [OCR redaction](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Web_app/ml_core.py): `Web_app/ml_core.py`

### Model lifecycle

- [PDF image preparation](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Data_preprocessing/data_prep.py): `Data_preprocessing/data_prep.py`
- [Image augmentation](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Data_preprocessing/data_generation.py): `Data_preprocessing/data_generation.py`
- [Classifier training](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Model/model.py): `Model/model.py`
- [Standalone prediction](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Model/prediction.py): `Model/prediction.py`
- [Classification evaluation](https://github.com/ajai-r/sensitive_document_privacy_protection/blob/main/Outputs/metrices.py): `Outputs/metrices.py`

### Other components

- **Document user**

## Connections

- Document user → Upload and results UI: selects image (evidence: `Web_app/static/script.js`)
- Upload and results UI → Upload web app: posts upload (evidence: `Web_app/static/script.js`)
- Upload web app → Inference core: imports inference (evidence: `Web_app/app.py`)
- Inference core → OCR redaction: redacts text (evidence: `Web_app/ml_core.py`)
