# arya920/signatureverificationproj architecture

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

- Interactive diagram: https://gitdiagram.com/arya920/signatureverificationproj
- Repository: https://github.com/arya920/signatureverificationproj

## Overview

This is an offline handwritten-signature verification product: users upload signatures, identify a claimed writer, and receive a genuine/forged/unknown decision with distance and a downloadable CSV. The runtime loads a trained embedder, reference embeddings, and threshold, then preprocesses each image and compares its embedding with the claimed writer’s references. The README also documents a training and evaluation workflow. Training internals are represented at notebook level because its source was not sampled; the graph does not assume undocumented wiring from the standalone service helpers.

Main entry points: [`app.py`](https://github.com/arya920/signatureverificationproj/blob/main/app.py) (Streamlit app), [`Inference.py`](https://github.com/arya920/signatureverificationproj/blob/main/Inference.py) (Distance verification), [`AdHoc_Testing.py`](https://github.com/arya920/signatureverificationproj/blob/main/AdHoc_Testing.py) (Bulk evaluation), [`artifacts/embedding_db.pkl`](https://github.com/arya920/signatureverificationproj/blob/main/artifacts/embedding_db.pkl) (Writer reference embeddings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_user_flow["Verification app"]
  node_app["Streamlit app<br/>[app.py]"]
  node_mapping["Name mapping<br/>[user_mapping.py]"]
  node_results["Results and CSV<br/>[app.py]"]
  node_model_loader["Asset loader helper<br/>[model_loader.py]"]
  node_verification_service["Single-signature helper"]
end

subgraph group_inference["Inference runtime"]
  node_preprocess["Image preprocessing<br/>[Inference.py]"]
  node_embedder["Writer embedding model<br/>[Inference.py]"]
  node_verify["Distance verification<br/>[Inference.py]"]
end

subgraph group_training["Training and evaluation"]
  node_train["Training pipeline"]
  node_evaluation["Bulk evaluation<br/>[AdHoc_Testing.py]"]
  node_report["Error analysis<br/>[report.py]"]
end

subgraph group_assets["Model artifacts"]
  node_weights["Model weights"]
  node_reference_db[("Writer reference embeddings<br/>[embedding_db.pkl]")]
  node_threshold["Decision threshold<br/>[threshold.txt]"]
  node_test_report["Test results CSV"]
end

node_user(("Signature submitter"))
node_cedar[("CEDAR dataset")]

node_user -->|"uploads signatures"| node_app
node_app -.->|"maps names"| node_mapping
node_app -->|"loads model"| node_embedder
node_app -->|"loads references"| node_reference_db
node_app -->|"loads threshold"| node_threshold
node_app -->|"verifies image"| node_verify
node_app -->|"displays and exports"| node_results
node_verify -->|"compares references"| node_reference_db
node_verify -->|"applies cutoff"| node_threshold
node_verify -->|"preprocesses image"| node_preprocess
node_verify -->|"extracts embedding"| node_embedder
node_model_loader -->|"loads model"| node_embedder
node_model_loader -->|"loads references"| node_reference_db
node_model_loader -->|"loads threshold"| node_threshold
node_verification_service -->|"delegates verification"| node_verify
node_cedar -->|"supplies signatures"| node_train
node_train -->|"produces weights"| node_weights
node_train -->|"builds references"| node_reference_db
node_train -->|"selects threshold"| node_threshold
node_evaluation -->|"loads model"| node_embedder
node_evaluation -->|"loads references"| node_reference_db
node_evaluation -->|"loads threshold"| node_threshold
node_evaluation -->|"tests signatures"| node_verify
node_evaluation -->|"writes results"| node_test_report
node_report -->|"analyzes CSV"| node_test_report

click node_app "https://github.com/arya920/signatureverificationproj/blob/main/app.py"
click node_mapping "https://github.com/arya920/signatureverificationproj/blob/main/services/user_mapping.py"
click node_results "https://github.com/arya920/signatureverificationproj/blob/main/app.py"
click node_model_loader "https://github.com/arya920/signatureverificationproj/blob/main/services/model_loader.py"
click node_verification_service "https://github.com/arya920/signatureverificationproj/blob/main/services/verification_service.py"
click node_preprocess "https://github.com/arya920/signatureverificationproj/blob/main/Inference.py"
click node_embedder "https://github.com/arya920/signatureverificationproj/blob/main/Inference.py"
click node_verify "https://github.com/arya920/signatureverificationproj/blob/main/Inference.py"
click node_train "https://github.com/arya920/signatureverificationproj/blob/main/training_notebook.ipynb"
click node_evaluation "https://github.com/arya920/signatureverificationproj/blob/main/AdHoc_Testing.py"
click node_report "https://github.com/arya920/signatureverificationproj/blob/main/report.py"
click node_weights "https://github.com/arya920/signatureverificationproj/blob/main/artifacts/signature_embedder.pth"
click node_reference_db "https://github.com/arya920/signatureverificationproj/blob/main/artifacts/embedding_db.pkl"
click node_threshold "https://github.com/arya920/signatureverificationproj/blob/main/artifacts/threshold.txt"
click node_test_report "https://github.com/arya920/signatureverificationproj/blob/main/artifacts/signature_test_report.csv"

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_mapping,node_results,node_model_loader,node_verification_service toneBlue
class node_preprocess,node_embedder,node_verify,node_cedar toneAmber
class node_train,node_evaluation,node_report toneMint
class node_weights,node_reference_db,node_threshold,node_test_report toneRose
class node_user toneIndigo
```

## Components

### Verification app

- [Streamlit app](https://github.com/arya920/signatureverificationproj/blob/main/app.py): `app.py`
- [Name mapping](https://github.com/arya920/signatureverificationproj/blob/main/services/user_mapping.py): `services/user_mapping.py`
- [Results and CSV](https://github.com/arya920/signatureverificationproj/blob/main/app.py): `app.py`
- [Asset loader helper](https://github.com/arya920/signatureverificationproj/blob/main/services/model_loader.py): `services/model_loader.py`
- [Single-signature helper](https://github.com/arya920/signatureverificationproj/blob/main/services/verification_service.py): `services/verification_service.py`

### Inference runtime

- [Image preprocessing](https://github.com/arya920/signatureverificationproj/blob/main/Inference.py): `Inference.py`
- [Writer embedding model](https://github.com/arya920/signatureverificationproj/blob/main/Inference.py): `Inference.py`
- [Distance verification](https://github.com/arya920/signatureverificationproj/blob/main/Inference.py): `Inference.py`

### Training and evaluation

- [Training pipeline](https://github.com/arya920/signatureverificationproj/blob/main/training_notebook.ipynb): `training_notebook.ipynb`
- [Bulk evaluation](https://github.com/arya920/signatureverificationproj/blob/main/AdHoc_Testing.py): `AdHoc_Testing.py`
- [Error analysis](https://github.com/arya920/signatureverificationproj/blob/main/report.py): `report.py`

### Model artifacts

- [Model weights](https://github.com/arya920/signatureverificationproj/blob/main/artifacts/signature_embedder.pth): `artifacts/signature_embedder.pth`
- [Writer reference embeddings](https://github.com/arya920/signatureverificationproj/blob/main/artifacts/embedding_db.pkl): `artifacts/embedding_db.pkl`
- [Decision threshold](https://github.com/arya920/signatureverificationproj/blob/main/artifacts/threshold.txt): `artifacts/threshold.txt`
- [Test results CSV](https://github.com/arya920/signatureverificationproj/blob/main/artifacts/signature_test_report.csv): `artifacts/signature_test_report.csv`

### Other components

- **Signature submitter**
- **CEDAR dataset**

## Connections

- Signature submitter → Streamlit app: uploads signatures (evidence: `README.md`)
- Streamlit app → Name mapping: maps names
- Streamlit app → Writer embedding model: loads model (evidence: `app.py`)
- Streamlit app → Writer reference embeddings: loads references (evidence: `app.py`)
- Streamlit app → Decision threshold: loads threshold (evidence: `app.py`)
- Streamlit app → Distance verification: verifies image (evidence: `app.py`)
- Streamlit app → Results and CSV: displays and exports (evidence: `app.py`)
- Distance verification → Writer reference embeddings: compares references (evidence: `Inference.py`)
- Distance verification → Decision threshold: applies cutoff (evidence: `Inference.py`)
- Distance verification → Image preprocessing: preprocesses image (evidence: `Inference.py`)
- Distance verification → Writer embedding model: extracts embedding (evidence: `Inference.py`)
- Asset loader helper → Writer embedding model: loads model (evidence: `services/model_loader.py`)
- Asset loader helper → Writer reference embeddings: loads references (evidence: `services/model_loader.py`)
- Asset loader helper → Decision threshold: loads threshold (evidence: `services/model_loader.py`)
- Single-signature helper → Distance verification: delegates verification (evidence: `services/verification_service.py`)
- CEDAR dataset → Training pipeline: supplies signatures (evidence: `README.md`)
- Training pipeline → Model weights: produces weights (evidence: `README.md`)
- Training pipeline → Writer reference embeddings: builds references (evidence: `README.md`)
- Training pipeline → Decision threshold: selects threshold (evidence: `README.md`)
- Bulk evaluation → Writer embedding model: loads model (evidence: `AdHoc_Testing.py`)
- Bulk evaluation → Writer reference embeddings: loads references (evidence: `AdHoc_Testing.py`)
- Bulk evaluation → Decision threshold: loads threshold (evidence: `AdHoc_Testing.py`)
- Bulk evaluation → Distance verification: tests signatures (evidence: `AdHoc_Testing.py`)
- Bulk evaluation → Test results CSV: writes results (evidence: `AdHoc_Testing.py`)
- Error analysis → Test results CSV: analyzes CSV (evidence: `report.py`)
