# paraccoli/remote-desktop-rs architecture

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

- Interactive diagram: https://gitdiagram.com/paraccoli/remote-desktop-rs
- Repository: https://github.com/paraccoli/remote-desktop-rs

## Overview

##### Project Type and Purpose
- The application is a remote desktop system supporting Windows, macOS, and Linux. It features both a desktop client (with an egui/eframe-based UI) and a Web client (using Rust/Yew/WebAssembly) to connect to a central server.
- The README clearly describes functionalities such as screen sharing, remote input, file and clipboard sharing, image compression, multiple connection protocols (TCP, WebSocket, and WebRTC), and end-to-end encryption. This context is crucial in identifying each high-level component and their responsibilities.

##### File Structure
- Top-level directories include:
- common — contains shared modules for encryption, compression, protocol definitions, and various utilities.
- server — houses the server-side code with sub-modules for screen capture, input handling, network management (including authentication, session management, etc.), and a dedicated UI/tray for system-level controls.
- client — contains the desktop client code featuring modules for UI rendering (with controls, settings, window management), remote input, and network connectivity.
- web-client — handles the web client built on Yew/WebAssembly with its own structure for UI components, state management, network utilities, and static assets.
- Notice how the directory names (client, server, web-client) and their internal structures clearly separate concerns and functionalities, which is an important architectural characteristic.

##### Elements
- From the server to the clients representing screen sharing and status updates.
- From clients to the server representing input commands and control signals.
- Annotations or legends to explain protocols used (TCP, WebSocket, WebRTC) and any specific design patterns implemented.

##### Final Touches
- Component is detailed with its sub-modules where necessary (e.g., list “Screen Capture” sub-modules such as encoder and monitor under the server section).

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Common Library
    subgraph "Common Library"
        CL["Common Library (protocol, encryption, compression, utils)"]:::common
    end

    %% Server Component
    subgraph "Server"
        S1["Screen Capture (encoder, diff, monitor, screenshot)"]:::server
        S2["Input Handling (keyboard, mouse, system)"]:::server
        S3["Network Management (authentication, protocol, session, tcp_server, webrtc_server, websocket_server)"]:::server
        S4["UI/Tray (settings, tray)"]:::server
        S[("Server Core")]:::server
        S1 --> S
        S2 --> S
        S3 --> S
        S4 --> S
    end

    %% Desktop Client Component
    subgraph "Desktop Client"
        DC1["UI (controls, settings, window, styles)"]:::client
        DC2["Input (command, events, mapping)"]:::client
        DC3["Network (protocol, tcp_client, webrtc_client, websocket_client)"]:::client
        DC[("Desktop Core")]:::client
        DC1 --> DC
        DC2 --> DC
        DC3 --> DC
    end

    %% Web Client Component
    subgraph "Web Client"
        WC1["UI Components (connection, controls, display, settings, status)"]:::web
        WC2["State & Utilities (state, clipboard, network, storage, logging)"]:::web
        WC3["Static Assets (styles.css, index.html, webpack.config.js)"]:::web
        WC[("Web Core")]:::web
        WC1 --> WC
        WC2 --> WC
        WC3 --> WC
    end

    %% Inter-component Relationships
    CL -->|"shares"| S3
    CL -->|"shares"| DC3
    CL -->|"shares"| WC2

    DC -->|"input"| S3
    WC -->|"input"| S3
    S -->|"screenData"| DC
    S -->|"screenData"| WC

    %% Click Events for Component Mapping
    click CL "https://github.com/paraccoli/remote-desktop-rs/blob/main/common/src/protocol.rs"
    click CL "https://github.com/paraccoli/remote-desktop-rs/blob/main/common/src/encryption.rs"
    click CL "https://github.com/paraccoli/remote-desktop-rs/blob/main/common/src/compression.rs"
    click CL "https://github.com/paraccoli/remote-desktop-rs/tree/main/common/src/utils/"
    
    click S1 "https://github.com/paraccoli/remote-desktop-rs/tree/main/server/src/capture/"
    click S2 "https://github.com/paraccoli/remote-desktop-rs/tree/main/server/src/input/"
    click S3 "https://github.com/paraccoli/remote-desktop-rs/tree/main/server/src/network/"
    click S4 "https://github.com/paraccoli/remote-desktop-rs/tree/main/server/src/ui/"
    
    click DC1 "https://github.com/paraccoli/remote-desktop-rs/tree/main/client/src/ui/"
    click DC2 "https://github.com/paraccoli/remote-desktop-rs/tree/main/client/src/input/"
    click DC3 "https://github.com/paraccoli/remote-desktop-rs/tree/main/client/src/network/"
    
    click WC1 "https://github.com/paraccoli/remote-desktop-rs/tree/main/web-client/src/components/"
    click WC2 "https://github.com/paraccoli/remote-desktop-rs/blob/main/web-client/src/state.rs"
    click WC2 "https://github.com/paraccoli/remote-desktop-rs/tree/main/web-client/src/utils/"
    click WC3 "https://github.com/paraccoli/remote-desktop-rs/tree/main/web-client/static/"

    %% Styles
    classDef common fill:#a6d8f0,stroke:#000,stroke-width:2px;
    classDef server fill:#f5b7b1,stroke:#000,stroke-width:2px;
    classDef client fill:#abebc6,stroke:#000,stroke-width:2px;
    classDef web fill:#f9e79f,stroke:#000,stroke-width:2px;
```
