# orfa1i/goldendentist architecture

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

## Overview

GoldenDentist is a browser-based cephalometric tracing and analysis tool. A user uploads a radiograph, places or suggests landmarks, reviews calibrated orthodontic measurements, then saves/imports a case or generates a PDF report. The repository also includes a separate model-development workflow for training and evaluating automatic landmark detection. The browser wiring is sampled; several AI implementation details are known only from the README and source index, so uncertain connections are omitted or marked dashed.

Main entry points: [`js/app.js`](https://github.com/orfa1i/goldendentist/blob/master/js/app.js) (App controller), [`ai/train.py`](https://github.com/orfa1i/goldendentist/blob/master/ai/train.py) (Model training), [`js/ai/index.js`](https://github.com/orfa1i/goldendentist/blob/master/js/ai/index.js) (AI backend selector), [`ai/dataset.py`](https://github.com/orfa1i/goldendentist/blob/master/ai/dataset.py) (Aariz dataset loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tracing["Tracing workspace"]
  node_app["App controller<br/>[app.js]"]
  node_tracer["SVG tracer<br/>[tracer.js]"]
  node_landmarks["Landmark catalog<br/>[landmarks.js]"]
  node_storage["Case persistence<br/>[storage.js]"]
end

subgraph group_analysis["Analysis and reports"]
  node_analysis_runner["Measurement analyses<br/>[analyses.js]"]
  node_geometry["Geometry primitives<br/>[geometry.js]"]
  node_pdf["PDF report<br/>[report.js]"]
end

subgraph group_ai_runtime["Automatic tracing"]
  node_ai_dispatch["AI backend selector<br/>[index.js]"]
  node_heuristic["Heuristic detector<br/>[heuristic.js]"]
  node_onnx_runtime["ONNX inference<br/>[onnx.js]"]
  node_preprocess["Image preprocessing<br/>[preprocess.js]"]
end

subgraph group_ai_development["Model development"]
  node_dataset["Aariz dataset loader<br/>[dataset.py]"]
  node_landmark_mapping["Landmark mapping"]
  node_unet["U-Net model<br/>[model.py]"]
  node_training["Model training<br/>[train.py]"]
  node_evaluation["ONNX evaluation<br/>[eval_onnx.py]"]
  node_export["ONNX export<br/>[export_onnx.py]"]
end

node_user(("Clinician / user"))
node_browser_store[("Browser localStorage")]
node_dataset_source[("Aariz / CEPHA29 data")]

node_user -->|"uses"| node_app
node_app -->|"controls"| node_tracer
node_app -->|"loads catalog"| node_landmarks
node_tracer -->|"looks up definitions"| node_landmarks
node_app -->|"runs analysis"| node_analysis_runner
node_analysis_runner -->|"computes measurements"| node_geometry
node_app -->|"requests suggestions"| node_ai_dispatch
node_ai_dispatch -->|"tries trained model"| node_onnx_runtime
node_ai_dispatch -->|"falls back"| node_heuristic
node_heuristic -->|"uses image tools"| node_preprocess
node_onnx_runtime -.->|"prepares inference input"| node_preprocess
node_ai_dispatch -->|"suggests landmarks"| node_tracer
node_app -->|"saves and loads cases"| node_storage
node_storage -->|"reads and writes"| node_browser_store
node_app -->|"generates report"| node_pdf
node_pdf -->|"calculates classification"| node_geometry
node_dataset_source -.->|"provides annotations"| node_dataset
node_dataset -->|"maps annotations"| node_landmark_mapping
node_training -->|"loads samples"| node_dataset
node_training -->|"uses landmark order"| node_landmark_mapping
node_training -->|"trains model"| node_unet
node_evaluation -->|"loads evaluation data"| node_dataset
node_evaluation -->|"maps landmarks"| node_landmark_mapping
node_export -->|"exports model"| node_unet
node_training -.->|"checkpoint for export"| node_export

click node_app "https://github.com/orfa1i/goldendentist/blob/master/js/app.js"
click node_tracer "https://github.com/orfa1i/goldendentist/blob/master/js/tracer.js"
click node_landmarks "https://github.com/orfa1i/goldendentist/blob/master/js/landmarks.js"
click node_storage "https://github.com/orfa1i/goldendentist/blob/master/js/storage.js"
click node_analysis_runner "https://github.com/orfa1i/goldendentist/blob/master/js/analyses.js"
click node_geometry "https://github.com/orfa1i/goldendentist/blob/master/js/geometry.js"
click node_pdf "https://github.com/orfa1i/goldendentist/blob/master/js/report.js"
click node_ai_dispatch "https://github.com/orfa1i/goldendentist/blob/master/js/ai/index.js"
click node_heuristic "https://github.com/orfa1i/goldendentist/blob/master/js/ai/heuristic.js"
click node_onnx_runtime "https://github.com/orfa1i/goldendentist/blob/master/js/ai/onnx.js"
click node_preprocess "https://github.com/orfa1i/goldendentist/blob/master/js/ai/preprocess.js"
click node_dataset "https://github.com/orfa1i/goldendentist/blob/master/ai/dataset.py"
click node_landmark_mapping "https://github.com/orfa1i/goldendentist/blob/master/ai/landmarks_mapping.py"
click node_unet "https://github.com/orfa1i/goldendentist/blob/master/ai/model.py"
click node_training "https://github.com/orfa1i/goldendentist/blob/master/ai/train.py"
click node_evaluation "https://github.com/orfa1i/goldendentist/blob/master/ai/eval_onnx.py"
click node_export "https://github.com/orfa1i/goldendentist/blob/master/ai/export_onnx.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_app,node_tracer,node_landmarks,node_storage,node_user toneBlue
class node_analysis_runner,node_geometry,node_pdf,node_browser_store,node_dataset_source toneAmber
class node_ai_dispatch,node_heuristic,node_onnx_runtime,node_preprocess toneMint
class node_dataset,node_landmark_mapping,node_unet,node_training,node_evaluation,node_export toneRose
```

## Components

### Tracing workspace

- [App controller](https://github.com/orfa1i/goldendentist/blob/master/js/app.js): `js/app.js`
- [SVG tracer](https://github.com/orfa1i/goldendentist/blob/master/js/tracer.js): `js/tracer.js`
- [Landmark catalog](https://github.com/orfa1i/goldendentist/blob/master/js/landmarks.js): `js/landmarks.js`
- [Case persistence](https://github.com/orfa1i/goldendentist/blob/master/js/storage.js): `js/storage.js`

### Analysis and reports

- [Measurement analyses](https://github.com/orfa1i/goldendentist/blob/master/js/analyses.js): `js/analyses.js`
- [Geometry primitives](https://github.com/orfa1i/goldendentist/blob/master/js/geometry.js): `js/geometry.js`
- [PDF report](https://github.com/orfa1i/goldendentist/blob/master/js/report.js): `js/report.js`

### Automatic tracing

- [AI backend selector](https://github.com/orfa1i/goldendentist/blob/master/js/ai/index.js): `js/ai/index.js`
- [Heuristic detector](https://github.com/orfa1i/goldendentist/blob/master/js/ai/heuristic.js): `js/ai/heuristic.js`
- [ONNX inference](https://github.com/orfa1i/goldendentist/blob/master/js/ai/onnx.js): `js/ai/onnx.js`
- [Image preprocessing](https://github.com/orfa1i/goldendentist/blob/master/js/ai/preprocess.js): `js/ai/preprocess.js`

### Model development

- [Aariz dataset loader](https://github.com/orfa1i/goldendentist/blob/master/ai/dataset.py): `ai/dataset.py`
- [Landmark mapping](https://github.com/orfa1i/goldendentist/blob/master/ai/landmarks_mapping.py): `ai/landmarks_mapping.py`
- [U-Net model](https://github.com/orfa1i/goldendentist/blob/master/ai/model.py): `ai/model.py`
- [Model training](https://github.com/orfa1i/goldendentist/blob/master/ai/train.py): `ai/train.py`
- [ONNX evaluation](https://github.com/orfa1i/goldendentist/blob/master/ai/eval_onnx.py): `ai/eval_onnx.py`
- [ONNX export](https://github.com/orfa1i/goldendentist/blob/master/ai/export_onnx.py): `ai/export_onnx.py`

### Other components

- **Clinician / user**
- **Browser localStorage**
- **Aariz / CEPHA29 data**

## Connections

- Clinician / user → App controller: uses (evidence: `README.md`)
- App controller → SVG tracer: controls (evidence: `js/app.js`)
- App controller → Landmark catalog: loads catalog (evidence: `js/app.js`)
- SVG tracer → Landmark catalog: looks up definitions (evidence: `js/tracer.js`)
- App controller → Measurement analyses: runs analysis (evidence: `js/app.js`)
- Measurement analyses → Geometry primitives: computes measurements (evidence: `js/analyses.js`)
- App controller → AI backend selector: requests suggestions (evidence: `js/app.js`)
- AI backend selector → ONNX inference: tries trained model (evidence: `js/ai/index.js`)
- AI backend selector → Heuristic detector: falls back (evidence: `js/ai/index.js`)
- Heuristic detector → Image preprocessing: uses image tools (evidence: `js/ai/heuristic.js`)
- ONNX inference → Image preprocessing: prepares inference input
- AI backend selector → SVG tracer: suggests landmarks (evidence: `js/app.js`)
- App controller → Case persistence: saves and loads cases (evidence: `js/app.js`)
- Case persistence → Browser localStorage: reads and writes (evidence: `js/storage.js`)
- App controller → PDF report: generates report (evidence: `js/app.js`)
- PDF report → Geometry primitives: calculates classification (evidence: `js/report.js`)
- Aariz / CEPHA29 data → Aariz dataset loader: provides annotations
- Aariz dataset loader → Landmark mapping: maps annotations (evidence: `ai/dataset.py`)
- Model training → Aariz dataset loader: loads samples (evidence: `ai/train.py`)
- Model training → Landmark mapping: uses landmark order (evidence: `ai/train.py`)
- Model training → U-Net model: trains model (evidence: `ai/train.py`)
- ONNX evaluation → Aariz dataset loader: loads evaluation data (evidence: `ai/eval_onnx.py`)
- ONNX evaluation → Landmark mapping: maps landmarks (evidence: `ai/eval_onnx.py`)
- ONNX export → U-Net model: exports model (evidence: `ai/export_onnx.py`)
- Model training → ONNX export: checkpoint for export
