# xpra-org/xpra architecture

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

- Interactive diagram: https://gitdiagram.com/xpra-org/xpra
- Repository: https://github.com/xpra-org/xpra

## Overview

##### Main Components Overview
The system should be divided into these major components:

a) Client Layer:
- Multiple client implementations (GTK3, Qt6, HTML5)
- Client mixins for features (audio, clipboard, display, etc.)
- Platform-specific adaptations (Windows, MacOS, Linux)

b) Network Layer:
- Protocol handlers (SSH, SSL, WebSocket, RFB)
- Compression and encoding systems
- Authentication modules
- Proxy server capabilities

c) Server Layer:
- Core X11 server integration
- Window management
- Desktop session handling
- Feature servers (audio, clipboard, etc.)

d) Codec/Media Layer:
- Video codecs (x264, vpx, nvenc)
- Image codecs (PIL, jpeg, webp)
- Audio codecs
- Hardware acceleration support

##### Component Relationships

**[Clients] → [Network Layer] → [Server Layer]**
- ↑                    ↑
- [Codec Layer]─────┘

##### Detailed Subsystems

For each major component, include these elements:

Client Layer:
- GUI frameworks (GTK3, Qt6)
- Window management
- Input handling
- Platform-specific features
- Client-side codecs

Network Layer:
- Protocol handlers
- Encryption
- Authentication
- Connection management
- Proxy services

Server Layer:
- X11 integration
- Window management
- Session management
- Feature coordination
- Resource management

Codec Layer:
- Video encoders/decoders
- Image processors
- Audio handlers
- Hardware accelerators

##### Connection Types

Use different line styles to represent:
- Double lines: Control flow

##### Key Features to Highlight

- Seamless window management
- Multi-protocol support
- Codec adaptation
- Platform-specific optimizations
- Authentication systems
- Hardware acceleration
- Audio/video synchronization

##### Specific Implementation Details

Implementation aspects:
- Python-based core
- Cython optimizations
- Native code integration
- Platform-specific adaptations
- Plugin architecture

##### Cross-cutting Concerns

How these aspects affect multiple components:
- Configuration management
- Logging and monitoring
- Security features
- Performance optimization
- Resource management

This design captures Xpra's nature as a sophisticated remote display system with multiple client options, extensive protocol support, and rich feature set, while showing how the components interact to provide seamless remote application and desktop access.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef client fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef network fill:#90EE90,stroke:#333,stroke-width:2px
    classDef server fill:#ffb3b3,stroke:#333,stroke-width:2px
    classDef codec fill:#ffff99,stroke:#333,stroke-width:2px
    classDef auth fill:#e6b3ff,stroke:#333,stroke-width:2px

    %% Client Layer
    subgraph ClientLayer
        GTK3["GTK3 Client"]:::client
        Qt6["Qt6 Client"]:::client
        ClientMixins["Client Mixins"]:::client
        PlatformSpecific["Platform Specific"]:::client
    end

    %% Network Layer
    subgraph NetworkLayer
        Protocol["Protocol Handlers"]:::network
        WebSocket["WebSocket"]:::network
        SSH["SSH Support"]:::network
        Auth["Authentication"]:::auth
        Proxy["Proxy Server"]:::network
        Compression["Compression"]:::network
    end

    %% Server Layer
    subgraph ServerLayer
        CoreServer["Core Server"]:::server
        X11["X11 Integration"]:::server
        WindowMgmt["Window Management"]:::server
        ServerMixins["Server Mixins"]:::server
        ShadowServer["Shadow Server"]:::server
    end

    %% Codec Layer
    subgraph CodecLayer
        VideoCodecs["Video Codecs"]:::codec
        ImageCodecs["Image Codecs"]:::codec
        Audio["Audio"]:::codec
        HWAccel["Hardware Acceleration"]:::codec
    end

    %% Relationships
    ClientLayer --> NetworkLayer
    NetworkLayer --> ServerLayer
    CodecLayer --> NetworkLayer
    CodecLayer --> ServerLayer

    %% Click Events
    click GTK3 "https://github.com/Xpra-org/xpra/tree/master/xpra/client/gtk3/"
    click Qt6 "https://github.com/Xpra-org/xpra/tree/master/xpra/client/qt6/"
    click ClientMixins "https://github.com/Xpra-org/xpra/tree/master/xpra/client/mixins/"
    click PlatformSpecific "https://github.com/Xpra-org/xpra/tree/master/xpra/platform/"
    click Protocol "https://github.com/Xpra-org/xpra/tree/master/xpra/net/protocol/"
    click WebSocket "https://github.com/Xpra-org/xpra/tree/master/xpra/net/websockets/"
    click SSH "https://github.com/Xpra-org/xpra/tree/master/xpra/net/ssh/"
    click Auth "https://github.com/Xpra-org/xpra/tree/master/xpra/auth/"
    click Proxy "https://github.com/Xpra-org/xpra/tree/master/xpra/server/proxy/"
    click Compression "https://github.com/Xpra-org/xpra/blob/master/xpra/net/compression.py"
    click CoreServer "https://github.com/Xpra-org/xpra/tree/master/xpra/server/"
    click X11 "https://github.com/Xpra-org/xpra/tree/master/xpra/x11/"
    click WindowMgmt "https://github.com/Xpra-org/xpra/tree/master/xpra/server/window/"
    click ServerMixins "https://github.com/Xpra-org/xpra/tree/master/xpra/server/mixins/"
    click ShadowServer "https://github.com/Xpra-org/xpra/tree/master/xpra/server/shadow/"
    click VideoCodecs "https://github.com/Xpra-org/xpra/tree/master/xpra/codecs/"
    click ImageCodecs "https://github.com/Xpra-org/xpra/tree/master/xpra/codecs/"
    click Audio "https://github.com/Xpra-org/xpra/tree/master/xpra/audio/"
    click HWAccel "https://github.com/Xpra-org/xpra/tree/master/xpra/codecs/nvidia/cuda/"

    %% Legend
    subgraph Legend
        Client["Client Components"]:::client
        Network["Network Components"]:::network
        Server["Server Components"]:::server
        Codec["Codec Components"]:::codec
        AuthComp["Authentication"]:::auth
    end
```
