$ show Comfy-Org/ComfyUI
ComfyUI is a modular, node-based AI engine for content creation, primarily focused on generative image, video, audio, and 3D model inference. It provides a web server (aiohttp) with WebSocket and REST APIs, a visual workflow editor, and an extensible plugin system for custom nodes. The architecture is a monolith with a clear separation of concerns: core model loading and sampling (comfy/), execution engine (comfy_execution/), asset management (app/assets/), external API integrations (comfy_api_nodes/), and a public API for defining nodes (comfy_api/). It supports a vast range of open-source diffusion models (Flux, SD3, Wan, Hunyuan, etc.) and offers advanced features like dynamic VRAM management, quantization, multi-GPU support, and experimental guidance methods. The system operates as a local-first application but also integrates with cloud services via partner API nodes. Key entry points include main.py (startup), server.py (PromptServer), and execution.py (PromptExecutor). The codebase demonstrates high craftsmanship in its weight adapter hierarchy (LoRA, LoHa, OFT), patcher extension system for model hooks, and asset management services with database-backed metadata extraction and cursor-based pagination. However, it also contains experimental and deprecated nodes, some code duplication across model implementations, and a reliance on external dependencies that may drift over time.
The LLM identified 5 files worth highlighting for reuse:
Provides a generic wrapper/callback infrastructure (WrapperExecutor, CallbacksMP, WrappersMP) that allows custom nodes and extensions to inject behavior into model forward passes without modifying core code. This is a clean, reusable pattern for extensibility in any ML inference framework.
Defines the abstract base class for all weight adapters (LoRA, LoHa, OFT, etc.) with a bypass injection mechanism that works with quantized models. The design separates loading, calculation, and application of weight diffs, making it easy to add new adapter types. Highly reusable for any model patching system.
Implements core path resolution logic for asset management, including deriving tags from directory structure, detecting model folders, and computing response paths. This is a self-contained utility that could be extracted for any file-based asset cataloging system.
Defines an abstract CacheProvider interface with registration, key canonicalization, and serialization. Allows external caching backends (e.g., Redis) to be plugged in. The pattern is clean and reusable for any execution caching system.
Provides the IO.Schema system for declaratively defining node inputs and outputs with validation, tooltips, and dynamic options. This is the foundation of the ComfyUI node API and is designed for reuse by any node-based workflow engine.