# radicle-dev/radicle-desktop architecture

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

- Interactive diagram: https://gitdiagram.com/radicle-dev/radicle-desktop
- Repository: https://github.com/radicle-dev/radicle-desktop

## Overview

##### Project type and purpose
- Radicle Desktop is a “local-first” peer-to-peer code collaboration desktop application.
- It uses Tauri to wrap a Rust backend with a Svelte/TypeScript frontend.
- Key features: interact with the Radicle network, view/create issues, patches, diffs, threads, notifications.

##### Main components
a. Frontend (Renderer)
- Built with Svelte (src/, src/components/, src/views/, public/ assets)
- Bundled by Vite (vite.config.ts, package.json)
- Runs in a WebView window provided by Tauri
b. Tauri Host & IPC Layer
- Tauri’s Rust side (crates/radicle-tauri) exposing commands via `invoke`
c. Core Libraries
- crates/radicle-types: shared Rust and TypeScript type definitions and domain logic (cobs, diff, repo, thread, config, error, outbound/sqlite)
d. Backend & Persistence
- Native Rust code in crates/radicle-tauri
- commands.rs + individual command modules (auth, cob, diff, inbox, profile, repo, startup, thread)
- Outbound layer uses SQLite (crates/radicle-types/src/outbound/sqlite.rs)
- Build.rs and Cargo.toml define Rust dependencies
e. External Services
- Radicle P2P network (libp2p, gossip protocols)—invoked by Rust backend
- Local filesystem (for peer identity, project repos, bundling)
- Optionally test-server crate (crates/test-http-api) for unit/integration tests
f. Testing & CI
- Unit tests (tests/unit), E2E tests (tests/e2e with Playwright), scripts/*, .github/workflows, .woodpecker pipelines

##### Relationships and data flow
1. User interacts with UI (Svelte app).
2. UI calls Tauri’s `invoke` API (src/lib/invoke.ts).
3. Tauri host dispatches to Rust commands in crates/radicle-tauri.
4. Commands execute domain logic (via crates/radicle-types).
5. Domain logic may:
- Query/modify local SQLite storage
- To Radicle P2P network (publish/subscribe)
6. Results are serialized back to UI (via Tauri IPC).
7. UI updates state, re-renders views.

##### Architectural patterns and principles
- Layered architecture:
- Presentation (Svelte)
- IPC/Facade (Tauri commands)
- Domain (crate radicle-types)
- Persistence (SQLite)
- Network (Radicle P2P)
- Shared domain types (Rust ↔ TypeScript) to ensure type safety across layers.
- Single executable bundling both UI and backend.
- MVC/Component pattern in the Svelte frontend (views, components, router).

##### Technologies/Frameworks to annotate
- Frontend: Svelte, TypeScript, Vite
- Native: Rust, Tauri
- Persistence: SQLite (via rusqlite in radicle-types)
- Networking: libp2p (transitively via radicle code in radicle-types / radicle-tauri)
- Testing: Playwright (E2E), Jest or similar for unit tests, custom test HTTP API server

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Renderer)" 
        direction TB
        FE_SRC["src/"]:::frontend
        FE_App["App.svelte"]:::frontend
        FE_Components["src/components/"]:::frontend
        FE_Views["src/views/"]:::frontend
        FE_Public["public/"]:::frontend
        FE_Index["index.html"]:::frontend
        FE_Main["main.ts"]:::frontend
        VITE_Config["vite.config.ts"]:::frontend
        Pkg_JSON["package.json"]:::frontend
    end

    %% IPC Layer
    IPC["Invoke API<br/>(src/lib/invoke.ts)"]:::backend

    %% Tauri Host & Backend
    subgraph "Rust Backend (Tauri Host & Commands)"
        direction TB
        TAURI_Main["main.rs"]:::backend
        TAURI_Lib["lib.rs"]:::backend
        TAURI_Config["tauri.conf.json"]:::backend

        subgraph "Commands" 
            direction TB
            CMDs["commands.rs"]:::backend
            Auth["auth.rs"]:::backend
            Cob["cob.rs"]:::backend
            Issue["cob/issue.rs"]:::backend
            Patch["cob/patch.rs"]:::backend
            DiffCmd["diff.rs"]:::backend
            Inbox["inbox.rs"]:::backend
            Profile["profile.rs"]:::backend
            RepoCmd["repo.rs"]:::backend
            Startup["startup.rs"]:::backend
            Thread["thread.rs"]:::backend
        end
    end

    %% Shared Domain Types
    subgraph "Shared Types & Domain Logic" 
        direction TB
        Types_Cargo["Cargo.toml"]:::shared
        Types_Lib["lib.rs"]:::shared
        Types_Cobs["cobs.rs"]:::shared
        Types_Diff["diff.rs"]:::shared
        Types_Repo["repo.rs"]:::shared
        Types_Thread["thread.rs"]:::shared
        Types_Bindings["bindings/"]:::shared
    end

    %% Persistence Layer
    DB["SQLite<br/>(sqlite.rs)"]:::persistence

    %% Network Layer
    P2P["Radicle P2P Network"]:::network

    %% Tests
    subgraph "Testing & Test Server"
        direction TB
        Test_HTTP["test-http-api"]:::testing
        Unit_Tests["tests/unit/"]:::testing
        E2E_Tests["tests/e2e/"]:::testing
        Playwright["playwright.config.ts"]:::testing
    end

    %% CI & Scripts
    subgraph "CI & Automation"
        direction TB
        GH_Check[".github/workflows/check.yml"]:::ci
        GH_Unit[".github/workflows/check-unit-test.yml"]:::ci
        GH_E2E[".github/workflows/check-e2e.yml"]:::ci
        Wood_Build[".woodpecker/build.yaml"]:::ci
        Wood_Unit[".woodpecker/unit-test.yaml"]:::ci
        Scripts["scripts/"]:::ci
    end

    %% Connections
    FE_SRC --> FE_App
    FE_SRC --> FE_Components
    FE_SRC --> FE_Views
    FE_SRC --> FE_Main
    FE_App --> IPC
    VITE_Config --> FE_SRC
    Pkg_JSON --> FE_SRC

    IPC --> TAURI_Main
    TAURI_Main --> CMDs
    CMDs --> Auth
    CMDs --> Cob
    Cob --> Issue
    Cob --> Patch
    CMDs --> DiffCmd
    CMDs --> Inbox
    CMDs --> Profile
    CMDs --> RepoCmd
    CMDs --> Startup
    CMDs --> Thread

    CMDs --> Types_Lib
    Types_Lib --> Types_Cobs
    Types_Lib --> Types_Diff
    Types_Lib --> Types_Repo
    Types_Lib --> Types_Thread
    Types_Lib --> Types_Bindings

    Types_Lib --> DB
    Types_Lib --> P2P

    DB --> Types_Lib
    P2P --> Types_Lib
    Types_Lib --> CMDs
    CMDs --> IPC
    IPC --> FE_App

    %% Test & CI flows (sidecar)
    Test_HTTP --> CMDs
    Unit_Tests --> FE_SRC
    E2E_Tests --> FE_App
    Playwright --> E2E_Tests

    GH_Check --> Unit_Tests
    GH_Check --> E2E_Tests
    GH_Check --> CMDs
    GH_Unit --> Unit_Tests
    GH_E2E --> E2E_Tests
    Wood_Build --> GH_Check
    Wood_Unit --> GH_Unit
    Scripts --> GH_Check
    Scripts --> GH_Unit
    Scripts --> GH_E2E

    %% Click Events
    click FE_SRC "https://github.com/radicle-dev/radicle-desktop/tree/main/src/"
    click FE_App "https://github.com/radicle-dev/radicle-desktop/blob/main/src/App.svelte"
    click FE_Components "https://github.com/radicle-dev/radicle-desktop/tree/main/src/components/"
    click FE_Views "https://github.com/radicle-dev/radicle-desktop/tree/main/src/views/"
    click FE_Public "https://github.com/radicle-dev/radicle-desktop/tree/main/public/"
    click FE_Index "https://github.com/radicle-dev/radicle-desktop/blob/main/index.html"
    click FE_Main "https://github.com/radicle-dev/radicle-desktop/blob/main/src/main.ts"
    click VITE_Config "https://github.com/radicle-dev/radicle-desktop/blob/main/vite.config.ts"
    click Pkg_JSON "https://github.com/radicle-dev/radicle-desktop/blob/main/package.json"
    click IPC "https://github.com/radicle-dev/radicle-desktop/blob/main/src/lib/invoke.ts"
    click TAURI_Main "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/main.rs"
    click TAURI_Lib "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/lib.rs"
    click TAURI_Config "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/tauri.conf.json"
    click CMDs "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands.rs"
    click Auth "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands/auth.rs"
    click Cob "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands/cob.rs"
    click Issue "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands/cob/issue.rs"
    click Patch "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands/cob/patch.rs"
    click DiffCmd "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands/diff.rs"
    click Inbox "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands/inbox.rs"
    click Profile "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands/profile.rs"
    click RepoCmd "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands/repo.rs"
    click Startup "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands/startup.rs"
    click Thread "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-tauri/src/commands/thread.rs"
    click Types_Cargo "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-types/Cargo.toml"
    click Types_Lib "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-types/src/lib.rs"
    click Types_Cobs "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-types/src/cobs.rs"
    click Types_Diff "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-types/src/diff.rs"
    click Types_Repo "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-types/src/repo.rs"
    click Types_Thread "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-types/src/thread.rs"
    click Types_Bindings "https://github.com/radicle-dev/radicle-desktop/tree/main/crates/radicle-types/bindings/"
    click DB "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/radicle-types/src/outbound/sqlite.rs"
    click Test_HTTP "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/test-http-api/src/main.rs"
    click Test_HTTP "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/test-http-api/src/api.rs"
    click Test_HTTP "https://github.com/radicle-dev/radicle-desktop/blob/main/crates/test-http-api/Cargo.toml"
    click Unit_Tests "https://github.com/radicle-dev/radicle-desktop/tree/main/tests/unit/"
    click E2E_Tests "https://github.com/radicle-dev/radicle-desktop/tree/main/tests/e2e/"
    click Playwright "https://github.com/radicle-dev/radicle-desktop/blob/main/playwright.config.ts"
    click GH_Check "https://github.com/radicle-dev/radicle-desktop/blob/main/.github/workflows/check.yml"
    click GH_Unit "https://github.com/radicle-dev/radicle-desktop/blob/main/.github/workflows/check-unit-test.yml"
    click GH_E2E "https://github.com/radicle-dev/radicle-desktop/blob/main/.github/workflows/check-e2e.yml"
    click Wood_Build "https://github.com/radicle-dev/radicle-desktop/blob/main/.woodpecker/build.yaml"
    click Wood_Unit "https://github.com/radicle-dev/radicle-desktop/blob/main/.woodpecker/unit-test.yaml"
    click Scripts "https://github.com/radicle-dev/radicle-desktop/tree/main/scripts/"

    %% Styles
    classDef frontend fill:#B3D4FF,stroke:#333,stroke-width:1px
    classDef backend fill:#B3FFB3,stroke:#333,stroke-width:1px
    classDef shared fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef persistence fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef network fill:#E0FFFF,stroke:#333,stroke-width:1px
    classDef testing fill:#FFDAB9,stroke:#333,stroke-width:1px
    classDef ci fill:#FFE4B5,stroke:#333,stroke-width:1px
```
