# theheavydriver/pixel2layer architecture

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

- Interactive diagram: https://gitdiagram.com/theheavydriver/pixel2layer
- Repository: https://github.com/theheavydriver/pixel2layer

## Overview

Pixel2Layer turns uploaded artwork into an editable, confidence-scored scene graph, then supports browser editing, saving, sharing, and export. The main workflow runs from upload through an asynchronous reconstruction job and back to the editor. The graph also preserves the documented tools, grouping, templates, batches, and optional SAM 2 segmentation capabilities. Some relationships are documented in the README or visible in the source index; unsampled route and UI internals are not inferred beyond that evidence.

Main entry points: [`apps/api/app/services/pipeline.py`](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/pipeline.py) (Reconstruction pipeline), [`apps/api/app/main.py`](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/main.py) (API application), [`apps/api/app/services/pipeline_worker.py`](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/pipeline_worker.py) (Pipeline worker), [`apps/web/src/components/editor/editor-screen.tsx`](https://github.com/theheavydriver/pixel2layer/blob/main/apps/web/src/components/editor/editor-screen.tsx) (Layered editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_upload_ui["Upload flow<br/>[upload-modal.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_editor["Layered editor<br/>[editor-screen.tsx]"]
  node_canvas["Canvas editor<br/>[canvas-editor.tsx]"]
  node_schema_ts["Shared scene schema<br/>[index.ts]"]
end

subgraph group_api["API and workflow"]
  node_api_app["API application<br/>[main.py]"]
  node_upload_service["Upload validation<br/>[upload_service.py]"]
  node_job_queue["Reconstruction jobs<br/>[job_queue.py]"]
  node_worker["Pipeline worker<br/>[pipeline_worker.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_storage_route["Stored asset delivery<br/>[storage.py]"]
end

subgraph group_reconstruction["Reconstruction"]
  node_pipeline["Reconstruction pipeline<br/>[pipeline.py]"]
  node_router["Progressive routing<br/>[progressive.py]"]
  node_text["Text detection<br/>[text_detector.py]"]
  node_font_match["Font matching<br/>[matching.py]"]
  node_shapes["Shape detection<br/>[shape_detector.py]"]
  node_segmenter["Region segmentation<br/>[segmenter.py]"]
  node_vectorizer["Vector paths<br/>[vectorizer.py]"]
  node_scene_builder["Scene graph builder"]
  node_confidence["Confidence scoring<br/>[confidence.py]"]
  node_scene_schema["Scene graph models<br/>[scene_graph.py]"]
  node_sam2["Optional SAM 2<br/>[sam2_segmenter.py]"]
end

subgraph group_persistence["Persistence"]
  node_blob_store[("Blob storage<br/>[storage.py]")]
  node_store[("Projects and sharing<br/>[store.py]")]
end

subgraph group_product_features["Product features"]
  node_product_routes["Tools and grouping<br/>[tools.py]"]
  node_export["Export formats<br/>[export_service.py]"]
  node_other_routes["Templates and batches<br/>[templates.py]"]
end

node_user(("User"))

node_user -->|"uploads artwork"| node_upload_ui
node_upload_ui -.->|"submits image"| node_api_client
node_api_client -->|"calls API"| node_api_app
node_api_app -->|"accepts uploads"| node_upload_service
node_upload_service -->|"stores original"| node_blob_store
node_api_app -->|"starts queue"| node_job_queue
node_job_queue -->|"dispatches work"| node_worker
node_worker -->|"reads and writes"| node_blob_store
node_worker -->|"runs pipeline"| node_pipeline
node_pipeline -->|"classifies complexity"| node_router
node_pipeline -->|"detects text"| node_text
node_pipeline -->|"matches fonts"| node_font_match
node_pipeline -->|"detects shapes"| node_shapes
node_pipeline -->|"segments regions"| node_segmenter
node_pipeline -->|"vectorizes artwork"| node_vectorizer
node_pipeline -->|"builds scene"| node_scene_builder
node_pipeline -->|"stores cutouts"| node_blob_store
node_pipeline -->|"produces model"| node_scene_schema
node_pipeline -.->|"may use backend"| node_sam2
node_worker -->|"reports progress"| node_job_queue
node_api_app -->|"initializes store"| node_store
node_api_app -->|"registers route"| node_storage_route
node_user -->|"edits reconstruction"| node_editor
node_editor -.->|"renders layers"| node_canvas
node_editor -->|"uses scene schema"| node_schema_ts
node_user -->|"uses image tools"| node_product_routes
node_user -->|"exports artwork"| node_export
node_user -->|"uses templates and batches"| node_other_routes
node_api_app -->|"serves authentication"| node_auth
node_user -->|"saves and shares projects"| node_store

click node_upload_ui "https://github.com/theheavydriver/pixel2layer/blob/main/apps/web/src/components/upload-modal.tsx"
click node_api_client "https://github.com/theheavydriver/pixel2layer/blob/main/apps/web/src/lib/api.ts"
click node_editor "https://github.com/theheavydriver/pixel2layer/blob/main/apps/web/src/components/editor/editor-screen.tsx"
click node_canvas "https://github.com/theheavydriver/pixel2layer/blob/main/apps/web/src/components/editor/canvas-editor.tsx"
click node_schema_ts "https://github.com/theheavydriver/pixel2layer/blob/main/packages/schema/src/index.ts"
click node_api_app "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/main.py"
click node_upload_service "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/upload_service.py"
click node_job_queue "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/job_queue.py"
click node_worker "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/pipeline_worker.py"
click node_pipeline "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/pipeline.py"
click node_router "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/progressive.py"
click node_text "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/text_detector.py"
click node_font_match "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/fonts/matching.py"
click node_shapes "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/shape_detector.py"
click node_segmenter "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/segmenter.py"
click node_vectorizer "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/vectorizer.py"
click node_scene_builder "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/scene_graph_builder.py"
click node_confidence "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/confidence.py"
click node_scene_schema "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/schemas/scene_graph.py"
click node_blob_store "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/storage.py"
click node_store "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/store.py"
click node_auth "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/auth.py"
click node_product_routes "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/api/routes/tools.py"
click node_export "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/export_service.py"
click node_other_routes "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/api/routes/templates.py"
click node_sam2 "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/finetune/sam2_segmenter.py"
click node_storage_route "https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/api/routes/storage.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_upload_ui,node_api_client,node_editor,node_canvas,node_schema_ts,node_user toneBlue
class node_api_app,node_upload_service,node_job_queue,node_worker,node_auth,node_storage_route toneAmber
class node_pipeline,node_router,node_text,node_font_match,node_shapes,node_segmenter,node_vectorizer,node_scene_builder,node_confidence,node_scene_schema,node_sam2 toneMint
class node_blob_store,node_store toneRose
class node_product_routes,node_export,node_other_routes toneIndigo
```

## Components

### Web application

- [Upload flow](https://github.com/theheavydriver/pixel2layer/blob/main/apps/web/src/components/upload-modal.tsx): `apps/web/src/components/upload-modal.tsx`
- [API client](https://github.com/theheavydriver/pixel2layer/blob/main/apps/web/src/lib/api.ts): `apps/web/src/lib/api.ts`
- [Layered editor](https://github.com/theheavydriver/pixel2layer/blob/main/apps/web/src/components/editor/editor-screen.tsx): `apps/web/src/components/editor/editor-screen.tsx`
- [Canvas editor](https://github.com/theheavydriver/pixel2layer/blob/main/apps/web/src/components/editor/canvas-editor.tsx): `apps/web/src/components/editor/canvas-editor.tsx`
- [Shared scene schema](https://github.com/theheavydriver/pixel2layer/blob/main/packages/schema/src/index.ts): `packages/schema/src/index.ts`

### API and workflow

- [API application](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/main.py): `apps/api/app/main.py`
- [Upload validation](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/upload_service.py): `apps/api/app/services/upload_service.py`
- [Reconstruction jobs](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/job_queue.py): `apps/api/app/services/job_queue.py`
- [Pipeline worker](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/pipeline_worker.py): `apps/api/app/services/pipeline_worker.py`
- [Authentication](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/auth.py): `apps/api/app/services/auth.py`
- [Stored asset delivery](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/api/routes/storage.py): `apps/api/app/api/routes/storage.py`

### Reconstruction

- [Reconstruction pipeline](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/pipeline.py): `apps/api/app/services/pipeline.py`
- [Progressive routing](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/progressive.py): `apps/api/app/services/progressive.py`
- [Text detection](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/text_detector.py): `apps/api/app/services/text_detector.py`
- [Font matching](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/fonts/matching.py): `apps/api/app/services/fonts/matching.py`
- [Shape detection](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/shape_detector.py): `apps/api/app/services/shape_detector.py`
- [Region segmentation](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/segmenter.py): `apps/api/app/services/segmenter.py`
- [Vector paths](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/vectorizer.py): `apps/api/app/services/vectorizer.py`
- [Scene graph builder](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/scene_graph_builder.py): `apps/api/app/services/scene_graph_builder.py`
- [Confidence scoring](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/confidence.py): `apps/api/app/services/confidence.py`
- [Scene graph models](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/schemas/scene_graph.py): `apps/api/app/schemas/scene_graph.py`
- [Optional SAM 2](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/finetune/sam2_segmenter.py): `apps/api/app/services/finetune/sam2_segmenter.py`

### Persistence

- [Blob storage](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/storage.py): `apps/api/app/services/storage.py`
- [Projects and sharing](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/store.py): `apps/api/app/services/store.py`

### Product features

- [Tools and grouping](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/api/routes/tools.py): `apps/api/app/api/routes/tools.py`
- [Export formats](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/services/export_service.py): `apps/api/app/services/export_service.py`
- [Templates and batches](https://github.com/theheavydriver/pixel2layer/blob/main/apps/api/app/api/routes/templates.py): `apps/api/app/api/routes/templates.py`

### Other components

- **User**

## Connections

- User → Upload flow: uploads artwork (evidence: `README.md`)
- Upload flow → API client: submits image
- API client → API application: calls API (evidence: `README.md`)
- API application → Upload validation: accepts uploads (evidence: `apps/api/app/main.py`)
- Upload validation → Blob storage: stores original (evidence: `apps/api/app/services/upload_service.py`)
- API application → Reconstruction jobs: starts queue (evidence: `apps/api/app/main.py`)
- Reconstruction jobs → Pipeline worker: dispatches work (evidence: `apps/api/app/main.py`)
- Pipeline worker → Blob storage: reads and writes (evidence: `apps/api/app/services/pipeline_worker.py`)
- Pipeline worker → Reconstruction pipeline: runs pipeline (evidence: `apps/api/app/services/pipeline_worker.py`)
- Reconstruction pipeline → Progressive routing: classifies complexity (evidence: `apps/api/app/services/pipeline.py`)
- Reconstruction pipeline → Text detection: detects text (evidence: `apps/api/app/services/pipeline.py`)
- Reconstruction pipeline → Font matching: matches fonts (evidence: `apps/api/app/services/pipeline.py`)
- Reconstruction pipeline → Shape detection: detects shapes (evidence: `apps/api/app/services/pipeline.py`)
- Reconstruction pipeline → Region segmentation: segments regions (evidence: `apps/api/app/services/pipeline.py`)
- Reconstruction pipeline → Vector paths: vectorizes artwork (evidence: `apps/api/app/services/pipeline.py`)
- Reconstruction pipeline → Scene graph builder: builds scene (evidence: `apps/api/app/services/pipeline.py`)
- Reconstruction pipeline → Blob storage: stores cutouts (evidence: `apps/api/app/services/pipeline.py`)
- Reconstruction pipeline → Scene graph models: produces model (evidence: `apps/api/app/services/pipeline.py`)
- Reconstruction pipeline → Optional SAM 2: may use backend (evidence: `README.md`)
- Pipeline worker → Reconstruction jobs: reports progress (evidence: `apps/api/app/services/pipeline_worker.py`)
- API application → Projects and sharing: initializes store (evidence: `apps/api/app/main.py`)
- API application → Stored asset delivery: registers route (evidence: `apps/api/app/main.py`)
- User → Layered editor: edits reconstruction (evidence: `README.md`)
- Layered editor → Canvas editor: renders layers
- Layered editor → Shared scene schema: uses scene schema (evidence: `apps/web/src/components/editor/editor-screen.tsx`)
- User → Tools and grouping: uses image tools (evidence: `README.md`)
- User → Export formats: exports artwork (evidence: `README.md`)
- User → Templates and batches: uses templates and batches (evidence: `README.md`)
- API application → Authentication: serves authentication
- User → Projects and sharing: saves and shares projects (evidence: `README.md`)
