# hyprland-community/hyprland-rs architecture

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

- Interactive diagram: https://gitdiagram.com/hyprland-community/hyprland-rs
- Repository: https://github.com/hyprland-community/hyprland-rs

## Overview

##### Main Components Identification

a) Core Modules (Central Components):
- Data Module (src/data/)
- Event Listener Module (src/event_listener/)
- Dispatch Module (src/dispatch.rs)
- Keyword Module (src/keyword.rs)
- Config Module (src/config.rs)
- Control Module (src/ctl.rs)

b) External Components:
- Hyprland Compositor (External System)
- Client Applications (Users of the Library)

##### Component Relationships

**[Client Applications]**
- ↕
**[Hyprland-rs Library]**
- ↙  ↓  ↘  ↖  ↗  ↘
**[Core Modules Layer]**
- ↕
**[IPC Layer]**
- ↕
**[Hyprland Compositor]**

##### Detailed Component Breakdown

- Rectangles (Blue): Core modules
- Hexagons (Green): External systems
- Diamonds (Yellow): Interface layers

##### Module-Specific Details

For each core module, show:
- Data Module: Data retrieval and processing capabilities
- Event Listener: Event streaming and handling system
- Dispatch: Command dispatching functionality
- Keyword: Configuration option management
- Config: Binding configuration
- Control: Direct hyprctl command interface

##### Implementation Details

Important aspects:
- IPC communication channels
- Event streaming patterns
- Macro expansion points
- Error handling paths

##### System Interface Layer (Bottom)

Key Elements to Include:
- Clear module boundaries
- Bidirectional communication paths
- Async vs sync pathways
- Macro expansion points
- Error propagation routes
- Event streaming channels

Remember to:
- Keep the main components clearly separated
- Both sync and async paths
- Macro usage points
- Public interfaces
- Error handling flows
- Event propagation paths

- How the library interfaces with Hyprland
- The flow of data and commands
- Event handling mechanisms
- Configuration management
- The role of macros in the system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Application Layer"
        Client["Client Applications"]:::client
    end

    subgraph "API Interface Layer"
        HyprlandRS["Hyprland-rs Library"]:::library
        MacroSystem["Macro System"]:::macro
        click MacroSystem "https://github.com/hyprland-community/hyprland-rs/tree/master/hyprland-macros/"
    end

    subgraph "Core Modules Layer"
        DataMod["Data Module"]:::core
        click DataMod "https://github.com/hyprland-community/hyprland-rs/tree/master/src/data/"
        EventMod["Event Listener"]:::core
        click EventMod "https://github.com/hyprland-community/hyprland-rs/tree/master/src/event_listener/"
        DispatchMod["Dispatch Module"]:::core
        click DispatchMod "https://github.com/hyprland-community/hyprland-rs/blob/master/src/dispatch.rs"
        KeywordMod["Keyword Module"]:::core
        click KeywordMod "https://github.com/hyprland-community/hyprland-rs/blob/master/src/keyword.rs"
        ConfigMod["Config Module"]:::core
        click ConfigMod "https://github.com/hyprland-community/hyprland-rs/blob/master/src/config.rs"
        ControlMod["Control Module"]:::core
        click ControlMod "https://github.com/hyprland-community/hyprland-rs/blob/master/src/ctl.rs"
        SharedUtils["Shared Utilities"]:::core
        click SharedUtils "https://github.com/hyprland-community/hyprland-rs/blob/master/src/shared.rs"
    end

    subgraph "IPC Communication Layer"
        IPC["IPC Interface"]:::ipc
    end

    subgraph "System Interface Layer"
        Hyprland["Hyprland Compositor"]:::external
    end

    %% Connections
    Client <--> HyprlandRS
    HyprlandRS --> MacroSystem
    
    HyprlandRS --> DataMod
    HyprlandRS --> EventMod
    HyprlandRS --> DispatchMod
    HyprlandRS --> KeywordMod
    HyprlandRS --> ConfigMod
    HyprlandRS --> ControlMod
    
    DataMod --> SharedUtils
    EventMod --> SharedUtils
    DispatchMod --> SharedUtils
    KeywordMod --> SharedUtils
    ConfigMod --> SharedUtils
    ControlMod --> SharedUtils
    
    DataMod -.-> IPC
    EventMod -.-> IPC
    DispatchMod -.-> IPC
    KeywordMod -.-> IPC
    ConfigMod -.-> IPC
    ControlMod -.-> IPC
    
    IPC <--> Hyprland

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef library fill:#9cf,stroke:#333,stroke-width:2px
    classDef macro fill:#fc9,stroke:#333,stroke-width:2px
    classDef core fill:#9fc,stroke:#333,stroke-width:2px
    classDef ipc fill:#ff9,stroke:#333,stroke-width:2px
    classDef external fill:#ccc,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        Client1["Client"]:::client
        Library1["Library"]:::library
        Macro1["Macro"]:::macro
        Core1["Core Module"]:::core
        IPC1["IPC"]:::ipc
        External1["External"]:::external
    end
```
