# milanbpatel90-a11y/deformation architecture

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

- Interactive diagram: https://gitdiagram.com/milanbpatel90-a11y/deformation
- Repository: https://github.com/milanbpatel90-a11y/deformation

## Overview

This repository is an eyewear virtual-try-on and 3D asset-generation toolkit. Its main image workflow segments glasses, classifies their style, extracts physical measurements, selects a template, deforms its mesh, and exports a GLB. It also contains an automatic parametric-generation path, a separate glasses3d CLI workflow, API/authentication and rim-detection routes, template matching and measurement-fusion modules, and Blender/factory tooling for preparing assets. The graph emphasizes relationships visible in excerpts or the source index; unsampled subsystems and API dispatch details are not asserted as verified calls.

Main entry points: [`backend/pipeline.py`](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/pipeline.py) (Deformation workflow), [`backend/pipeline/auto_3d_pipeline.py`](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/pipeline/auto_3d_pipeline.py) (Auto 3D workflow), [`glasses3d/main.py`](https://github.com/milanbpatel90-a11y/deformation/blob/main/glasses3d/main.py) (Glasses3D CLI), [`backend/api/main.py`](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/api/main.py) (API service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_service["API and access"]
  node_api["API service<br/>[main.py]"]
  node_auth[("Authentication<br/>[auth.py]")]
  node_rim_api["Rim detection API"]
end

subgraph group_vision["Image understanding"]
  node_segment["Glasses segmentation<br/>[segmenter.py]"]
  node_classifier["Style classification"]
  node_measure["Image measurements<br/>[extractor.py]"]
  node_mask_measure["Mask measurements"]
  node_fusion["Measurement fusion"]
  node_view["View classification<br/>[view_classifier.py]"]
  node_opacity["Lens opacity"]
end

subgraph group_geometry["3D generation"]
  node_pipeline["Deformation workflow<br/>[pipeline.py]"]
  node_auto_pipeline["Auto 3D workflow"]
  node_context["Deformation context"]
  node_deformer["Mesh deformation<br/>[engine.py]"]
  node_generator["Parametric generator"]
  node_exporter["GLB export<br/>[glb_exporter.py]"]
  node_materials["PBR materials<br/>[pbr.py]"]
  node_cli["Glasses3D CLI<br/>[main.py]"]
end

subgraph group_assets["Template assets"]
  node_templates["Template library<br/>[loader.py]"]
  node_matching["Template matching<br/>[scoring.py]"]
  node_descriptor["Template descriptors"]
end

subgraph group_authoring["Asset authoring"]
  node_designer["Blender authoring<br/>[geometry.py]"]
  node_factory["Asset factory<br/>[importer.py]"]
end

node_user(("Image user"))

node_user -.->|"submits images"| node_api
node_api -.->|"uses access control"| node_auth
node_api -.->|"dispatches workflow"| node_pipeline
node_api -.->|"routes requests"| node_rim_api
node_pipeline -->|"segments image"| node_segment
node_pipeline -->|"classifies style"| node_classifier
node_pipeline -->|"extracts measurements"| node_measure
node_pipeline -->|"loads template"| node_templates
node_pipeline -->|"deforms mesh"| node_deformer
node_pipeline -->|"applies materials"| node_materials
node_pipeline -->|"exports model"| node_exporter
node_auto_pipeline -->|"segments image"| node_segment
node_auto_pipeline -->|"classifies shape"| node_classifier
node_auto_pipeline -->|"extracts dimensions"| node_mask_measure
node_auto_pipeline -->|"generates model"| node_generator
node_deformer -->|"updates context"| node_context
node_context -->|"loads descriptor"| node_descriptor
node_deformer -.->|"uses template"| node_templates
node_pipeline -.->|"fuses measurements"| node_fusion
node_pipeline -.->|"classifies views"| node_view
node_pipeline -.->|"detects opacity"| node_opacity
node_templates -.->|"supports retrieval"| node_matching
node_cli -.->|"preprocesses images"| node_segment
node_cli -->|"loads template"| node_templates
node_cli -->|"deforms template"| node_deformer
node_cli -->|"exports GLB"| node_exporter

click node_api "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/api/main.py"
click node_auth "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/auth.py"
click node_rim_api "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/api/rim_detection_routes.py"
click node_pipeline "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/pipeline.py"
click node_auto_pipeline "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/pipeline/auto_3d_pipeline.py"
click node_segment "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/segmentation/segmenter.py"
click node_classifier "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/classifier/shape_classifier.py"
click node_measure "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/measurement/extractor.py"
click node_mask_measure "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/measurement/mask_to_measurements.py"
click node_fusion "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/fusion/measurement_fuser.py"
click node_view "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/fusion/view_classifier.py"
click node_opacity "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/fusion/opacity_detector.py"
click node_templates "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/template_library/loader.py"
click node_matching "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/template_matching/scoring.py"
click node_descriptor "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/deformer/descriptor_loader.py"
click node_context "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/deformer/deformation_context.py"
click node_deformer "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/deformer/engine.py"
click node_generator "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/generator/parametric_glb_generator.py"
click node_exporter "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/exporter/glb_exporter.py"
click node_materials "https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/materials/pbr.py"
click node_designer "https://github.com/milanbpatel90-a11y/deformation/blob/main/designer/blender_addon/geometry.py"
click node_factory "https://github.com/milanbpatel90-a11y/deformation/blob/main/factory/importer.py"
click node_cli "https://github.com/milanbpatel90-a11y/deformation/blob/main/glasses3d/main.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_api,node_auth,node_rim_api,node_user toneBlue
class node_segment,node_classifier,node_measure,node_mask_measure,node_fusion,node_view,node_opacity toneAmber
class node_pipeline,node_auto_pipeline,node_context,node_deformer,node_generator,node_exporter,node_materials,node_cli toneMint
class node_templates,node_matching,node_descriptor toneRose
class node_designer,node_factory toneIndigo
```

## Components

### API and access

- [API service](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/api/main.py): `backend/api/main.py`
- [Authentication](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/auth.py): `backend/auth.py`
- [Rim detection API](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/api/rim_detection_routes.py): `backend/api/rim_detection_routes.py`

### Image understanding

- [Glasses segmentation](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/segmentation/segmenter.py): `backend/segmentation/segmenter.py`
- [Style classification](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/classifier/shape_classifier.py): `backend/classifier/shape_classifier.py`
- [Image measurements](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/measurement/extractor.py): `backend/measurement/extractor.py`
- [Mask measurements](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/measurement/mask_to_measurements.py): `backend/measurement/mask_to_measurements.py`
- [Measurement fusion](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/fusion/measurement_fuser.py): `backend/fusion/measurement_fuser.py`
- [View classification](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/fusion/view_classifier.py): `backend/fusion/view_classifier.py`
- [Lens opacity](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/fusion/opacity_detector.py): `backend/fusion/opacity_detector.py`

### 3D generation

- [Deformation workflow](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/pipeline.py): `backend/pipeline.py`
- [Auto 3D workflow](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/pipeline/auto_3d_pipeline.py): `backend/pipeline/auto_3d_pipeline.py`
- [Deformation context](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/deformer/deformation_context.py): `backend/deformer/deformation_context.py`
- [Mesh deformation](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/deformer/engine.py): `backend/deformer/engine.py`
- [Parametric generator](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/generator/parametric_glb_generator.py): `backend/generator/parametric_glb_generator.py`
- [GLB export](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/exporter/glb_exporter.py): `backend/exporter/glb_exporter.py`
- [PBR materials](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/materials/pbr.py): `backend/materials/pbr.py`
- [Glasses3D CLI](https://github.com/milanbpatel90-a11y/deformation/blob/main/glasses3d/main.py): `glasses3d/main.py`

### Template assets

- [Template library](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/template_library/loader.py): `backend/template_library/loader.py`
- [Template matching](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/template_matching/scoring.py): `backend/template_matching/scoring.py`
- [Template descriptors](https://github.com/milanbpatel90-a11y/deformation/blob/main/backend/deformer/descriptor_loader.py): `backend/deformer/descriptor_loader.py`

### Asset authoring

- [Blender authoring](https://github.com/milanbpatel90-a11y/deformation/blob/main/designer/blender_addon/geometry.py): `designer/blender_addon/geometry.py`
- [Asset factory](https://github.com/milanbpatel90-a11y/deformation/blob/main/factory/importer.py): `factory/importer.py`

### Other components

- **Image user**

## Connections

- Image user → API service: submits images
- API service → Authentication: uses access control (evidence: `backend/api/main.py`)
- API service → Deformation workflow: dispatches workflow (evidence: `backend/api/main.py`)
- API service → Rim detection API: routes requests (evidence: `backend/api/main.py`)
- Deformation workflow → Glasses segmentation: segments image (evidence: `backend/pipeline.py`)
- Deformation workflow → Style classification: classifies style (evidence: `backend/pipeline.py`)
- Deformation workflow → Image measurements: extracts measurements (evidence: `backend/pipeline.py`)
- Deformation workflow → Template library: loads template (evidence: `backend/pipeline.py`)
- Deformation workflow → Mesh deformation: deforms mesh (evidence: `backend/pipeline.py`)
- Deformation workflow → PBR materials: applies materials (evidence: `backend/pipeline.py`)
- Deformation workflow → GLB export: exports model (evidence: `backend/pipeline.py`)
- Auto 3D workflow → Glasses segmentation: segments image (evidence: `backend/pipeline/auto_3d_pipeline.py`)
- Auto 3D workflow → Style classification: classifies shape (evidence: `backend/pipeline/auto_3d_pipeline.py`)
- Auto 3D workflow → Mask measurements: extracts dimensions (evidence: `backend/pipeline/auto_3d_pipeline.py`)
- Auto 3D workflow → Parametric generator: generates model (evidence: `backend/pipeline/auto_3d_pipeline.py`)
- Mesh deformation → Deformation context: updates context (evidence: `backend/deformer/engine.py`)
- Deformation context → Template descriptors: loads descriptor (evidence: `backend/deformer/deformation_context.py`)
- Mesh deformation → Template library: uses template
- Deformation workflow → Measurement fusion: fuses measurements
- Deformation workflow → View classification: classifies views
- Deformation workflow → Lens opacity: detects opacity
- Template library → Template matching: supports retrieval
- Glasses3D CLI → Glasses segmentation: preprocesses images
- Glasses3D CLI → Template library: loads template (evidence: `glasses3d/main.py`)
- Glasses3D CLI → Mesh deformation: deforms template (evidence: `glasses3d/main.py`)
- Glasses3D CLI → GLB export: exports GLB (evidence: `glasses3d/main.py`)
