# febryannnn/dermadiff-ai architecture

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

- Interactive diagram: https://gitdiagram.com/febryannnn/dermadiff-ai
- Repository: https://github.com/febryannnn/dermadiff-ai

## Overview

DermaDiff is a clinician-facing skin-lesion decision-support system, supported by an offline synthetic-data training pipeline and an online classification/explanation workflow. README documentation establishes the major training stages and model handoffs; sampled backend/API and frontend excerpts support the interactive inference flow. Some training and MedGemma wiring is documented but not shown in sampled source, so those links reflect documented behavior.

Main entry points: [`website/backend/api/web.py`](https://github.com/febryannnn/dermadiff-ai/blob/main/website/backend/api/web.py) (HTTP API), [`website/frontend/src/components/product/classifier.tsx`](https://github.com/febryannnn/dermadiff-ai/blob/main/website/frontend/src/components/product/classifier.tsx) (Classifier UI), [`website/frontend/src/lib/api.ts`](https://github.com/febryannnn/dermadiff-ai/blob/main/website/frontend/src/lib/api.ts) (API client), [`fine-tune/dataset_prep.py`](https://github.com/febryannnn/dermadiff-ai/blob/main/fine-tune/dataset_prep.py) (Dataset preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clinical["Clinical application"]
  node_productui["Classifier UI<br/>[classifier.tsx]"]
  node_webpage["Product page<br/>[page.tsx]"]
  node_frontendapi["API client<br/>[api.ts]"]
end

subgraph group_inference["Inference services"]
  node_webapi["HTTP API<br/>[web.py]"]
  node_cache[("Result cache<br/>[app.py]")]
  node_panderm["PanDerm classifier<br/>[panderm.py]"]
  node_medgemma["MedGemma explainer<br/>[medgemma.py]"]
end

subgraph group_training["Training pipeline"]
  node_hamdata["HAM10000 data<br/>[ham10000.py]"]
  node_isicdata["ISIC 2019 data<br/>[isic2019.py]"]
  node_prep["Dataset preparation<br/>[dataset_prep.py]"]
  node_diffusion["Diffusion fine-tuning"]
  node_synthesis["Synthetic image generation"]
  node_classifiertraining["PanDerm training"]
  node_registry[("Model registry")]
end

subgraph group_evaluation["Model evaluation"]
  node_evaluation["Model evaluation"]
end

node_clinician(("Clinician"))
node_externalhub["Hugging Face Hub"]
node_diffusionmodels["Stable Diffusion models"]
node_hamhost["Harvard Dataverse"]
node_isichost["ISIC dataset source"]

node_clinician -->|"uploads image"| node_productui
node_webpage -->|"presents"| node_productui
node_productui -->|"requests analysis"| node_frontendapi
node_frontendapi -->|"sends requests"| node_webapi
node_webapi -->|"classifies image"| node_panderm
node_webapi -->|"reads and writes"| node_cache
node_webapi -->|"requests explanation"| node_medgemma
node_webapi -->|"returns results"| node_frontendapi
node_frontendapi -->|"streams explanation"| node_productui
node_productui -->|"shows probabilities and heatmap"| node_clinician
node_hamhost -->|"provides dataset"| node_hamdata
node_isichost -->|"provides dataset"| node_isicdata
node_hamdata -->|"provides images and labels"| node_prep
node_isicdata -->|"provides images and labels"| node_prep
node_prep -->|"prepares class data"| node_diffusion
node_diffusionmodels -->|"base models"| node_diffusion
node_diffusion -->|"produces tuned generators"| node_synthesis
node_synthesis -->|"augments rare classes"| node_classifiertraining
node_prep -->|"provides original data"| node_classifiertraining
node_classifiertraining -->|"publishes best weights"| node_registry
node_registry -->|"stores weights"| node_externalhub
node_classifiertraining -->|"evaluated by"| node_evaluation
node_externalhub -->|"supplies classifier weights"| node_panderm
node_externalhub -.->|"supplies language model"| node_medgemma

click node_productui "https://github.com/febryannnn/dermadiff-ai/blob/main/website/frontend/src/components/product/classifier.tsx"
click node_webpage "https://github.com/febryannnn/dermadiff-ai/blob/main/website/frontend/src/app/product/page.tsx"
click node_frontendapi "https://github.com/febryannnn/dermadiff-ai/blob/main/website/frontend/src/lib/api.ts"
click node_webapi "https://github.com/febryannnn/dermadiff-ai/blob/main/website/backend/api/web.py"
click node_cache "https://github.com/febryannnn/dermadiff-ai/blob/main/website/backend/app.py"
click node_panderm "https://github.com/febryannnn/dermadiff-ai/blob/main/website/backend/models/panderm.py"
click node_medgemma "https://github.com/febryannnn/dermadiff-ai/blob/main/website/backend/models/medgemma.py"
click node_hamdata "https://github.com/febryannnn/dermadiff-ai/blob/main/fine-tune/dataset/ham10000.py"
click node_isicdata "https://github.com/febryannnn/dermadiff-ai/blob/main/fine-tune/dataset/isic2019.py"
click node_prep "https://github.com/febryannnn/dermadiff-ai/blob/main/fine-tune/dataset_prep.py"
click node_diffusion "https://github.com/febryannnn/dermadiff-ai/tree/main/fine-tune/models"
click node_synthesis "https://github.com/febryannnn/dermadiff-ai/tree/main/fine-tune/models"
click node_classifiertraining "https://github.com/febryannnn/dermadiff-ai/blob/main/fine-tune/stable-diffusion-xl-base/classifiers_training_LoRA.py"
click node_evaluation "https://github.com/febryannnn/dermadiff-ai/tree/main/fine-tune/evaluation"

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_productui,node_webpage,node_frontendapi toneBlue
class node_webapi,node_cache,node_panderm,node_medgemma toneAmber
class node_hamdata,node_isicdata,node_prep,node_diffusion,node_synthesis,node_classifiertraining,node_registry toneMint
class node_evaluation toneRose
class node_clinician,node_externalhub,node_diffusionmodels,node_hamhost,node_isichost toneIndigo
```

## Components

### Clinical application

- [Classifier UI](https://github.com/febryannnn/dermadiff-ai/blob/main/website/frontend/src/components/product/classifier.tsx): `website/frontend/src/components/product/classifier.tsx`
- [Product page](https://github.com/febryannnn/dermadiff-ai/blob/main/website/frontend/src/app/product/page.tsx): `website/frontend/src/app/product/page.tsx`
- [API client](https://github.com/febryannnn/dermadiff-ai/blob/main/website/frontend/src/lib/api.ts): `website/frontend/src/lib/api.ts`

### Inference services

- [HTTP API](https://github.com/febryannnn/dermadiff-ai/blob/main/website/backend/api/web.py): `website/backend/api/web.py`
- [Result cache](https://github.com/febryannnn/dermadiff-ai/blob/main/website/backend/app.py): `website/backend/app.py`
- [PanDerm classifier](https://github.com/febryannnn/dermadiff-ai/blob/main/website/backend/models/panderm.py): `website/backend/models/panderm.py`
- [MedGemma explainer](https://github.com/febryannnn/dermadiff-ai/blob/main/website/backend/models/medgemma.py): `website/backend/models/medgemma.py`

### Training pipeline

- [HAM10000 data](https://github.com/febryannnn/dermadiff-ai/blob/main/fine-tune/dataset/ham10000.py): `fine-tune/dataset/ham10000.py`
- [ISIC 2019 data](https://github.com/febryannnn/dermadiff-ai/blob/main/fine-tune/dataset/isic2019.py): `fine-tune/dataset/isic2019.py`
- [Dataset preparation](https://github.com/febryannnn/dermadiff-ai/blob/main/fine-tune/dataset_prep.py): `fine-tune/dataset_prep.py`
- [Diffusion fine-tuning](https://github.com/febryannnn/dermadiff-ai/tree/main/fine-tune/models): `fine-tune/models`
- [Synthetic image generation](https://github.com/febryannnn/dermadiff-ai/tree/main/fine-tune/models): `fine-tune/models`
- [PanDerm training](https://github.com/febryannnn/dermadiff-ai/blob/main/fine-tune/stable-diffusion-xl-base/classifiers_training_LoRA.py): `fine-tune/stable-diffusion-xl-base/classifiers_training_LoRA.py`
- **Model registry**

### Model evaluation

- [Model evaluation](https://github.com/febryannnn/dermadiff-ai/tree/main/fine-tune/evaluation): `fine-tune/evaluation`

### Other components

- **Clinician**
- **Hugging Face Hub**
- **Stable Diffusion models**
- **Harvard Dataverse**
- **ISIC dataset source**

## Connections

- Clinician → Classifier UI: uploads image
- Product page → Classifier UI: presents
- Classifier UI → API client: requests analysis
- API client → HTTP API: sends requests
- HTTP API → PanDerm classifier: classifies image
- HTTP API → Result cache: reads and writes
- HTTP API → MedGemma explainer: requests explanation
- HTTP API → API client: returns results
- API client → Classifier UI: streams explanation
- Classifier UI → Clinician: shows probabilities and heatmap
- Harvard Dataverse → HAM10000 data: provides dataset
- ISIC dataset source → ISIC 2019 data: provides dataset
- HAM10000 data → Dataset preparation: provides images and labels
- ISIC 2019 data → Dataset preparation: provides images and labels
- Dataset preparation → Diffusion fine-tuning: prepares class data
- Stable Diffusion models → Diffusion fine-tuning: base models
- Diffusion fine-tuning → Synthetic image generation: produces tuned generators
- Synthetic image generation → PanDerm training: augments rare classes
- Dataset preparation → PanDerm training: provides original data
- PanDerm training → Model registry: publishes best weights
- Model registry → Hugging Face Hub: stores weights
- PanDerm training → Model evaluation: evaluated by
- Hugging Face Hub → PanDerm classifier: supplies classifier weights
- Hugging Face Hub → MedGemma explainer: supplies language model
