# mohalthaf/artifex architecture

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

- Interactive diagram: https://gitdiagram.com/mohalthaf/artifex
- Repository: https://github.com/mohalthaf/artifex

## Overview

ARTIFEX is a research prototype for brushstroke-aware restoration of Van Gogh paintings, with a local web demo for uploads and model comparison. Its research workflow prepares paintings and synthetic damage, trains a dual-stream inpainting model using brushstroke-related loss supervision, and evaluates restorations with standard and custom metrics. The demo exposes model discovery and inference through Flask and presents results and research evidence in Next.js. Connections involving the unsampled upload client and training pipeline are documented at the product level; some implementation wiring remains unverified.

Main entry points: [`artifex/server/ml/app.py`](https://github.com/mohalthaf/artifex/blob/main/artifex/server/ml/app.py) (Flask API), [`artifex/client-next/components/ModelResultCard.jsx`](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/ModelResultCard.jsx) (Restoration results), [`artifex/client-next/components/UploadZone.jsx`](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/UploadZone.jsx) (Upload interface), [`artifex/client-next/app/page.jsx`](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/app/page.jsx) (Demo page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_research["Research pipeline"]
  node_dataset["Dataset prep"]
  node_damage["Synthetic damage"]
  node_training["Model training"]
end

subgraph group_serving["Restoration service"]
  node_generator["Dual-stream generator"]
  node_registry[("Model registry<br/>[model_registry.py]")]
  node_metrics["Image metrics<br/>[metrics.py]"]
  node_api["Flask API<br/>[app.py]"]
end

subgraph group_web["Web experience"]
  node_upload["Upload interface<br/>[UploadZone.jsx]"]
  node_clientapi["API client<br/>[api.js]"]
  node_page["Demo page<br/>[page.jsx]"]
  node_result["Restoration results"]
  node_slider["Before-after view"]
  node_metricbadge["Metric display<br/>[MetricBadge.jsx]"]
end

subgraph group_evidence["Evaluation evidence"]
  node_evidence["Evidence dashboard"]
  node_evidenceparts["Evidence components"]
  node_benchmark["Benchmark evaluation"]
  node_statistics["Statistical analysis"]
end

node_researcher(("Researcher"))
node_visitor(("Demo user"))

node_researcher -->|"prepares data"| node_dataset
node_dataset -->|"generates masks"| node_damage
node_researcher -->|"trains model"| node_training
node_training -.->|"defines architecture"| node_generator
node_visitor -.->|"uploads image"| node_upload
node_upload -.->|"sends request"| node_clientapi
node_clientapi -.->|"calls service"| node_api
node_page -.->|"renders"| node_upload
node_page -.->|"renders"| node_result
node_api -->|"reads models"| node_registry
node_api -->|"runs inference"| node_generator
node_api -->|"computes metrics"| node_metrics
node_result -->|"renders"| node_slider
node_result -->|"renders"| node_metricbadge
node_evidence -->|"renders"| node_evidenceparts
node_researcher -->|"evaluates models"| node_benchmark
node_benchmark -.->|"supports comparisons"| node_statistics

click node_dataset "https://github.com/mohalthaf/artifex/blob/main/scripts/preprocess_dataset.py"
click node_damage "https://github.com/mohalthaf/artifex/blob/main/scripts/generate_realistic_masks.py"
click node_training "https://github.com/mohalthaf/artifex/blob/main/artifex_training.ipynb"
click node_generator "https://github.com/mohalthaf/artifex/blob/main/artifex/server/ml/canonical_inference.py"
click node_registry "https://github.com/mohalthaf/artifex/blob/main/artifex/server/ml/model_registry.py"
click node_metrics "https://github.com/mohalthaf/artifex/blob/main/artifex/server/ml/metrics.py"
click node_api "https://github.com/mohalthaf/artifex/blob/main/artifex/server/ml/app.py"
click node_upload "https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/UploadZone.jsx"
click node_clientapi "https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/lib/api.js"
click node_page "https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/app/page.jsx"
click node_result "https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/ModelResultCard.jsx"
click node_slider "https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/BeforeAfterSlider.jsx"
click node_metricbadge "https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/MetricBadge.jsx"
click node_evidence "https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/EvidenceDashboard.jsx"
click node_evidenceparts "https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/EvidenceComponents.jsx"
click node_benchmark "https://github.com/mohalthaf/artifex/blob/main/scripts/evaluate_camera_ready.py"
click node_statistics "https://github.com/mohalthaf/artifex/blob/main/scripts/statistical_analysis_corrected.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_dataset,node_damage,node_training,node_visitor toneBlue
class node_generator,node_registry,node_metrics,node_api toneAmber
class node_upload,node_clientapi,node_page,node_result,node_slider,node_metricbadge toneMint
class node_evidence,node_evidenceparts,node_benchmark,node_statistics toneRose
class node_researcher toneIndigo
```

## Components

### Research pipeline

- [Dataset prep](https://github.com/mohalthaf/artifex/blob/main/scripts/preprocess_dataset.py): `scripts/preprocess_dataset.py`
- [Synthetic damage](https://github.com/mohalthaf/artifex/blob/main/scripts/generate_realistic_masks.py): `scripts/generate_realistic_masks.py`
- [Model training](https://github.com/mohalthaf/artifex/blob/main/artifex_training.ipynb): `artifex_training.ipynb`

### Restoration service

- [Dual-stream generator](https://github.com/mohalthaf/artifex/blob/main/artifex/server/ml/canonical_inference.py): `artifex/server/ml/canonical_inference.py`
- [Model registry](https://github.com/mohalthaf/artifex/blob/main/artifex/server/ml/model_registry.py): `artifex/server/ml/model_registry.py`
- [Image metrics](https://github.com/mohalthaf/artifex/blob/main/artifex/server/ml/metrics.py): `artifex/server/ml/metrics.py`
- [Flask API](https://github.com/mohalthaf/artifex/blob/main/artifex/server/ml/app.py): `artifex/server/ml/app.py`

### Web experience

- [Upload interface](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/UploadZone.jsx): `artifex/client-next/components/UploadZone.jsx`
- [API client](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/lib/api.js): `artifex/client-next/lib/api.js`
- [Demo page](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/app/page.jsx): `artifex/client-next/app/page.jsx`
- [Restoration results](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/ModelResultCard.jsx): `artifex/client-next/components/ModelResultCard.jsx`
- [Before-after view](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/BeforeAfterSlider.jsx): `artifex/client-next/components/BeforeAfterSlider.jsx`
- [Metric display](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/MetricBadge.jsx): `artifex/client-next/components/MetricBadge.jsx`

### Evaluation evidence

- [Evidence dashboard](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/EvidenceDashboard.jsx): `artifex/client-next/components/EvidenceDashboard.jsx`
- [Evidence components](https://github.com/mohalthaf/artifex/blob/main/artifex/client-next/components/EvidenceComponents.jsx): `artifex/client-next/components/EvidenceComponents.jsx`
- [Benchmark evaluation](https://github.com/mohalthaf/artifex/blob/main/scripts/evaluate_camera_ready.py): `scripts/evaluate_camera_ready.py`
- [Statistical analysis](https://github.com/mohalthaf/artifex/blob/main/scripts/statistical_analysis_corrected.py): `scripts/statistical_analysis_corrected.py`

### Other components

- **Researcher**
- **Demo user**

## Connections

- Researcher → Dataset prep: prepares data (evidence: `README.md`)
- Dataset prep → Synthetic damage: generates masks (evidence: `README.md`)
- Researcher → Model training: trains model (evidence: `README.md`)
- Model training → Dual-stream generator: defines architecture
- Demo user → Upload interface: uploads image
- Upload interface → API client: sends request
- API client → Flask API: calls service
- Demo page → Upload interface: renders
- Demo page → Restoration results: renders
- Flask API → Model registry: reads models (evidence: `artifex/server/ml/app.py`)
- Flask API → Dual-stream generator: runs inference (evidence: `artifex/server/ml/app.py`)
- Flask API → Image metrics: computes metrics (evidence: `artifex/server/ml/app.py`)
- Restoration results → Before-after view: renders (evidence: `artifex/client-next/components/ModelResultCard.jsx`)
- Restoration results → Metric display: renders (evidence: `artifex/client-next/components/ModelResultCard.jsx`)
- Evidence dashboard → Evidence components: renders (evidence: `artifex/client-next/components/EvidenceDashboard.jsx`)
- Researcher → Benchmark evaluation: evaluates models (evidence: `README.md`)
- Benchmark evaluation → Statistical analysis: supports comparisons
