# zenai-vietnam/comfyui_infiniteyou architecture

> Architecture diagram of the GitHub repository zenai-vietnam/comfyui_infiniteyou, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zenai-vietnam/comfyui_infiniteyou
- Repository: https://github.com/zenai-vietnam/comfyui_infiniteyou

## Overview

##### Main Components
- Core Module: Represented by files like main.py, __init__.py, utils.py, and resampler.py. This component handles the primary logic for processing images and integrating the model.
- Workflows: The JSON files in the workflows directory (Ksampler.json, aes_stages2.json, face_combine.json, face_swap.json, sim_stage1.json) signify different processing pipelines for the tasks offered. These should be represented as individual workflow components or as a unified workflow engine within the module.
- Model Management: Components such as downloadmodel.py and the installation instructions (which include downloading ControlNet models, Image Projection files, InsightFace model) indicate a sub-system for model management and setup.
- CI/CD Pipeline: The .github directory (especially the publish workflow) represents automated workflows which might be included as part of the overall system lifecycle (build/deployment).

##### Relationships and Interactions
- Data Flow: Show how input images or commands flow from ComfyUI into this module. Then detail how the module uses the chosen workflow (e.g., face_swap, face_combine) to process data, which then may utilize models downloaded/managed by downloadmodel.py.
- Inter-component Communication: Emphasize the interaction between the core processing files (main.py, resampler.py, utils.py) and how they interface with the workflow JSON definitions.
- CI/CD and Deployment: Indicate the role of GitHub Actions (publish.yml) that manage building, testing, or deploying updates.

##### Architectural Patterns and Design Principles
- Extensibility: Since the extension is built to integrate into a larger system (ComfyUI) and supports multiple workflows, highlight the plug-in like architecture that allows new workflows or models to be easily added.
- Use of Standard Configurations: Note the role of standard configuration/build files (pyproject.toml, requirements.txt) that ensure consistency across different environments.

##### Following Elements
- Clear labels for each primary component (ComfyUI Interface, Core Module, Workflow Engine, Model Manager, External Dependencies, CI/CD Pipeline).

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Components
    UI["ComfyUI Host (ComfyUI)"]:::external
    CI["CI/CD Pipeline"]:::pipeline
    HF(["HuggingFace"]):::external
    IF(["InsightFace"]):::external
    CN(["ControlNet"]):::external

    subgraph "InfiniteYou Extension"
        CIInt["ComfyUI Integration (main.py, __init__.py)"]:::integration
        Core["Core Module (utils.py, resampler.py)"]:::core
        WL["Workflow Engine (workflows JSON)"]:::workflow
        MM["Model Manager (downloadmodel.py)"]:::model
    end

    %% Data Flows
    UI -->|"initiates"| CIInt
    CIInt -->|"delegates_to"| Core
    Core -->|"triggers_workflow"| WL
    Core -->|"invokes_model_manager"| MM
    MM -->|"fetches_from"| HF
    MM -->|"fetches_from"| IF
    MM -->|"fetches_from"| CN
    Core -->|"returns_result_to"| UI
    CI -->|"deploys_updates_to"| CIInt

    %% Click Events
    click CIInt "https://github.com/zenai-vietnam/comfyui_infiniteyou/blob/main/__init__.py"
    click CIInt "https://github.com/zenai-vietnam/comfyui_infiniteyou/blob/main/main.py"
    click Core "https://github.com/zenai-vietnam/comfyui_infiniteyou/blob/main/utils.py"
    click Core "https://github.com/zenai-vietnam/comfyui_infiniteyou/blob/main/resampler.py"
    click WL "https://github.com/zenai-vietnam/comfyui_infiniteyou/tree/main/workflows/"
    click MM "https://github.com/zenai-vietnam/comfyui_infiniteyou/blob/main/downloadmodel.py"
    click CI "https://github.com/zenai-vietnam/comfyui_infiniteyou/blob/main/.github/workflows/publish.yml"

    %% Styles
    classDef integration fill:#ADD8E6,stroke:#4682B4,stroke-width:2px;
    classDef core fill:#90EE90,stroke:#228B22,stroke-width:2px;
    classDef workflow fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef model fill:#FFEFD5,stroke:#CD853F,stroke-width:2px;
    classDef external fill:#FFC0CB,stroke:#FF69B4,stroke-width:2px,stroke-dasharray: 5, 5;
    classDef pipeline fill:#DDA0DD,stroke:#9932CC,stroke-width:2px;
```
