# swartzmss/simplerustdesk architecture

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

- Interactive diagram: https://gitdiagram.com/swartzmss/simplerustdesk
- Repository: https://github.com/swartzmss/simplerustdesk

## Overview

Based on our analysis of the file tree and the README, the SimpleRustDesk project is a sample remote desktop control system. It implements a full remote control framework inspired by RustDesk’s design. The system is split between several applications that work together to allow a user (the control end) to remotely connect to and control another device (the controlled end).

##### Main Components
- IDServer (Signaling Server): This central server handles device registrations and status exchanges. It manages the “ID” registration of the controlled endpoints.
- DeskServer (Controlled End): This is the application on the controlled device. It registers its online status with the IDServer and checks the availability of the RelayServer.
- DeskControler (Control End): This client both initiates a connection (by manually inputting the target ID) and depends on the RelayServer to forward control commands.
- RelayServer (Relay/Intermediate Server): This component ensures that data (including video, mouse, keyboard, and files) is smoothly transmitted between the control end and the controlled end.
- RendezvousProto: This module likely defines the protocol (using protobuf) for the signaling, message exchanges, or session establishment.

##### Relationships and Interactions
- DeskServer registers with the IDServer to advertise its availability.
- DeskControler queries the IDServer (or inputs an ID manually) to initiate the connection.

##### Architectural Patterns and Design Principles
- The architecture follows a loosely-coupled, distributed design. Each module (signaling, control, and relay) is independently deployable.
- Separation of concerns is well defined: IDServer for session management and device registration, RelayServer for data forwarding, and the two client applications for remote control interactions.
- Use of a protocol buffer based messaging mechanism (with the RendezvousProto) supports scalable and language-independent communication.
- The UI pieces of the control and remote endpoints are built via Qt, as indicated by the VCXPROJ files and QtMsBuild scripts.

##### Relevant Technologies and Frameworks
- Qt: For user interface windows, dialogs, and event handling.
- ffmpeg: Likely used on the DeskServer side for screen capture or video decoding.
- Protobuf: For defining and serializing messages between the components.
- SQLite3: Possibly used on the IDServer to manage user registrations or device statuses.
- MSBuild/VCXPROJ: Build and deployment management for the C++ components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Server Components
    subgraph "Server Components"
        IDServer["IDServer (Signaling Server)"]:::server
        RelayServer["RelayServer (Relay/Intermediate Server)"]:::server
        RendezvousProto["RendezvousProto (Protocol Buffer Module)"]:::protocol
    end

    %% Client Components
    subgraph "Client Components"
        DeskControler["DeskControler (Control End)"]:::client
        DeskServer["DeskServer (Controlled End)"]:::client
    end

    %% External Dependencies
    subgraph "External Dependencies"
        Qt["Qt Library"]:::external
        ffmpeg["ffmpeg Library"]:::external
        protobuf["Protobuf Library"]:::external
        sqlite3["SQLite3 Database"]:::external
        MSBuild["MSBuild/VCXPROJ"]:::external
    end

    %% Connections between core components
    DeskServer -->|"register"| IDServer
    DeskControler -->|"queryID"| IDServer

    DeskControler -->|"control_messages,remote_input,video,file_data"| RelayServer
    RelayServer -->|"control_messages,remote_input,video,file_data"| DeskControler

    RelayServer -->|"control_messages,remote_input,video,file_data"| DeskServer
    DeskServer -->|"control_messages,remote_input,video,file_data"| RelayServer

    %% External dependencies interactions
    DeskControler -->|"uses_UI"| Qt
    DeskServer -->|"uses_UI"| Qt
    DeskServer -->|"video_decode"| ffmpeg
    RendezvousProto -->|"defines_protocol_with"| protobuf
    IDServer -->|"data_storage"| sqlite3

    DeskControler -->|"builds_with"| MSBuild
    DeskServer -->|"builds_with"| MSBuild
    IDServer -->|"builds_with"| MSBuild
    RelayServer -->|"builds_with"| MSBuild

    %% Click Events
    click IDServer "https://github.com/swartzmss/simplerustdesk/tree/main/IDServer/"
    click RelayServer "https://github.com/swartzmss/simplerustdesk/tree/main/RelayServer/"
    click DeskControler "https://github.com/swartzmss/simplerustdesk/tree/main/DeskControler/"
    click DeskServer "https://github.com/swartzmss/simplerustdesk/tree/main/DeskServer/"
    click RendezvousProto "https://github.com/swartzmss/simplerustdesk/tree/main/RendezvousProto/"

    %% Styles
    classDef server fill:#FFCCCC,stroke:#FF0000,stroke-width:2px,color:#000000;
    classDef client fill:#CCFFCC,stroke:#008000,stroke-width:2px,color:#000000;
    classDef protocol fill:#CCCCFF,stroke:#0000FF,stroke-width:2px,color:#000000;
    classDef external fill:#FFFFCC,stroke:#999900,stroke-width:2px,color:#000000;
```
