Repository navigation
Engine Service
nodemode-ai edited this page Nov 30, 2026
·
3 revisions
The Python engine does what a browser cannot: decode HEIC and TIFF, keep the project library on disk, import packages, remove backgrounds, and write exports for the desktop app. It binds to loopback only.
| Source path | What lives there |
|---|---|
backend/app/main.py |
App assembly, CORS, the static mount for the built frontend |
backend/app/core/config.py |
Ports, limits, data folders, .env loading |
backend/app/routers/system.py |
/api/health, /api/version, /api/capabilities
|
backend/app/routers/io.py |
/api/io/decode, /api/io/export
|
backend/app/routers/projects.py |
Library list, save, package, open, delete, import, session assets |
backend/app/routers/ops.py |
/api/ops/remove-background: returns the engine's raw subject mask; since 0.9.0 the frontend's Remove Background panel refines it (frontend/src/engine/matte.ts) and lays it down as a layer mask |
backend/app/routers/comfy_bridge.py, services/formbridge.py
|
/api/comfyui/bridge (not mounted with --no-comfy): GET /handshake, /workflows (each with ready), /workflows/{id}/readiness, /job/{job_id} (job and latest preview), /file?file_id=; POST /run (multipart, media slots as files; a video slot with several files is a frame sequence, a keyframes slot takes the frame numbers in the slots JSON plus one file each, multiples of 8 only; uploads and downloads stream from disk), /cancel/{job_id}. Each takes target, the ComfyUI address; reads need the window key like the other ComfyUI reads. The client speaks FormBridge contract 1 to the pack in ComfyUI (headers X-FormBridge-Contract and X-FormBridge-Client), follows ComfyUI's websocket for progress and previews with polling as the fallback, caches result files in <data>/formbridge, and turns failures into {detail: {message, code}} with code not_installed, not_ready, comfyui_too_old or unreachable
|
backend/app/services/project_format.py |
Manifest validation, zip and folder reading, zip writing |
backend/app/services/background.py |
rembg (ML) and OpenCV GrabCut (lightweight) |
backend/app/services/imaging.py, sessions.py
|
Decoding w/ Pillow and pillow-heif, opened-project sessions |
backend/formvis_engine.py |
Frozen sidecar entry, --selfcheck
|
- Validate every manifest against the limits before touching disk; reject what this build cannot read with a clear message.
- Write library files atomically (temporary file, then replace).
- Accept only safe asset names; never build paths from request text without validation.
- Never ship
pillow-heif's PyPI wheel (it links GPL x265): the frozen sidecar carries the decode-only build thatsetup/heif_decode.pymakes, andsetup/freeze_backendfails if x265 or x264 reaches it.