# nikopolistico/nailvision architecture

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

- Interactive diagram: https://gitdiagram.com/nikopolistico/nailvision
- Repository: https://github.com/nikopolistico/nailvision

## Overview

NailVision lets a user select a hand photo, detects and selects nails in the browser, then requests per-nail designs from a Python Stable Diffusion service and displays the results. The frontend handles image selection, detection, controls, and job polling; the server validates uploaded photos and masks, runs generation, and exposes job status. The README documents browser-side ONNX detection and the separate design-generation service. The sampled files show frontend calls and server routes; the HTTP connection between them is represented as unverified because no excerpt explicitly links the two implementations.

Main entry points: [`src/App.vue`](https://github.com/nikopolistico/nailvision/blob/main/src/App.vue) (Photo and design UI), [`src/lib/utils.ts`](https://github.com/nikopolistico/nailvision/blob/main/src/lib/utils.ts) (Class utilities), [`sd-server/server.py`](https://github.com/nikopolistico/nailvision/blob/main/sd-server/server.py) (Job API and runner), [`src/lib/sd.ts`](https://github.com/nikopolistico/nailvision/blob/main/src/lib/sd.ts) (Generation API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend workflow"]
  node_app["Photo and design UI<br/>[App.vue]"]
  node_sdclient["Generation API client<br/>[sd.ts]"]
  node_entry["Vue app entry<br/>[main.ts]"]
end

subgraph group_detection["Nail detection"]
  node_detector["Browser nail detector<br/>[detector.ts]"]
  node_onnx["Nail segmentation model<br/>[nail_seg.onnx]"]
end

subgraph group_generation["Design generation"]
  node_sdserver["Job API and runner<br/>[server.py]"]
  node_nvutils["Image and style helpers<br/>[nv_utils.py]"]
  node_sdmodel[("Stable Diffusion model")]
end

subgraph group_ui["UI components"]
  node_button["Button<br/>[Button.vue]"]
  node_badge["Badge<br/>[Badge.vue]"]
  node_card["Card<br/>[Card.vue]"]
  node_slider["Slider<br/>[Slider.vue]"]
  node_utils["Class utilities<br/>[utils.ts]"]
end

node_user(("Photo user"))

node_user -->|"selects photo"| node_app
node_app -->|"detects nails"| node_detector
node_detector -.->|"runs inference"| node_onnx
node_app -->|"starts and polls"| node_sdclient
node_sdclient -.->|"requests jobs"| node_sdserver
node_sdserver -->|"uses helpers"| node_nvutils
node_sdserver -->|"loads model"| node_sdmodel
node_entry -->|"mounts"| node_app
node_app -->|"renders"| node_button
node_app -->|"renders"| node_badge
node_app -->|"renders"| node_card
node_utils -->|"styles"| node_button
node_utils -->|"styles"| node_badge
node_utils -->|"styles"| node_card
node_utils -->|"styles"| node_slider
node_app -.->|"configures"| node_slider

click node_app "https://github.com/nikopolistico/nailvision/blob/main/src/App.vue"
click node_detector "https://github.com/nikopolistico/nailvision/blob/main/src/lib/detector.ts"
click node_onnx "https://github.com/nikopolistico/nailvision/blob/main/src/model/nail_seg.onnx"
click node_sdclient "https://github.com/nikopolistico/nailvision/blob/main/src/lib/sd.ts"
click node_sdserver "https://github.com/nikopolistico/nailvision/blob/main/sd-server/server.py"
click node_nvutils "https://github.com/nikopolistico/nailvision/blob/main/sd-server/nv_utils.py"
click node_sdmodel "https://github.com/nikopolistico/nailvision/tree/main/gpu"
click node_button "https://github.com/nikopolistico/nailvision/blob/main/src/components/ui/button/Button.vue"
click node_badge "https://github.com/nikopolistico/nailvision/blob/main/src/components/ui/badge/Badge.vue"
click node_card "https://github.com/nikopolistico/nailvision/blob/main/src/components/ui/card/Card.vue"
click node_slider "https://github.com/nikopolistico/nailvision/blob/main/src/components/ui/slider/Slider.vue"
click node_utils "https://github.com/nikopolistico/nailvision/blob/main/src/lib/utils.ts"
click node_entry "https://github.com/nikopolistico/nailvision/blob/main/src/main.ts"

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_sdclient,node_entry,node_user toneBlue
class node_detector,node_onnx toneAmber
class node_sdserver,node_nvutils,node_sdmodel toneMint
class node_button,node_badge,node_card,node_slider,node_utils toneRose
```

## Components

### Frontend workflow

- [Photo and design UI](https://github.com/nikopolistico/nailvision/blob/main/src/App.vue): `src/App.vue`
- [Generation API client](https://github.com/nikopolistico/nailvision/blob/main/src/lib/sd.ts): `src/lib/sd.ts`
- [Vue app entry](https://github.com/nikopolistico/nailvision/blob/main/src/main.ts): `src/main.ts`

### Nail detection

- [Browser nail detector](https://github.com/nikopolistico/nailvision/blob/main/src/lib/detector.ts): `src/lib/detector.ts`
- [Nail segmentation model](https://github.com/nikopolistico/nailvision/blob/main/src/model/nail_seg.onnx): `src/model/nail_seg.onnx`

### Design generation

- [Job API and runner](https://github.com/nikopolistico/nailvision/blob/main/sd-server/server.py): `sd-server/server.py`
- [Image and style helpers](https://github.com/nikopolistico/nailvision/blob/main/sd-server/nv_utils.py): `sd-server/nv_utils.py`
- [Stable Diffusion model](https://github.com/nikopolistico/nailvision/tree/main/gpu): `gpu`

### UI components

- [Button](https://github.com/nikopolistico/nailvision/blob/main/src/components/ui/button/Button.vue): `src/components/ui/button/Button.vue`
- [Badge](https://github.com/nikopolistico/nailvision/blob/main/src/components/ui/badge/Badge.vue): `src/components/ui/badge/Badge.vue`
- [Card](https://github.com/nikopolistico/nailvision/blob/main/src/components/ui/card/Card.vue): `src/components/ui/card/Card.vue`
- [Slider](https://github.com/nikopolistico/nailvision/blob/main/src/components/ui/slider/Slider.vue): `src/components/ui/slider/Slider.vue`
- [Class utilities](https://github.com/nikopolistico/nailvision/blob/main/src/lib/utils.ts): `src/lib/utils.ts`

### Other components

- **Photo user**

## Connections

- Photo user → Photo and design UI: selects photo (evidence: `src/App.vue`)
- Photo and design UI → Browser nail detector: detects nails (evidence: `src/App.vue`)
- Browser nail detector → Nail segmentation model: runs inference
- Photo and design UI → Generation API client: starts and polls (evidence: `src/App.vue`)
- Generation API client → Job API and runner: requests jobs
- Job API and runner → Image and style helpers: uses helpers (evidence: `sd-server/server.py`)
- Job API and runner → Stable Diffusion model: loads model (evidence: `sd-server/server.py`)
- Vue app entry → Photo and design UI: mounts (evidence: `src/main.ts`)
- Photo and design UI → Button: renders (evidence: `src/App.vue`)
- Photo and design UI → Badge: renders (evidence: `src/App.vue`)
- Photo and design UI → Card: renders (evidence: `src/App.vue`)
- Class utilities → Button: styles (evidence: `src/components/ui/button/Button.vue`)
- Class utilities → Badge: styles (evidence: `src/components/ui/badge/Badge.vue`)
- Class utilities → Card: styles (evidence: `src/components/ui/card/Card.vue`)
- Class utilities → Slider: styles (evidence: `src/components/ui/slider/Slider.vue`)
- Photo and design UI → Slider: configures
