# yunsmn/meshforge architecture

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

- Interactive diagram: https://gitdiagram.com/yunsmn/meshforge
- Repository: https://github.com/yunsmn/meshforge

## Overview

MeshForge is a notebook-based pipeline that turns an uploaded DWG/DXF floor plan into one unified 3D mesh. Its four sequential phases render and segment the plan, create CAD-conditioned image variants, generate per-segment meshes, then place and stitch them using Phase 1 metadata. The README documents these responsibilities and handoffs; no source excerpts were available, so internal call details are not inferred. Google Drive persistence is included as a supporting capability, not a pipeline stage.

Main entry points: [`Scripts/phase 1.ipynb`](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%201.ipynb) (Tiles and metadata), [`Scripts/phase 2.ipynb`](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%202.ipynb) (ControlNet rendering), [`Scripts/phase 3.ipynb`](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%203.ipynb) (Hunyuan3D inference), [`Scripts/phase 4.ipynb`](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%204.ipynb) (Mesh-to-segment mapping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_segmentation["Plan segmentation"]
  node_dxf_render["DXF overview render<br/>[phase 1.ipynb]"]
  node_density["Density regions<br/>[phase 1.ipynb]"]
  node_sam["SAM segmentation<br/>[phase 1.ipynb]"]
  node_segment_outputs["Tiles and metadata<br/>[phase 1.ipynb]"]
end

subgraph group_rendering["CAD rendering"]
  node_lineart["Line-art control map<br/>[phase 2.ipynb]"]
  node_controlnet["ControlNet rendering<br/>[phase 2.ipynb]"]
  node_render_variants["Rendered variants<br/>[phase 2.ipynb]"]
end

subgraph group_generation["Mesh generation"]
  node_background["Background removal<br/>[phase 3.ipynb]"]
  node_hunyuan["Hunyuan3D inference<br/>[phase 3.ipynb]"]
  node_segment_meshes["Segment GLB meshes<br/>[phase 3.ipynb]"]
end

subgraph group_stitching["Mesh stitching"]
  node_mesh_mapping["Mesh-to-segment mapping<br/>[phase 4.ipynb]"]
  node_mesh_alignment["Transform and align<br/>[phase 4.ipynb]"]
  node_mesh_cleanup["Weld and smooth<br/>[phase 4.ipynb]"]
  node_unified_mesh["Unified GLB mesh<br/>[phase 4.ipynb]"]
end

node_user(("Floor-plan user"))
node_cad["DWG/DXF plan"]
node_drive[("Google Drive")]

node_user -->|"uploads"| node_cad
node_cad -->|"renders"| node_dxf_render
node_dxf_render -->|"builds density map"| node_density
node_density -->|"segments regions"| node_sam
node_sam -->|"produces tiles and metadata"| node_segment_outputs
node_segment_outputs -->|"provides tiles"| node_lineart
node_lineart -->|"conditions rendering"| node_controlnet
node_controlnet -->|"generates variants"| node_render_variants
node_render_variants -->|"provides images"| node_background
node_background -->|"prepares images"| node_hunyuan
node_hunyuan -->|"exports meshes"| node_segment_meshes
node_segment_meshes -->|"loads meshes"| node_mesh_mapping
node_segment_outputs -->|"supplies spatial metadata"| node_mesh_mapping
node_mesh_mapping -->|"transforms and aligns"| node_mesh_alignment
node_mesh_alignment -->|"passes aligned meshes"| node_mesh_cleanup
node_mesh_cleanup -->|"exports"| node_unified_mesh
node_controlnet -->|"backs up renders"| node_drive
node_drive -.->|"caches model weights"| node_hunyuan

click node_dxf_render "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%201.ipynb"
click node_density "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%201.ipynb"
click node_sam "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%201.ipynb"
click node_segment_outputs "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%201.ipynb"
click node_lineart "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%202.ipynb"
click node_controlnet "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%202.ipynb"
click node_render_variants "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%202.ipynb"
click node_background "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%203.ipynb"
click node_hunyuan "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%203.ipynb"
click node_segment_meshes "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%203.ipynb"
click node_mesh_mapping "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%204.ipynb"
click node_mesh_alignment "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%204.ipynb"
click node_mesh_cleanup "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%204.ipynb"
click node_unified_mesh "https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%204.ipynb"

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_dxf_render,node_density,node_sam,node_segment_outputs,node_user toneBlue
class node_lineart,node_controlnet,node_render_variants,node_drive toneAmber
class node_background,node_hunyuan,node_segment_meshes toneMint
class node_mesh_mapping,node_mesh_alignment,node_mesh_cleanup,node_unified_mesh toneRose
class node_cad toneIndigo
```

## Components

### Plan segmentation

- [DXF overview render](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%201.ipynb): `Scripts/phase 1.ipynb`
- [Density regions](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%201.ipynb): `Scripts/phase 1.ipynb`
- [SAM segmentation](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%201.ipynb): `Scripts/phase 1.ipynb`
- [Tiles and metadata](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%201.ipynb): `Scripts/phase 1.ipynb`

### CAD rendering

- [Line-art control map](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%202.ipynb): `Scripts/phase 2.ipynb`
- [ControlNet rendering](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%202.ipynb): `Scripts/phase 2.ipynb`
- [Rendered variants](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%202.ipynb): `Scripts/phase 2.ipynb`

### Mesh generation

- [Background removal](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%203.ipynb): `Scripts/phase 3.ipynb`
- [Hunyuan3D inference](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%203.ipynb): `Scripts/phase 3.ipynb`
- [Segment GLB meshes](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%203.ipynb): `Scripts/phase 3.ipynb`

### Mesh stitching

- [Mesh-to-segment mapping](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%204.ipynb): `Scripts/phase 4.ipynb`
- [Transform and align](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%204.ipynb): `Scripts/phase 4.ipynb`
- [Weld and smooth](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%204.ipynb): `Scripts/phase 4.ipynb`
- [Unified GLB mesh](https://github.com/yunsmn/meshforge/blob/main/Scripts/phase%204.ipynb): `Scripts/phase 4.ipynb`

### Other components

- **Floor-plan user**
- **DWG/DXF plan**
- **Google Drive**

## Connections

- Floor-plan user → DWG/DXF plan: uploads (evidence: `README.md`)
- DWG/DXF plan → DXF overview render: renders (evidence: `README.md`)
- DXF overview render → Density regions: builds density map (evidence: `README.md`)
- Density regions → SAM segmentation: segments regions (evidence: `README.md`)
- SAM segmentation → Tiles and metadata: produces tiles and metadata (evidence: `README.md`)
- Tiles and metadata → Line-art control map: provides tiles (evidence: `README.md`)
- Line-art control map → ControlNet rendering: conditions rendering (evidence: `README.md`)
- ControlNet rendering → Rendered variants: generates variants (evidence: `README.md`)
- Rendered variants → Background removal: provides images (evidence: `README.md`)
- Background removal → Hunyuan3D inference: prepares images (evidence: `README.md`)
- Hunyuan3D inference → Segment GLB meshes: exports meshes (evidence: `README.md`)
- Segment GLB meshes → Mesh-to-segment mapping: loads meshes (evidence: `README.md`)
- Tiles and metadata → Mesh-to-segment mapping: supplies spatial metadata (evidence: `README.md`)
- Mesh-to-segment mapping → Transform and align: transforms and aligns (evidence: `README.md`)
- Transform and align → Weld and smooth: passes aligned meshes (evidence: `README.md`)
- Weld and smooth → Unified GLB mesh: exports (evidence: `README.md`)
- ControlNet rendering → Google Drive: backs up renders (evidence: `README.md`)
- Google Drive → Hunyuan3D inference: caches model weights (evidence: `README.md`)
