# crystian/comfyui-crystools architecture

> Architecture diagram of the GitHub repository crystian/comfyui-crystools, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/crystian/comfyui-crystools
- Repository: https://github.com/crystian/comfyui-crystools

## Overview

##### Main Components
- Backend (Python):
- “core”: Contains base functionality (configuration, logger, keys, common utilities, version handling).
- “nodes”: Implements the custom nodes that add new behaviors to ComfyUI (metadata extraction, JSON comparison, image preview, debugger nodes, pipe nodes, etc.).
- “general”: Implements system-level monitoring tools (hardware stats, GPU, HDD, etc.) used by the “resources monitor” and other UI nodes.
- “server”: Contains modules like server/monitor.py that likely facilitate or relay monitoring data to the UI.
- Additional support files like “requirements.txt”, “pyproject.toml” ensure dependencies and environment configuration.

- Frontend / Web (TypeScript/JavaScript):
- “web”: Contains the UI scripts, components, and type definitions that build the monitor, progress bar visualizations, debugging interfaces, and integration with ComfyUI’s overall UI. There are clearly defined files for each component (e.g., monitorUI, progressBar, debugger, etc.).

- Auxiliary Artifacts:
- “samples”: Provides JSON sample workflows demonstrating node usage.
- Configuration files (.eslintrc, tsconfig.json, package.json) which orient code-checking and building processes.
- GitHub configuration (.github folder) for CI/CD and publishing workflows.

##### Relationships and Data Flows
- The backend Python modules receive image and workflow data from ComfyUI and process metadata, system stats, or debugging information.
- Custom nodes (from “nodes”) interact with external libraries (psutil, torch, pynvml, DeepDiff) to compute differences between metadata or show system stats.
- The “server” module may expose endpoints or handle the routing of monitoring data for real-time updates.
- The frontend, defined in the “web” directory, receives processed data from the backend—using JSON payloads or other IPC mechanisms—and renders UI components (e.g., resource monitors, progress bars, image previews).
- The UI nodes (e.g., those for the debugger or metadata extraction) show how user actions in the ComfyUI interface trigger backend processing and then update the UI.

##### Architectural Patterns and Design Principles
- Modular design: Separate folders for “core”, “nodes”, “general”, and “server” promote separation of concerns (e.g., shared utilities vs. node-specific functionality).
- Integration: The design leverages both Python (for robust backend processing) and web technologies (for a responsive user interface) that together extend the original ComfyUI experience.

##### Relevant Technologies and Libraries
- Python Libraries: psutil, torch, pynvml, and DeepDiff are key components for system monitoring and metadata comparison; logging and configuration are handled in “core”.
- Web Technologies: TypeScript, JavaScript, and associated typings files in the “web” directory support UI functionality.
- Build/Configuration Tools: package.json, tsconfig.json, pyproject.toml, and ESLint hint at code quality, type-checking, and build processes.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Backend (Python)"
        A["Core Utilities"]:::backend
        B["Custom Nodes"]:::backend
        subgraph "Custom Nodes Pipeline"
            Pip1["Load Image with Metadata"]:::pipeline
            Pip2["Metadata Extractor"]:::pipeline
            Pip3["Debugger"]:::pipeline
            Pip4["Pipe Nodes"]:::pipeline
            Pip1 -->|"flow"| Pip2
            Pip2 -->|"flow"| Pip3
            Pip3 -->|"flow"| Pip4
        end
        C["System Monitoring Tools"]:::backend
        D["Server API"]:::backend
    end

    subgraph "Frontend"
        E["Frontend UI Components"]:::frontend
    end

    subgraph "Auxiliary & Configuration"
        Aux1["Requirements.txt"]:::auxiliary
        Aux2["pyproject.toml"]:::auxiliary
        Aux3["package.json"]:::auxiliary
        Aux4["tsconfig.json"]:::auxiliary
        Aux5["Documentation"]:::auxiliary
        Aux6["Samples"]:::auxiliary
    end

    %% Data flows in Backend
    A -->|"provides_utils"| B
    B -->|"processes_data"| D
    C -->|"sends_monitoring"| D

    %% Server API sends processed data to Frontend
    D -->|"serves_data"| E

    %% Integrate Custom Nodes Pipeline with Custom Nodes module
    B -->|"includes_pipeline"| Pip1

    %% UI triggers actions back to Custom Nodes
    E -->|"triggers_actions"| B

    %% Styles
    classDef backend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef frontend fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef auxiliary fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef pipeline fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;

click A "https://github.com/crystian/comfyui-crystools/tree/main/core"
click B "https://github.com/crystian/comfyui-crystools/tree/main/nodes"
click C "https://github.com/crystian/comfyui-crystools/tree/main/general"
click D "https://github.com/crystian/comfyui-crystools/blob/main/server/monitor.py"
click E "https://github.com/crystian/comfyui-crystools/tree/main/web"
click Aux1 "https://github.com/crystian/comfyui-crystools/blob/main/requirements.txt"
click Aux2 "https://github.com/crystian/comfyui-crystools/blob/main/pyproject.toml"
click Aux3 "https://github.com/crystian/comfyui-crystools/blob/main/package.json"
click Aux4 "https://github.com/crystian/comfyui-crystools/blob/main/tsconfig.json"
click Aux5 "https://github.com/crystian/comfyui-crystools/tree/main/docs"
click Aux6 "https://github.com/crystian/comfyui-crystools/tree/main/samples"
```
