# jeffshee/hidamari architecture

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

- Interactive diagram: https://gitdiagram.com/jeffshee/hidamari
- Repository: https://github.com/jeffshee/hidamari

## Overview

##### Main Components
- User Interface (GUI) Component:
- Located in the src/gui directory. This is where control panels, widgets (for volume control, pause/play, “I’m feeling lucky,” etc.), and other UI-related functions reside.
- Video Playback Component (Player):
- Found in src/player with submodules like video_player.py and web_player.py.
- This module uses VLC (backed by libvlc and patched within the libvlc directory) and potentially other libraries for hardware-accelerated decoding.
- System Monitor / Manager:
- The src/monitor.py module likely implements detection of full-screen or maximized windows to pause the wallpaper video playback accordingly.
- Server/Communication Component:
- The src/server.py file suggests an internal API endpoint or communication layer for controlling or interfacing with other parts of the system.
- Core and Utility Modules:
- The remaining modules (src/commons.py, src/utils.py, src/yt_utils.py) serve as various support layers for common functionality, interaction with YouTube via yt-dlp, and other tasks.
- Configuration and Build Infrastructure:
- With several meson.build files, python3-requirements.json, requirements.txt, and patch files inside libvlc, the architecture also includes a robust build/deployment process.
- External Dependencies:
- VLC library is integrated (see libvlc and vlc-slim.json).
- yt-dlp and other external command-line utilities or libraries are used to source streaming content.

##### Relationships and Data Flow
- UI ↔ Video Playback: When a user interacts (e.g., pause/resume, volume control), the GUI passes commands to the Player module.
- Monitor Interaction: The Monitor module watches for system state changes (like a full-screen window) and sends signals to notify the Player/UI to pause/resume playback.
- Server and Remote Control: The Server component might relay API calls or communicate with background tasks, potentially interfacing with the Monitor and Player.
- Utility and Common Functions: Shared modules (commons.py, utils.py, yt_utils.py) are used by the GUI as well as the Player and Monitor modules to encapsulate non-specific business logic.
- External Services: VLC and yt-dlp are shown as external dependencies interacting with the Player for rendering video and streaming from URLs or web pages.

##### Architectural Patterns and Design Principles
- Modular Design: The separation of assets, core logic, GUI, and player functionalities points to a modularized architecture where each component has a distinct responsibility.
- Event-Driven/Observer Pattern: The use of a monitor for detecting state changes (e.g., full-screen mode) suggests an event-driven design to relay this information to other modules such as the Player.
- Integration with External Tools: The integration of VLC and yt-dlp illustrates dependency injection where external tools are “plugged into” the internal Python logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Internal Modules Subgraph
    subgraph "Internal Modules"
        UI["User Interface (GUI)"] 
        Player["Video Playback (Player)"]
        Monitor["System Monitor / Manager"]
        Server["Server/Communication"]
    end

    %% Core and Utility Modules Subgraph
    subgraph "Core and Utility Modules"
        Commons["Commons"]
        Utils["Utils"]
        YtUtils["yt_utils"]
    end

    %% Configuration and Build Infrastructure Subgraph
    subgraph "Configuration and Build Infrastructure"
        ProjMeson["Project meson.build"]
        SrcMeson["Src meson.build"]
        PythonReq["python3-requirements.json"]
        Req["requirements.txt"]
    end

    %% External Dependencies Subgraph
    subgraph "External Dependencies"
        VLC["VLC Integration"]
        YTDLP["yt-dlp"]
    end

    %% Internal Modules Relationships
    UI -->|"control"| Player
    Monitor -->|"pause/resume"| Player
    Monitor -->|"state_update"| UI
    Server -->|"API_commands"| Player
    Server -->|"status_queries"| Monitor

    %% Utilities used by Internal Modules
    UI -->|"uses"| Commons
    UI -->|"uses"| Utils
    UI -->|"uses"| YtUtils

    Player -->|"uses"| Commons
    Player -->|"uses"| Utils
    Player -->|"uses"| YtUtils

    Monitor -->|"uses"| Commons
    Monitor -->|"uses"| Utils
    Monitor -->|"uses"| YtUtils

    Server -->|"uses"| Commons
    Server -->|"uses"| Utils
    Server -->|"uses"| YtUtils

    %% External Dependencies integrated with Player
    Player -->|"video_rendering"| VLC
    Player -->|"streaming"| YTDLP

    %% Click Events
    click UI "https://github.com/jeffshee/hidamari/tree/master/src/gui"
    click Player "https://github.com/jeffshee/hidamari/tree/master/src/player"
    click Monitor "https://github.com/jeffshee/hidamari/blob/master/src/monitor.py"
    click Server "https://github.com/jeffshee/hidamari/blob/master/src/server.py"
    click Commons "https://github.com/jeffshee/hidamari/blob/master/src/commons.py"
    click Utils "https://github.com/jeffshee/hidamari/blob/master/src/utils.py"
    click YtUtils "https://github.com/jeffshee/hidamari/blob/master/src/yt_utils.py"
    click ProjMeson "https://github.com/jeffshee/hidamari/blob/master/meson.build"
    click SrcMeson "https://github.com/jeffshee/hidamari/blob/master/src/meson.build"
    click PythonReq "https://github.com/jeffshee/hidamari/blob/master/python3-requirements.json"
    click Req "https://github.com/jeffshee/hidamari/blob/master/requirements.txt"
    click VLC "https://github.com/jeffshee/hidamari/tree/master/libvlc"

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef utility fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef config fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:1px;

    class UI,Player,Monitor,Server internal;
    class Commons,Utils,YtUtils utility;
    class ProjMeson,SrcMeson,PythonReq,Req config;
    class VLC,YTDLP external;
```
