How lightningpixel/modly works
Purpose and Runtime Topology
Modly is a local, GPU-backed desktop application that converts images into 3D meshes using installable open-source model extensions. It combines an Electron desktop shell, React renderer, and Python/FastAPI compute backend; no cloud inference service is required. Primary desktop entry points are electron/main/index.ts, src/main.tsx, and api/main.py.
Desktop Shell and Native Boundary
Electron owns application lifecycle, persistent settings, OS integration, embedded-Python setup, backend process launching, downloads, updates, and artifact registration. Renderer access is mediated through the preload/IPC boundary rather than direct Node access. Key paths: electron/main/ipc-handlers.ts, electron/main/python-bridge.ts, electron/preload/electron-api.ts.
Renderer Application
The React/Vite UI routes among setup, generation, models/extensions, settings, and workflow editing. Shared stores coordinate application, agent, extension, navigation, and workflow state. The generation area presents image input, model/workflow controls, progress, asset library, and 3D/splat viewers. Key paths: src/App.tsx, src/shared/router/Router.tsx, src/areas/generate/GeneratePage.tsx.
API and Generation Orchestration
FastAPI exposes the backend contract consumed by Electron/renderer and automation clients. Routers separate generation, model management, extensions, optimization/export, settings/status, agent endpoints, and workflow-run lifecycle. Generator implementations are selected through a registry; the backend runner executes generation work. Key paths: api/main.py, api/routers/workflow_runs.py, api/services/generator_registry.py, api/runner.py.
Extension and Model Boundary
Models and processing capabilities are external extensions, generally acquired from GitHub and described by manifest.json. Electron performs installation/path validation and lifecycle work; Python launches or coordinates extension processes. This isolates arbitrary model runtime dependencies from the core application and allows model variants/downloads. Key paths: electron/main/extension-install-utils.ts, electron/main/extension-path-guard.ts, api/services/extension_process.py.
Workflow Execution and Mesh Processing
Users compose validated node graphs, then run them from the Generate page. Nodes cover inputs, image/text, extension execution, loops/waits, mesh loading, preview, and scene insertion; built-in processing extensions provide export, optimization, remeshing, repair, and smoothing. Invalid wiring is preflighted before execution and should preserve the current scene. Key paths: src/areas/workflows/WorkflowsPage.tsx, src/areas/workflows/preflight.ts, src/areas/workflows/workflowRunStore.ts, src/areas/workflows/nodes/mesh-optimizer/processor.ts.
Native Geometry Pipeline and Automation
The Python backend includes compiled native modules for UV unwrapping and texture baking, with C++ plus CUDA/Metal platform implementations—important GPU/platform boundaries. A stdlib-only CLI automates a running desktop app through canonical API concepts, especially workflow-run polling and final artifact export. Key paths: api/uv_unwrapper/uv_unwrapper/unwrap.py, api/texture_baker/texture_baker/baker.py, tools/modly-cli/agent.py.
Main entry points: runner.py Generation runner · main.py FastAPI service · index.ts Electron main · Router.tsx UI routes
Components 20
Desktop runtime
- Electron main · Owns lifecycle, native integration, backend launch, and artifacts.
electron/main/index.ts - IPC handlers
electron/main/ipc-handlers.ts - Preload API · Mediates renderer access to Electron capabilities.
electron/preload/electron-api.ts - Python bridge
electron/main/python-bridge.ts - Extension installer · Installs extensions and validates their paths.
electron/main/extension-install-utils.ts
Renderer UI
- React application
src/main.tsx - UI routes · Routes setup, generation, models, settings, and workflows.
src/shared/router/Router.tsx - Generate page · Collects inputs and presents progress, assets, and 3D viewers.
src/areas/generate/GeneratePage.tsx - Workflow editor
src/areas/workflows/WorkflowsPage.tsx - Workflow preflight · Rejects invalid wiring before execution.
src/areas/workflows/preflight.ts - Workflow run store
src/areas/workflows/workflowRunStore.ts
Python backend
- FastAPI service · Serves generation, models, extensions, settings, agent, and workflows.
api/main.py - Workflow-run API
api/routers/workflow_runs.py - Generator registry
api/services/generator_registry.py - Generation runner · Executes selected generation work.
api/runner.py - UV unwrapper · Uses compiled C++ and CUDA/Metal implementations.
api/uv_unwrapper/uv_unwrapper/unwrap.py - Texture baker · Uses compiled GPU/platform implementations.
api/texture_baker/texture_baker/baker.py
Extensions & processing
- Extension process manager · Launches or coordinates isolated model processes.
api/services/extension_process.py - Mesh optimizer processor · Provides optimization and related mesh operations.
src/areas/workflows/nodes/mesh-optimizer/processor.ts
Other components
- Modly CLI · Automates workflow runs, polling, and artifact export.
tools/modly-cli/agent.py
Connections 23
- Electron main → IPC handlers: registers
- Electron main → Python bridge: launches
- Electron main → Extension installer: manages
- React application → UI routes: renders
- UI routes → Generate page: routes to
- UI routes → Workflow editor: routes to
- Workflow editor → Workflow preflight: validates graph
- Workflow preflight → Workflow run store: permits run
- Generate page → Workflow run store: starts and observes
- React application → Preload API: uses
- Preload API → IPC handlers: invokes
- Python bridge → FastAPI service: starts
- IPC handlers → FastAPI service: proxies backend calls
- Workflow run store → Workflow-run API: creates and polls
- FastAPI service → Workflow-run API: mounts
- Workflow-run API → Generation runner: dispatches
- Generation runner → Generator registry: selects generator
- Generation runner → Extension process manager: coordinates models
- Extension installer → Extension process manager: installs runtimes for
- Generation runner → UV unwrapper: unwraps UVs
- Generation runner → Texture baker: bakes textures
- Workflow editor → Mesh optimizer processor: uses processing node
- Modly CLI → FastAPI service: automates canonical API