# rubickcenter/rubick architecture

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

- Interactive diagram: https://gitdiagram.com/rubickcenter/rubick
- Repository: https://github.com/rubickcenter/rubick

## Overview

##### Main Components
- UI/Renderer Layer:
– Found in directories like “src/renderer” and “guide/src/App.vue” or “feature/src/App.vue”.
– Built using Vue (as indicated by .vue files, shims for Vue/TS files, and related assets).
– It handles user interactions—search input, plugin market access, and launching system plugins.
- Main/Backend Process:
– Managed in “src/main” and “src/core”.
– Contains modules for system interactions such as “registerHotKey”, “tray”, “versionHandler”, “app-search” (with OS-specific search modules for Darwin, Linux, Windows) and “plugin-handler” that manages installation, loading, and integration of plugins.
- Core Modules:
– Under “src/core”, various submodules (e.g., “app-search”, “db”, “screen-capture”) encapsulate the key business logic.
– The “db” module may handle local data persistence and integration with external data sources like WebDAV.
- Plugin Infrastructure:
– Plugins are installed/uninstalled in a manner similar to npm packages (as described in the README).
– The system plugin mode, which makes plugins an integral part of Rubick, can be highlighted as a dynamic extension point.
– This is supported by both UI components (viewing in the plugin market) and backend/plugin-handler services.
- External Services & Integrations:
– WebDAV for multi-device data synchronization.
– OS-level integrations (launching local apps, file/folder search, system shortcuts).

##### Relationships and Interactions
- The Main Process forwards requests to Core modules (e.g., app-search, plugin-handler, db) and then returns data or results through the UI.
– For example: a search request travels from “src/renderer/search.vue” → “src/main/common” → “src/core/app-search” → back to UI.
- Plugin Manager:
– Illustrate the integration pathway between the UI’s plugin market and the plugin-handler module in the core.
– Show connections with the external npm registry (or its mirror) and local installation directories.
- Data Synchronization:
– The WebDAV module (in “src/core/db/webdav.ts”) handles the export/import process for settings and plugin data, communicating with remote endpoints.
- Multiple Build Variants:
– Folders like “detach”, “feature”, “guide”, and “tpl” suggest different deployment flavors or interface variations.

##### Architectural Patterns and Design Principles
- Modular Design:
- Separation of Concerns:
– Separate UI rendering from business logic (main process/core) and external synchronization.
- Extensibility/Plug-in Architecture:
– Emphasize the extension point for plugins, showing how they integrate into both the UI (via a dedicated plugin market view) and backend (via a plugin handler).
- Multi-environment Support:
– Some modules are designed to work across various operating systems (e.g., OS-specific search modules in core/app-search).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI/Renderer Layer"
        UI1["Primary Vue UI (App.vue)"]:::ui
        UI2["Guide Vue UI (App.vue)"]:::ui
        UI3["Feature Vue UI (App.vue)"]:::ui
        UI4["TPL Vue UI (App.vue)"]:::ui
        UI5["Detach Vue UI (App.vue)"]:::ui
        UPM["UI Plugin Manager"]:::ui
    end

    subgraph "Main Process"
        MP["Main Process (Electron/Node)"]:::backend
    end

    subgraph "Core Modules"
        AS["App Search Module\n(Darwin/Linux/Windows)"]:::core
        PH["Plugin Handler"]:::plugin
        DB["Database & WebDAV Module"]:::core
        SC["Screen Capture Module"]:::core
    end

    subgraph "External Services"
        WS["WebDAV Server"]:::external
    end

    %% UI Layer interactions
    UI1 -->|"sends_command"| MP
    UI2 -->|"sends_command"| MP
    UI3 -->|"sends_command"| MP
    UI4 -->|"sends_command"| MP
    UI5 -->|"sends_command"| MP
    UPM -->|"sends_plugin_cmd"| PH

    %% Main Process calls Core Modules
    MP -->|"calls_search"| AS
    MP -->|"calls_pluginhandler"| PH
    MP -->|"calls_db"| DB
    MP -->|"calls_screencap"| SC

    %% Core Modules return responses to Main
    AS -->|"returns_results"| MP
    PH -->|"returns_response"| MP
    DB -->|"syncs_data"| MP
    SC -->|"sends_capture"| MP

    %% Database sync with External WebDAV Service
    DB -->|"sync_with"| WS

    %% Click Events
    click UI1 "https://github.com/rubickcenter/rubick/blob/master/src/renderer/App.vue"
    click UI2 "https://github.com/rubickcenter/rubick/blob/master/guide/src/App.vue"
    click UI3 "https://github.com/rubickcenter/rubick/blob/master/feature/src/App.vue"
    click UI4 "https://github.com/rubickcenter/rubick/blob/master/tpl/src/App.vue"
    click UI5 "https://github.com/rubickcenter/rubick/blob/master/detach/src/App.vue"
    click UPM "https://github.com/rubickcenter/rubick/tree/master/src/renderer/plugins-manager"
    click MP "https://github.com/rubickcenter/rubick/tree/master/src/main"
    click AS "https://github.com/rubickcenter/rubick/tree/master/src/core/app-search"
    click DB "https://github.com/rubickcenter/rubick/blob/master/src/core/db/webdav.ts"
    click SC "https://github.com/rubickcenter/rubick/tree/master/src/core/screen-capture"
    click PH "https://github.com/rubickcenter/rubick/tree/master/src/core/plugin-handler"

    %% Styles
    classDef ui fill:#a8def0,stroke:#333,stroke-width:2px;
    classDef backend fill:#f0c68b,stroke:#333,stroke-width:2px;
    classDef core fill:#c0e1c2,stroke:#333,stroke-width:2px;
    classDef plugin fill:#e0aaff,stroke:#333,stroke-width:2px;
    classDef external fill:#fdd835,stroke:#333,stroke-width:2px;
```
