# beac0n/ruroco architecture

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

- Interactive diagram: https://gitdiagram.com/beac0n/ruroco
- Repository: https://github.com/beac0n/ruroco

## Overview

##### Main Components

a) Client-side Components:
- CLI Client (`client`)
- GUI Client (`client_ui`)
- RSA Key Management System
- Configuration Management

b) Server-side Components:
- UDP Server (`server`)
- Command Executor (`commander`)
- Configuration System
- Security Components (Blocklist, Validation)

##### Architectural Layers

**1. Client Layer (Local Host)**
**2. Network Layer**
**3. Server Layer (Remote Host)**

##### Detailed Component Breakdown

Client Layer:
- UI Components
- CLI Interface
- Slint-based GUI (src/ui/*.slint)
- Client Core
- Command Encoder
- RSA Encryption
- Configuration Manager
- Key Management
- Private/Public Key Generation
- Key Storage

Server Layer:
- UDP Server
- Packet Receiver
- RSA Decryption
- Validation Logic
- Blocklist Management
- Commander Service
- Command Executor
- Permission Management
- Configuration Parser

##### Data Flow Representation

**1. Client → Server**
- Encrypted UDP packets
- Command data
- Timestamp
- IP information

**2. Server → Commander**
- Validated command names
- Execution context

##### Security Components Highlight

- RSA Encryption/Decryption
- Blocklist System (replay protection)
- IP Validation
- Minimal Rights Management
- Command Restriction System

##### Specific Implementation Details

Technical specifications:
- UDP Communication
- Systemd Integration
- Fail2ban Integration
- Configuration Format (TOML)

- Yellow highlights: Configuration elements

##### Component Relationships

Key relationships:
**Client ─(UDP)→ Server ─(Unix Socket)→ Commander**

- (Config)→ Local Config

**Server ←─────┘**

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef client fill:#b3d9ff,stroke:#333
    classDef server fill:#ffb3b3,stroke:#333
    classDef security fill:#98FB98,stroke:#333
    classDef config fill:#fff2b3,stroke:#333
    classDef ui fill:#e6ccff,stroke:#333
    classDef core fill:#ffd9b3,stroke:#333

    %% Legend
    subgraph Legend
        L1[Client Components]:::client
        L2[Server Components]:::server
        L3[Security Features]:::security
        L4[Configuration]:::config
        L5[UI Elements]:::ui
        L6[Core Components]:::core
    end

    %% Client Layer
    subgraph ClientLayer[Client Layer]
        UI[UI Components]:::ui
        click UI "https://github.com/beac0n/ruroco/tree/master/src/ui/"
        
        subgraph UIComponents
            CLI[CLI Client]:::ui
            click CLI "https://github.com/beac0n/ruroco/blob/master/src/bin/client.rs"
            GUI[GUI Client]:::ui
            click GUI "https://github.com/beac0n/ruroco/blob/master/src/bin/client_ui.rs"
            Dashboard["Dashboard UI"]:::ui
            click Dashboard "https://github.com/beac0n/ruroco/blob/master/src/ui/dashboard.slint"
            Execute["Execute UI"]:::ui
            click Execute "https://github.com/beac0n/ruroco/blob/master/src/ui/execute.slint"
            Create["Create UI"]:::ui
            click Create "https://github.com/beac0n/ruroco/blob/master/src/ui/create.slint"
            Bridge["UI-Backend Bridge"]:::ui
            click Bridge "https://github.com/beac0n/ruroco/blob/master/src/rust_slint_bridge.rs"
        end

        ClientCore[Client Core]:::core
        click ClientCore "https://github.com/beac0n/ruroco/blob/master/src/client.rs"
        
        subgraph ClientComponents
            CmdEncoder["Command Encoder"]:::core
            click CmdEncoder "https://github.com/beac0n/ruroco/blob/master/src/data.rs"
            RSAEnc["RSA Encryption"]:::security
            SavedCmds["Saved Commands"]:::core
            click SavedCmds "https://github.com/beac0n/ruroco/blob/master/src/saved_command_list.rs"
        end

        ClientConfig[Client Configuration]:::config
        click ClientConfig "https://github.com/beac0n/ruroco/blob/master/src/config_client.rs"
    end

    %% Server Layer
    subgraph ServerLayer[Server Layer]
        UDPServer[UDP Server]:::server
        click UDPServer "https://github.com/beac0n/ruroco/blob/master/src/bin/server.rs"
        
        subgraph ServerComponents
            ServerCore["Server Core"]:::core
            click ServerCore "https://github.com/beac0n/ruroco/blob/master/src/server.rs"
            RSADec["RSA Decryption"]:::security
            BlockList["Blocklist System"]:::security
            click BlockList "https://github.com/beac0n/ruroco/blob/master/src/blocklist.rs"
            Validator["Validation Logic"]:::security
        end

        ServerConfig[Server Configuration]:::config
        click ServerConfig "https://github.com/beac0n/ruroco/blob/master/src/config_server.rs"
        
        Commander[Commander Service]:::server
        click Commander "https://github.com/beac0n/ruroco/blob/master/src/bin/commander.rs"
        
        subgraph CommanderComponents
            CmdCore["Commander Core"]:::core
            click CmdCore "https://github.com/beac0n/ruroco/blob/master/src/commander.rs"
            PermMgmt["Permission Management"]:::security
            CmdExec["Command Executor"]:::core
        end

        SystemdServer["Server Service"]:::server
        click SystemdServer "https://github.com/beac0n/ruroco/blob/master/systemd/ruroco.service"
        SystemdCommander["Commander Service"]:::server
        click SystemdCommander "https://github.com/beac0n/ruroco/blob/master/systemd/ruroco-commander.service"
    end

    %% Connections
    UI --> ClientCore
    ClientCore --> CmdEncoder
    CmdEncoder --> RSAEnc
    ClientCore --> ClientConfig
    UDPServer --> ServerCore
    ServerCore --> RSADec
    ServerCore --> BlockList
    ServerCore --> Validator
    ServerCore --> ServerConfig
    ServerCore --> Commander
    Commander --> CmdCore
    CmdCore --> CmdExec
    CmdCore --> PermMgmt

    %% UDP Communication
    ClientCore ==>|"Encrypted UDP"| UDPServer

    %% Common Utilities
    CommonUtils["Common Utilities"]:::core
    click CommonUtils "https://github.com/beac0n/ruroco/blob/master/src/common.rs"
```
