# ecopastehub/ecopaste architecture

> Architecture diagram of the GitHub repository ecopastehub/ecopaste, 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/ecopastehub/ecopaste
- Repository: https://github.com/ecopastehub/ecopaste

## Overview

Based on our analysis of the file tree and README, EcoPaste is an open‐source, cross-platform clipboard manager built using Tauri v2. It combines a modern web front-end (using TypeScript/React, as evidenced by the “src” folder with components, pages, hooks, etc.) with a robust Rust-based backend (located in the “src-tauri” folder). The application supports Windows, macOS, and Linux (x11) and leverages a plugin architecture (with modules such as clipboard, paste, window, ocr, and autostart) to handle different system integrations.

##### Main Components
- Tauri Backend: Highlight the “src-tauri” directory that contains the core Rust application, configuration files (tauri.conf.json and OS-specific configs), and integration code. This component orchestrates the overall application runtime, interacts with system-level features, and hosts the plugin system.
- Native Binaries: Note the presence of OS-specific binaries (in “src-tauri/bin”) used possibly for specialized tasks (for example, OCR support on different platforms).
- Local Data & Storage: Include the “src/database” area and related types which show local data storage ensuring user privacy and application state management.

##### Relationships and Interactions
- Interaction between the backend and the native binaries (for specialized functionality like OCR) by linking the “bin” folder components.
- Data flow between local storage (the database modules) and the UI for managing clipboard history and user settings.
- Build/deployment pipelines (using GitHub Actions and build scripts) as supporting infrastructure.

##### Architectural Patterns and Design Principles
- Separation of concerns: UI (frontend) versus system operations (backend).
- Modular plugin architecture that allows the addition of new commands or functionalities without altering the core system.
- That the system leverages cross-platform design, with OS-specific handling in the “setup” directories under src-tauri.
- Point out the hybrid nature of the project (Rust for performance-critical native operations and TypeScript/React for a rich, interactive UI) and how this separation ensures both efficiency and a smooth user experience.

##### Relevant Technologies
- Tauri v2 (for the native application container and Rust integration)
- React (or a similar framework as seen in the “src” directory) for the UI interface.
- Rust and Cargo for the backend implementation.
- Cross-platform build and deployment infrastructure (GitHub Actions workflows, shell scripts, and configuration files such as tauri.conf.json, .github workflows, etc.)
- Use of pnpm as a package manager as indicated by pnpm-lock.yaml.

##### Additional Details
- If space allows, highlight external integrations like the third-party libraries or native binaries that expose functionalities such as OCR.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        FE["React UI"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        TB["Tauri Core"]:::backend
        subgraph "Plugin Modules"
            CP["Clipboard Plugin"]:::plugin
            OP["OCR Plugin"]:::plugin
            PP["Paste Plugin"]:::plugin
            WP["Window Plugin"]:::plugin
            AP["Autostart Plugin"]:::plugin
        end
        NB["Native Binaries"]:::binary
        DB["Local Database"]:::database
    end

    %% Build/Deployment Pipeline
    subgraph "Build/Deployment"
        BD["Deployment Configs"]:::build
        BS["Build Scripts"]:::build
    end

    %% Connections
    FE -->|"TauriAPIcall"| TB
    TB -->|"commands"| CP
    TB -->|"commands"| OP
    TB -->|"commands"| PP
    TB -->|"commands"| WP
    TB -->|"commands"| AP
    TB -->|"executes"| NB
    TB -->|"data read/write"| DB
    FE <-->|"dataUpdates"| DB
    BD ---|"build/deploy"| TB
    BS ---|"build/deploy"| TB

    %% Click Events
    click FE "https://github.com/ecopastehub/ecopaste/tree/master/src"
    click TB "https://github.com/ecopastehub/ecopaste/tree/master/src-tauri"
    click CP "https://github.com/ecopastehub/ecopaste/tree/master/src-tauri/src/plugins/clipboard"
    click OP "https://github.com/ecopastehub/ecopaste/tree/master/src-tauri/src/plugins/ocr"
    click PP "https://github.com/ecopastehub/ecopaste/tree/master/src-tauri/src/plugins/paste"
    click WP "https://github.com/ecopastehub/ecopaste/tree/master/src-tauri/src/plugins/window"
    click AP "https://github.com/ecopastehub/ecopaste/tree/master/src-tauri/src/plugins/autostart"
    click NB "https://github.com/ecopastehub/ecopaste/tree/master/src-tauri/bin"
    click DB "https://github.com/ecopastehub/ecopaste/tree/master/src/database"
    click BD "https://github.com/ecopastehub/ecopaste/tree/master/.github/workflows"
    click BS "https://github.com/ecopastehub/ecopaste/tree/master/scripts"

    %% Styles
    classDef frontend fill:#ace,stroke:#333,stroke-width:2px;
    classDef backend fill:#cfa,stroke:#333,stroke-width:2px;
    classDef plugin fill:#ffc,stroke:#333,stroke-width:2px;
    classDef binary fill:#fdd,stroke:#333,stroke-width:2px;
    classDef database fill:#eef,stroke:#333,stroke-width:2px;
    classDef build fill:#dfd,stroke:#333,stroke-width:2px;
```
