# niharxd/heritageai architecture

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

- Interactive diagram: https://gitdiagram.com/niharxd/heritageai
- Repository: https://github.com/niharxd/heritageai

## Overview

Heritage AI is a local cultural-heritage image analysis and conservation assistant. A conservator selects manuscript or monument images, submits one or a batch, and receives damage findings, enhancement, text or structured labels, risk, age estimates, explanations, and restoration recommendations. The same analysis can be reviewed and exported, then retained in an archive for notes, groups, trends, comparison, statistics, urgency, and map views. The graph includes README-documented capabilities whose implementation was not sampled; their internal wiring is omitted where evidence is unavailable.

Main entry points: [`backend/pipeline.py`](https://github.com/niharxd/heritageai/blob/main/backend/pipeline.py) (Analysis pipeline), [`frontend/src/api.ts`](https://github.com/niharxd/heritageai/blob/main/frontend/src/api.ts) (API client), [`app.py`](https://github.com/niharxd/heritageai/blob/main/app.py) (HTTP API), [`frontend/src/App.tsx`](https://github.com/niharxd/heritageai/blob/main/frontend/src/App.tsx) (Application views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Conservator interface"]
  node_appui["Application views<br/>[App.tsx]"]
  node_client["API client<br/>[api.ts]"]
  node_gallery["Archive gallery<br/>[Gallery.tsx]"]
  node_compare["Comparison<br/>[Compare.tsx]"]
  node_stats["Statistics<br/>[StatsPage.tsx]"]
  node_mapview["Map view<br/>[MapView.tsx]"]
  node_urgency["Urgency queue<br/>[UrgencyQueue.tsx]"]
  node_annotation["Image annotation<br/>[AnnotationTool.tsx]"]
  node_batchresults["Batch results<br/>[BatchResults.tsx]"]
  node_trend["Trend chart<br/>[TrendChart.tsx]"]
  node_quality["Image quality<br/>[ImageQuality.tsx]"]
end

subgraph group_analysis["Image analysis"]
  node_pipeline["Analysis pipeline<br/>[pipeline.py]"]
  node_preprocess["Preprocessing<br/>[preprocessing.py]"]
  node_detection["Damage detection"]
  node_enhancement["Image enhancement<br/>[enhancement.py]"]
  node_ocr["OCR and labels<br/>[ocr_engine.py]"]
  node_risk["Risk prediction<br/>[risk_prediction.py]"]
  node_age["Age estimation<br/>[age_estimation.py]"]
  node_explain["Explainability<br/>[explainability.py]"]
  node_suggest["Restoration advice"]
  node_material["Material detection"]
  node_duplicate["Duplicate detection"]
end

subgraph group_archive["Archive and reporting"]
  node_api["HTTP API<br/>[app.py]"]
  node_history[("History store<br/>[history_store.py]")]
  node_pdf["PDF reports<br/>[pdf_report.py]"]
end

subgraph group_integration["External services"]
  node_geocoder["Place geocoding"]
end

node_conservator(("Conservator"))

node_conservator -->|"uses"| node_appui
node_appui -->|"requests analysis"| node_client
node_client -->|"calls endpoints"| node_api
node_api -->|"runs analysis"| node_pipeline
node_pipeline -->|"estimates domain"| node_preprocess
node_pipeline -->|"detects damage"| node_detection
node_pipeline -->|"enhances image"| node_enhancement
node_pipeline -->|"extracts semantics"| node_ocr
node_pipeline -->|"scores risk"| node_risk
node_pipeline -->|"estimates age"| node_age
node_pipeline -->|"explains findings"| node_explain
node_pipeline -->|"suggests restoration"| node_suggest
node_api -->|"reads and writes"| node_history
node_api -->|"generates reports"| node_pdf
node_appui -->|"shows batch"| node_batchresults
node_appui -->|"checks uploads"| node_quality
node_appui -->|"offers annotation"| node_annotation
node_gallery -->|"loads archive"| node_client
node_gallery -->|"renders trends"| node_trend
node_stats -->|"loads statistics"| node_client
node_stats -->|"renders trends"| node_trend
node_mapview -->|"loads map pins"| node_client
node_urgency -->|"loads queue"| node_client
node_compare -->|"loads analyses"| node_client
node_conservator -.->|"searches locations"| node_geocoder
node_api -.->|"may classify material"| node_material
node_api -->|"checks duplicates"| node_duplicate

click node_appui "https://github.com/niharxd/heritageai/blob/main/frontend/src/App.tsx"
click node_client "https://github.com/niharxd/heritageai/blob/main/frontend/src/api.ts"
click node_gallery "https://github.com/niharxd/heritageai/blob/main/frontend/src/pages/Gallery.tsx"
click node_compare "https://github.com/niharxd/heritageai/blob/main/frontend/src/pages/Compare.tsx"
click node_stats "https://github.com/niharxd/heritageai/blob/main/frontend/src/pages/StatsPage.tsx"
click node_mapview "https://github.com/niharxd/heritageai/blob/main/frontend/src/pages/MapView.tsx"
click node_urgency "https://github.com/niharxd/heritageai/blob/main/frontend/src/pages/UrgencyQueue.tsx"
click node_annotation "https://github.com/niharxd/heritageai/blob/main/frontend/src/components/AnnotationTool.tsx"
click node_batchresults "https://github.com/niharxd/heritageai/blob/main/frontend/src/components/BatchResults.tsx"
click node_trend "https://github.com/niharxd/heritageai/blob/main/frontend/src/components/TrendChart.tsx"
click node_quality "https://github.com/niharxd/heritageai/blob/main/frontend/src/components/ImageQuality.tsx"
click node_pipeline "https://github.com/niharxd/heritageai/blob/main/backend/pipeline.py"
click node_preprocess "https://github.com/niharxd/heritageai/blob/main/backend/preprocessing.py"
click node_detection "https://github.com/niharxd/heritageai/blob/main/backend/damage_detection.py"
click node_enhancement "https://github.com/niharxd/heritageai/blob/main/backend/enhancement.py"
click node_ocr "https://github.com/niharxd/heritageai/blob/main/backend/ocr_engine.py"
click node_risk "https://github.com/niharxd/heritageai/blob/main/backend/risk_prediction.py"
click node_age "https://github.com/niharxd/heritageai/blob/main/backend/age_estimation.py"
click node_explain "https://github.com/niharxd/heritageai/blob/main/backend/explainability.py"
click node_suggest "https://github.com/niharxd/heritageai/blob/main/backend/restoration_suggestions.py"
click node_material "https://github.com/niharxd/heritageai/blob/main/backend/material_detection.py"
click node_duplicate "https://github.com/niharxd/heritageai/blob/main/backend/duplicate_detector.py"
click node_api "https://github.com/niharxd/heritageai/blob/main/app.py"
click node_history "https://github.com/niharxd/heritageai/blob/main/backend/history_store.py"
click node_pdf "https://github.com/niharxd/heritageai/blob/main/backend/pdf_report.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_appui,node_client,node_gallery,node_compare,node_stats,node_mapview,node_urgency,node_annotation,node_batchresults,node_trend,node_quality toneBlue
class node_pipeline,node_preprocess,node_detection,node_enhancement,node_ocr,node_risk,node_age,node_explain,node_suggest,node_material,node_duplicate toneAmber
class node_api,node_history,node_pdf toneMint
class node_geocoder toneRose
class node_conservator toneIndigo
```

## Components

### Conservator interface

- [Application views](https://github.com/niharxd/heritageai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/niharxd/heritageai/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Archive gallery](https://github.com/niharxd/heritageai/blob/main/frontend/src/pages/Gallery.tsx): `frontend/src/pages/Gallery.tsx`
- [Comparison](https://github.com/niharxd/heritageai/blob/main/frontend/src/pages/Compare.tsx): `frontend/src/pages/Compare.tsx`
- [Statistics](https://github.com/niharxd/heritageai/blob/main/frontend/src/pages/StatsPage.tsx): `frontend/src/pages/StatsPage.tsx`
- [Map view](https://github.com/niharxd/heritageai/blob/main/frontend/src/pages/MapView.tsx): `frontend/src/pages/MapView.tsx`
- [Urgency queue](https://github.com/niharxd/heritageai/blob/main/frontend/src/pages/UrgencyQueue.tsx): `frontend/src/pages/UrgencyQueue.tsx`
- [Image annotation](https://github.com/niharxd/heritageai/blob/main/frontend/src/components/AnnotationTool.tsx): `frontend/src/components/AnnotationTool.tsx`
- [Batch results](https://github.com/niharxd/heritageai/blob/main/frontend/src/components/BatchResults.tsx): `frontend/src/components/BatchResults.tsx`
- [Trend chart](https://github.com/niharxd/heritageai/blob/main/frontend/src/components/TrendChart.tsx): `frontend/src/components/TrendChart.tsx`
- [Image quality](https://github.com/niharxd/heritageai/blob/main/frontend/src/components/ImageQuality.tsx): `frontend/src/components/ImageQuality.tsx`

### Image analysis

- [Analysis pipeline](https://github.com/niharxd/heritageai/blob/main/backend/pipeline.py): `backend/pipeline.py`
- [Preprocessing](https://github.com/niharxd/heritageai/blob/main/backend/preprocessing.py): `backend/preprocessing.py`
- [Damage detection](https://github.com/niharxd/heritageai/blob/main/backend/damage_detection.py): `backend/damage_detection.py`
- [Image enhancement](https://github.com/niharxd/heritageai/blob/main/backend/enhancement.py): `backend/enhancement.py`
- [OCR and labels](https://github.com/niharxd/heritageai/blob/main/backend/ocr_engine.py): `backend/ocr_engine.py`
- [Risk prediction](https://github.com/niharxd/heritageai/blob/main/backend/risk_prediction.py): `backend/risk_prediction.py`
- [Age estimation](https://github.com/niharxd/heritageai/blob/main/backend/age_estimation.py): `backend/age_estimation.py`
- [Explainability](https://github.com/niharxd/heritageai/blob/main/backend/explainability.py): `backend/explainability.py`
- [Restoration advice](https://github.com/niharxd/heritageai/blob/main/backend/restoration_suggestions.py): `backend/restoration_suggestions.py`
- [Material detection](https://github.com/niharxd/heritageai/blob/main/backend/material_detection.py): `backend/material_detection.py`
- [Duplicate detection](https://github.com/niharxd/heritageai/blob/main/backend/duplicate_detector.py): `backend/duplicate_detector.py`

### Archive and reporting

- [HTTP API](https://github.com/niharxd/heritageai/blob/main/app.py): `app.py`
- [History store](https://github.com/niharxd/heritageai/blob/main/backend/history_store.py): `backend/history_store.py`
- [PDF reports](https://github.com/niharxd/heritageai/blob/main/backend/pdf_report.py): `backend/pdf_report.py`

### External services

- **Place geocoding**

### Other components

- **Conservator**

## Connections

- Conservator → Application views: uses (evidence: `README.md`)
- Application views → API client: requests analysis (evidence: `frontend/src/App.tsx`)
- API client → HTTP API: calls endpoints (evidence: `README.md`)
- HTTP API → Analysis pipeline: runs analysis (evidence: `app.py`)
- Analysis pipeline → Preprocessing: estimates domain (evidence: `backend/pipeline.py`)
- Analysis pipeline → Damage detection: detects damage (evidence: `backend/pipeline.py`)
- Analysis pipeline → Image enhancement: enhances image (evidence: `backend/pipeline.py`)
- Analysis pipeline → OCR and labels: extracts semantics (evidence: `backend/pipeline.py`)
- Analysis pipeline → Risk prediction: scores risk (evidence: `backend/pipeline.py`)
- Analysis pipeline → Age estimation: estimates age (evidence: `backend/pipeline.py`)
- Analysis pipeline → Explainability: explains findings (evidence: `backend/pipeline.py`)
- Analysis pipeline → Restoration advice: suggests restoration (evidence: `backend/pipeline.py`)
- HTTP API → History store: reads and writes (evidence: `app.py`)
- HTTP API → PDF reports: generates reports (evidence: `app.py`)
- Application views → Batch results: shows batch (evidence: `frontend/src/App.tsx`)
- Application views → Image quality: checks uploads (evidence: `frontend/src/App.tsx`)
- Application views → Image annotation: offers annotation (evidence: `frontend/src/App.tsx`)
- Archive gallery → API client: loads archive (evidence: `frontend/src/pages/Gallery.tsx`)
- Archive gallery → Trend chart: renders trends (evidence: `frontend/src/pages/Gallery.tsx`)
- Statistics → API client: loads statistics (evidence: `frontend/src/pages/StatsPage.tsx`)
- Statistics → Trend chart: renders trends (evidence: `frontend/src/pages/StatsPage.tsx`)
- Map view → API client: loads map pins (evidence: `frontend/src/pages/MapView.tsx`)
- Urgency queue → API client: loads queue (evidence: `frontend/src/pages/UrgencyQueue.tsx`)
- Comparison → API client: loads analyses (evidence: `frontend/src/pages/Compare.tsx`)
- Conservator → Place geocoding: searches locations (evidence: `README.md`)
- HTTP API → Material detection: may classify material
- HTTP API → Duplicate detection: checks duplicates (evidence: `app.py`)
