# liseami/deeprant architecture

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

## Overview

##### Main Components
- Frontend UI:
- Located in the “src” directory (with components, pages, assets, and styles).
- Built in React with Vite as the build tool.
- Handles user interactions, renders the game-friendly UI, and communicates with the Tauri backend.

- Backend (Tauri core):
- Found in “src-tauri”.
- Contains Rust code that sets up the application’s lifecycle, inter-process communication, and native functionalities (e.g., handling global shortcuts, clipboard operations, and system tray interactions).
- Uses Tauri configuration files, such as “tauri.conf.json” and “build.rs”, to manage the native side.

- Configuration & Build:
- Including Vite configurations (vite.config.js), PostCSS (postcss.config.js), Tailwind (tailwind.config.js), and package.json for JavaScript dependencies.
- Cargo.toml and Cargo.lock in the “src-tauri” directory capture Rust dependencies.

##### Out Component Interactions
- The frontend (React) is served via an HTML entry-point (index.html) and bundled using Vite.
- When users trigger an action (for example, using the “CMD + T” shortcut), the React application invokes specific Tauri APIs that bridge JavaScript and Rust.
- The Tauri backend receives these calls in its Rust code (main.rs, lib.rs, and related modules such as shortcut.rs, tray.rs, etc.) and coordinates native OS functionalities.
- Feedback (such as translation results) is then sent back from the backend to update the frontend UI.

- User input → Frontend UI event handlers
- Frontend → Tauri API calls (JS to Rust bridge)
- Tauri backend handling (global shortcut management, clipboard copy logic)
- Tauri → Frontend result propagation

##### Architectural Patterns and Technologies
- Separation of Concerns: Clear division between frontend business/UI logic and native/backend operations using the Tauri bridge.
- Integration Pattern: Hybrid architecture where React handles the UI layer while Rust handles native operations.
- Use of configuration-driven builds: Vite for modern JavaScript bundling, Cargo for Rust dependencies, and Tauri configuration files to set up cross-platform capabilities.
- Mention that the system also has a “lib” subdirectory (e.g., src/lib/supabase.js), indicating potential integration with external services for data or translation retrieval.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    U("User"):::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        RF["React Frontend"]:::frontend
        AC["App Component"]:::frontend
        ME["Main Entry"]:::frontend
        UP["UI Pages"]:::frontend
        UC["UI Components"]:::frontend
        UA["UI Assets"]:::frontend
        SI["Supabase Integration"]:::external
    end

    %% Bridge Layer
    subgraph "Bridge Layer"
        TB["Tauri API Bridge"]:::backend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        TBK["Tauri Backend (Rust)"]:::backend
        MR["Main (Rust)"]:::backend
        LR["Library (Rust)"]:::backend
        SH["Shell Helper (Rust)"]:::backend
        SM["Shortcut Manager (Rust)"]:::backend
        ST["System Tray (Rust)"]:::backend
    end

    %% Configuration & Build Tools
    subgraph "JS Configuration"
        VC["Vite Config"]:::config
        TC["Tailwind Config"]:::config
        PC["PostCSS Config"]:::config
        PF["Package File"]:::config
        PL["Package Lock"]:::config
    end

    subgraph "Rust/Tauri Configuration"
        TCJ["Tauri Config"]:::config
        CT["Cargo File"]:::config
        CL["Cargo Lock"]:::config
        BS["Build Script"]:::config
    end

    %% Flows
    U -->|"initiates"| RF
    RF -->|"triggers"| TB
    TB -->|"forwards commands"| TBK
    TBK -->|"routes to"| SM
    TBK -->|"routes to"| SH
    TBK -->|"routes to"| MR
    TBK -->|"routes to"| LR
    TBK -->|"routes to"| ST
    TBK ---|"returns results"| RF
    RF -->|"fetchTranslation"| SI
    SI ---|"provides data"| RF

    %% Styles
    classDef frontend fill:#FFDDCC,stroke:#BB5500,stroke-width:2px;
    classDef backend fill:#CCE5FF,stroke:#0066CC,stroke-width:2px;
    classDef config fill:#FFFFCC,stroke:#CCCC00,stroke-width:2px;
    classDef external fill:#CCFFCC,stroke:#009900,stroke-width:2px;

    %% Click Events for Frontend UI
    click RF "https://github.com/liseami/deeprant/tree/main/src/"
    click AC "https://github.com/liseami/deeprant/blob/main/src/App.jsx"
    click ME "https://github.com/liseami/deeprant/blob/main/src/main.jsx"
    click UP "https://github.com/liseami/deeprant/tree/main/src/pages"
    click UC "https://github.com/liseami/deeprant/tree/main/src/components"
    click UA "https://github.com/liseami/deeprant/tree/main/src/assets"

    %% Click Event for Supabase Integration
    click SI "https://github.com/liseami/deeprant/blob/main/src/lib/supabase.js"

    %% Click Events for Tauri Backend (Rust)
    click TBK "https://github.com/liseami/deeprant/tree/main/src-tauri/"
    click MR "https://github.com/liseami/deeprant/blob/main/src-tauri/src/main.rs"
    click LR "https://github.com/liseami/deeprant/blob/main/src-tauri/src/lib.rs"
    click SH "https://github.com/liseami/deeprant/blob/main/src-tauri/src/shell_helper.rs"
    click SM "https://github.com/liseami/deeprant/blob/main/src-tauri/src/shortcut.rs"
    click ST "https://github.com/liseami/deeprant/blob/main/src-tauri/src/tray.rs"

    %% Click Events for JS Configuration
    click VC "https://github.com/liseami/deeprant/blob/main/vite.config.js"
    click TC "https://github.com/liseami/deeprant/blob/main/tailwind.config.js"
    click PC "https://github.com/liseami/deeprant/blob/main/postcss.config.js"
    click PF "https://github.com/liseami/deeprant/blob/main/package.json"
    click PL "https://github.com/liseami/deeprant/blob/main/package-lock.json"

    %% Click Events for Rust/Tauri Configuration
    click TCJ "https://github.com/liseami/deeprant/blob/main/src-tauri/tauri.conf.json"
    click CT "https://github.com/liseami/deeprant/blob/main/src-tauri/Cargo.toml"
    click CL "https://github.com/liseami/deeprant/blob/main/src-tauri/Cargo.lock"
    click BS "https://github.com/liseami/deeprant/blob/main/src-tauri/build.rs"
```
