# aknobloch/qtplex architecture

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

- Interactive diagram: https://gitdiagram.com/aknobloch/qtplex
- Repository: https://github.com/aknobloch/qtplex

## Overview

##### Main Components

a. Application Layer:
- Qt Application Window (Main Container)
- QML Interface Layer
- Web Engine Component
- Key Event System
- Settings Management
- First-Time Setup Handler

b. External Systems:
- Plex Web Interface
- Plex Media Server
- System Media Keys

**[User Interface Layer]**
- ↕
**[Core Application Layer]**
- ↕
**[External Services Layer]**

##### Component Relationships

a. User Interface Flow:
- ApplicationWindow (Qt) → QML Interface
- QML Interface → PlexWebPage (QtWebEngine)
- Settings Dialog ↔ ApplicationWindow

b. Event Handling:
- KeyEventController → System Media Keys
- KeyEventController → JavaScript Execution Layer
- JavaScript Execution Layer → Plex Web Interface

c. Data Flow:
- PlexWebPage ↔ Plex Web Interface
- Plex Web Interface ↔ Plex Media Server

##### Specific Component Details

Key files/components with their relationships:
**application_window.h/cpp**
- ↓
**plex_web_page.h/cpp**
- ↓
**key_event_controller.h/cpp**
- ↓
**JavaScript Execution Files**
**(execute_play_pause.js, execute_forward.js, etc.)**

##### Important Elements to Highlight

a. Core Features:
- Media key integration system
- Web interface wrapper
- Settings management
- First-time setup workflow

b. External Dependencies:
- Qt Framework (especially QtWebEngine)
- System media key hooks (QHotkey)
- Plex web interface

##### Technical Details

- QtWebEngine container hosting the Plex web interface
- JavaScript bridge between native code and web interface
- Media key event flow from system to Plex controls
- Configuration/settings flow

##### Notes for Implementation

- Keep the web interface integration central to the design
- Event handling system for media keys
- Clear boundaries between native and web components
- Error handling and notification flows

Remember to include version information and any relevant build requirements in supplementary documentation, as these affect the system's deployment architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI
        AW[Application Window]
        QML[QML Interface]
        SD[Settings Dialog]
        FTS[First Time Setup]
    end

    subgraph Core
        WE[Web Engine Component]
        KE[Key Event Controller]
        JS[JavaScript Bridge]
        FL[File Loader]
        MSN[Media Status Notifications]
        CONST[Constants]
        CSS[CSS Styling]
    end

    subgraph External
        PWI[Plex Web Interface]
        PMS[Plex Media Server]
        SMK[System Media Keys]
        QHK[QHotkey]
    end

    subgraph "JavaScript Layer"
        PP[Play/Pause]
        FWD[Forward]
        PREV[Previous]
        STOP[Stop]
        COMMON[Common Library]
    end

    %% Relationships
    AW --> QML
    QML --> WE
    WE <--> PWI
    PWI <--> PMS
    KE --> SMK
    KE --> QHK
    KE --> JS
    JS --> PP & FWD & PREV & STOP
    PP & FWD & PREV & STOP --> COMMON
    JS --> PWI
    SD <--> AW
    FTS --> AW
    FL --> WE
    MSN --> AW
    CONST --> AW

    %% Styling
    classDef ui fill:#3498db
    classDef core fill:#2ecc71
    classDef external fill:#e74c3c
    classDef js fill:#9b59b6

    class AW,QML,SD,FTS ui
    class WE,KE,JS,FL,MSN,CONST,CSS core
    class PWI,PMS,SMK,QHK external
    class PP,FWD,PREV,STOP,COMMON js

    %% Click Events
    click AW "https://github.com/aknobloch/QtPlex/blob/master/include/application_window.h"
    click WE "https://github.com/aknobloch/QtPlex/blob/master/include/plex_web_page.h"
    click KE "https://github.com/aknobloch/QtPlex/blob/master/include/key_event_controller.h"
    click SD "https://github.com/aknobloch/QtPlex/blob/master/include/settings_dialog.h"
    click FTS "https://github.com/aknobloch/QtPlex/blob/master/include/first_time_setup_widget.h"
    click MSN "https://github.com/aknobloch/QtPlex/blob/master/include/media_status_notification.h"
    click FL "https://github.com/aknobloch/QtPlex/blob/master/include/file_loader.h"
    click CONST "https://github.com/aknobloch/QtPlex/blob/master/include/constants.h"
    click QML "https://github.com/aknobloch/QtPlex/blob/master/main.qml"
    click CSS "https://github.com/aknobloch/QtPlex/blob/master/src/css/titleBar.css"
    click QHK "https://github.com/aknobloch/QtPlex/tree/master/third_party/QHotkey"
    click PP "https://github.com/aknobloch/QtPlex/blob/master/src/js/execute_play_pause.js"
    click FWD "https://github.com/aknobloch/QtPlex/blob/master/src/js/execute_forward.js"
    click PREV "https://github.com/aknobloch/QtPlex/blob/master/src/js/execute_previous.js"
    click STOP "https://github.com/aknobloch/QtPlex/blob/master/src/js/execute_stop.js"
    click COMMON "https://github.com/aknobloch/QtPlex/blob/master/src/js/common_library.js"
    click JS "https://github.com/aknobloch/QtPlex/tree/master/src/js/"
```
