# codefuse-ai/codefuse-ide architecture

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

- Interactive diagram: https://gitdiagram.com/codefuse-ai/codefuse-ide
- Repository: https://github.com/codefuse-ai/codefuse-ide

## Overview

##### Main components
- ● Electron Main Process: Represented by the code in directories like src/core/electron-main, src/bootstrap/electron-main, and parts of the auto-updater (src/auto-updater/electron-main). This is where the application’s lifecycle, window management, and native integrations are managed.
- ● Renderer or Browser Process: Shown in directories such as src/core/browser, src/bootstrap/browser, and the auto-updater’s update-window module. This is the UI layer that interacts with the end user.
- ● AI Modules: Code under src/ai (with subdirectories for browser and node) encapsulates the AI integration and services, which provide AI-enhanced development features and command handling.
- ● Auto-Updater Module: Found in src/auto-updater for both browser and electron-main implementations, managing update workflows, notification windows, and update services.
- ● Extension and Bootstrap Components: Directories like src/bootstrap-web, src/bootstrap, and src/core provide mechanisms for bootstrapping the IDE’s services, loading configurations, and integrating OpenSumi-based extensions.
- ● Build/Packaging Infrastructure: The build and webpack folders (including build/webpack-web) highlight the multi-target build configurations for both electron (desktop) and web versions.
- ● Utility and Support Services: Submodules under src/core/common, src/i18n, and src/logger provide logging, internationalization, and shared functionalities.

##### Relationships and interactions
- That the UI layer (Renderer Process) accesses core services such as AI modules (which include command management and prompt handling) and displays results from these services.
- That auto-updater components in both Electron and browser have bi-directional communication with the main process to coordinate update routines.
- Bootstrap modules as facilitators that initialize the various parts of the system (loading common modules, configuring extensions, and establishing communication channels between the Node and Browser contexts).

##### Architectural patterns and design principles
- Modularity: The code is split into clear modules for AI handling, auto-updating, bootstrapping, and core UI functionality. This not only encourages maintainability but also easy scalability (e.g., adding new extensions or AI capabilities).
- Separation of concerns: Notice the clear separation between Electron-specific main process logic and browser-based renderer logic, as well as distinct build pipelines (webpack configurations for different targets).
- Integration pattern: Integration with external tools (like VS Code extensions) and dependencies (electron-forge, OpenSumi) is managed through well-organized configuration files and modular services.

## Diagram (Mermaid)

```mermaid
graph TD

    %% Electron Desktop Subgraph
    subgraph "Electron Desktop"
        E_Main_Core["Electron Main: Core"]:::electron
        E_Main_Bootstrap["Electron Main: Bootstrap"]:::electron
        E_Main_Updater["Electron Main: Updater"]:::updater

        R_Core["Renderer: Core"]:::renderer
        R_Bootstrap["Renderer: Bootstrap"]:::renderer
        R_Updater["Renderer: Updater Window"]:::renderer

        %% Relationships within Electron Desktop
        E_Main_Core -->|"manages"| R_Core
        E_Main_Updater -->|"notifies"| R_Updater
        E_Main_Core -->|"triggers"| AutoUpdater_Core
    end

    %% Experimental Web Version Subgraph
    subgraph "Experimental Web Version"
        BE_Bootstrap["Bootstrap & Extension: Web"]:::bootstrap
        Browser_Process_Web["Browser Process (Web)"]:::web
        Build_Webpack_Web["Build: Webpack Web"]:::build

        %% Relationships within Web Version
        BE_Bootstrap -->|"bootstraps"| Browser_Process_Web
        Build_Webpack_Web -->|"bundles"| Browser_Process_Web
        Browser_Process_Web -->|"invokes"| AI_Core
    end

    %% Shared Modules Subgraph
    subgraph "Shared Modules"
        AI_Core["AI: Core Modules"]:::ai
        AI_Browser["AI: Browser"]:::ai
        AI_Node["AI: Node"]:::ai
        Boot_Ext_Core["Bootstrap & Extension: Core"]:::bootstrap
        Core_Ext["Core/Extension Integration"]:::bootstrap
        Build_Build["Build: Build"]:::build
        Build_Webpack["Build: Webpack"]:::build
        Util_Common["Utility: Common"]:::utility
        Util_i18n["Utility: i18n"]:::utility
        Util_Logger["Utility: Logger"]:::utility
        AutoUpdater_Core["Auto-Updater Core"]:::updater
    end

    %% Cross-Subgraph Relationships
    R_Core -->|"calls"| AI_Core
    R_Bootstrap -->|"initializes"| Boot_Ext_Core
    Boot_Ext_Core -->|"integrates"| E_Main_Bootstrap
    Core_Ext -->|"integrates"| E_Main_Core
    Core_Ext -->|"integrates"| Browser_Process_Web

    %% Click Events for Electron Main Process mapping
    click E_Main_Core "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/core/electron-main"
    click E_Main_Bootstrap "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/bootstrap/electron-main"
    click E_Main_Updater "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/auto-updater/electron-main"

    %% Click Events for Renderer Process mapping
    click R_Core "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/core/browser"
    click R_Bootstrap "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/bootstrap/browser"
    click R_Updater "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/auto-updater/update-window"

    %% Click Events for AI Modules mapping
    click AI_Core "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/ai"
    click AI_Browser "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/ai/browser"
    click AI_Node "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/ai/node"

    %% Click Event for Auto-Updater Module mapping
    click AutoUpdater_Core "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/auto-updater"

    %% Click Events for Extension and Bootstrap Components mapping
    click Boot_Ext_Core "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/bootstrap"
    click Core_Ext "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/core"
    click BE_Bootstrap "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/bootstrap-web"

    %% Click Events for Build/Packaging Infrastructure mapping
    click Build_Build "https://github.com/codefuse-ai/codefuse-ide/tree/main/build"
    click Build_Webpack "https://github.com/codefuse-ai/codefuse-ide/tree/main/build/webpack"
    click Build_Webpack_Web "https://github.com/codefuse-ai/codefuse-ide/tree/main/build/webpack-web"

    %% Click Events for Utility and Support Services mapping
    click Util_Common "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/core/common"
    click Util_i18n "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/i18n"
    click Util_Logger "https://github.com/codefuse-ai/codefuse-ide/tree/main/src/logger"

%% Styles
classDef electron fill:#F9E79F,stroke:#333,stroke-width:2px;
classDef renderer fill:#AED6F1,stroke:#333,stroke-width:2px;
classDef updater fill:#F5B7B1,stroke:#333,stroke-width:2px;
classDef ai fill:#A9DFBF,stroke:#333,stroke-width:2px;
classDef bootstrap fill:#D2B4DE,stroke:#333,stroke-width:2px;
classDef build fill:#FAD7A0,stroke:#333,stroke-width:2px;
classDef utility fill:#D5F5E3,stroke:#333,stroke-width:2px;
classDef web fill:#C39BD3,stroke:#333,stroke-width:2px;
```
