# 0pandadev/qopy architecture

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

- Interactive diagram: https://gitdiagram.com/0pandadev/qopy
- Repository: https://github.com/0pandadev/qopy

## Overview

##### Main Components
- Backend (Tauri) Application: Found in the src-tauri folder, this Rust-based layer includes system-level APIs for clipboard handling, hotkeys, system tray support, and updater management. It also manages persistent data such as history and settings (see src-tauri/src/db with migrations and settings files).
- Database Module: Within the Tauri backend, the database module includes migration scripts and logic for storing clipboard history and user settings.
- Plugins and Utilities: Both in the frontend (plugins directory) and backend (src-tauri/src/utils), these modules contain helper functions, command utilities, key handling, logging, etc.
- Build and Deployment Artifacts: GitHub workflow files (build.yml, release.yml) and package/build scripts (bun commands, tauri.conf.json) that manage CI/CD and production building.

##### Relationships and Interactions
- User Interaction Flow: The frontend (Vue/Nuxt) receives user actions (e.g., copying text, interacting with settings), and these actions trigger API calls to the Tauri Rust backend.
- Tauri Bridge: Represent the Tauri communication layer that bridges the frontend JavaScript code with the native Rust backend—using Tauri’s invocation mechanism.
- Backend Processes: Within the Rust backend, separate modules handle API requests (clipboard, hotkeys, updater, tray) and interact with the database to fetch or store data.
- Data Persistence: The database component is responsible for maintaining clipboard history and settings. It interacts with migration scripts to update the schema as needed.
- External Integrations: Indicate integration points with operating system services (such as system notifications, clipboard handling, native keybindings) and third-party services (like the updater module for releases).

##### Architectural Patterns and Design Principles
- Cross-Platform Considerations: Since Qopy targets Windows, Linux, and macOS (as evident by the various installer assets in the README), mention that the design accounts for platform-specific integrations handled by Tauri.
- Configuration and CI/CD: Include ancillary components like GitHub workflows and build scripts that manage the project’s build and deployment pipeline.

##### Additional Recommendations
- Drill down by splitting the backend into its submodules (API modules, DB modules, utilities) and the frontend into its UI components and pages.
- Brief notes on how external services (such as system notifications, updates, or OS-level integrations) interact with these components.
- Do not forget to mark the flow from the build pipeline (.github workflows) to the deployment artifact generation (noting that production builds are generated in src-tauri/target/release/bundle).

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE_UI["Frontend (Vue/Nuxt) UI"]:::frontend
        FE_App["app.vue"]:::frontendFile
        FE_Components["Components (BottomBar, TopBar, Icons)"]:::frontendFile
        FE_Pages["Pages (index.vue, settings.vue)"]:::frontendFile
        FE_Config["nuxt.config.ts"]:::frontendFile
        FE_Plugins["Plugins (history.ts, settings.ts)"]:::frontendFile
    end

    %% Tauri Backend Layer
    subgraph "Tauri/Backend Layer"
        TB_Main["Tauri Backend"]:::backend
        TB_MainApp["Rust Main (src-tauri/src/main.rs)"]:::backendFile
        TB_Clipboard["Clipboard API Module"]:::backend
        TB_Hotkeys["Hotkeys Module"]:::backend
        TB_Tray["System Tray Module"]:::backend
        TB_Updater["Updater Module"]:::backend
        TB_Database["Database & Migrations"]:::backendDB
        TB_Utils["Backend Utilities"]:::backendUtil
    end

    %% Build/CI/CD Layer
    subgraph "Build/CI/CD"
        CI["Build & Deployment Artifacts"]:::config
        CI_Workflow["GitHub Workflows (.github/workflows)"]:::configFile
        CI_Scripts["GitHub Scripts (.github/scripts)"]:::configFile
        CI_TauriConf["tauri.conf.json"]:::configFile
    end

    %% Data Flow and Interactions
    FE_UI -->|"UserAction"| TB_Main
    FE_Plugins -->|"InvokeTauri"| TB_Main
    TB_Main -->|"APIcalls"| TB_Clipboard
    TB_Main --> TB_Hotkeys
    TB_Main --> TB_Tray
    TB_Main --> TB_Updater
    TB_Main --> TB_Utils
    TB_Main -->|"PersistData"| TB_Database
    CI -->|"TriggersBuild"| TB_Main

    %% Frontend internal connections
    FE_App --- FE_UI
    FE_Components --- FE_UI
    FE_Pages --- FE_UI
    FE_Config --- FE_UI
    FE_Plugins --- FE_UI

    %% Click Events for Frontend Components
    click FE_App "https://github.com/0pandadev/qopy/blob/main/app.vue"
    click FE_Components "https://github.com/0pandadev/qopy/blob/main/components/BottomBar.vue"
    click FE_Pages "https://github.com/0pandadev/qopy/blob/main/pages/index.vue"
    click FE_Plugins "https://github.com/0pandadev/qopy/blob/main/plugins/history.ts"
    
    %% Click Events for Backend Components
    click TB_MainApp "https://github.com/0pandadev/qopy/blob/main/src-tauri/src/main.rs"
    click TB_Database "https://github.com/0pandadev/qopy/tree/main/src-tauri/src/db"
    click TB_Utils "https://github.com/0pandadev/qopy/tree/main/src-tauri/src/utils"
    
    %% Click Events for Build/CI Components
    click CI_Workflow "https://github.com/0pandadev/qopy/tree/main/.github/workflows"
    click CI_Scripts "https://github.com/0pandadev/qopy/tree/main/.github/scripts"
    click CI_TauriConf "https://github.com/0pandadev/qopy/blob/main/src-tauri/tauri.conf.json"

    %% Style Definitions
    classDef frontend fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef frontendFile fill:#fce5cd,stroke:#333,stroke-width:2px;
    classDef backend fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef backendDB fill:#a9dfbf,stroke:#333,stroke-width:2px;
    classDef backendFile fill:#d6eaf8,stroke:#333,stroke-width:2px;
    classDef backendUtil fill:#d2b4de,stroke:#333,stroke-width:2px;
    classDef config fill:#f7dc6f,stroke:#333,stroke-width:2px;
    classDef configFile fill:#fad7a0,stroke:#333,stroke-width:2px;
```
