# muescha/dot_hammerspoon architecture

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

- Interactive diagram: https://gitdiagram.com/muescha/dot_hammerspoon
- Repository: https://github.com/muescha/dot_hammerspoon

## Overview

##### Main Components

a. Core Components:
- Hammerspoon Runtime Environment
- Lua Script Engine
- System Integration Layer

b. Project Structure Components:
- Functions Module
- Helpers Module
- Spoons (Plugin System)
- Configuration Layer

**┌─────────────────────────────────────────────────────────┐**
- macOS System Layer                    │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Hammerspoon Runtime Engine                │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Core Components                      │
- ┬───────────────────┬───────────────────┤
- Window Manager│  Event Handlers   │  System Controls   │
- ┴───────────────────┴───────────────────┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Functional Modules                      │
- ┬──────────────┬──────────────┬──────────┤
- WindowPlacer  │AudioSwitcher │PlayerControl │  Others  │
- ┴──────────────┴──────────────┴──────────┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Helper Utilities                      │
- ┬──────────────┬──────────────┬──────────┤
- Debug Tools  │ Extensions   │ HotkeyBind   │ Utilities│
- ┴──────────────┴──────────────┴──────────┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Spoons (Plugins)                      │
- ┘

##### Component Relationships

- Data flow between components
- Dependencies between modules
- Event propagation paths
- System integration points

##### Documentation Elements

- Component types
- Major subsystems

##### Implementation Details

- The modular structure of Functions/
- The helper utility system in Helpers/
- The plugin architecture using Spoons/
- The configuration system (init.lua)

##### Key Features to Emphasize

- Window management system
- Media player controls
- Audio device switching
- Hotkey management
- Debug and development tools

- Nested components
- Clear connection lines
- Text annotations
- Export to common formats (PNG, SVG)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef system fill:#A9A9A9,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef function fill:#90EE90,stroke:#333,stroke-width:2px
    classDef helper fill:#FFD700,stroke:#333,stroke-width:2px
    classDef spoon fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% System Layer
    subgraph SYS["macOS System Layer"]
        MacOS["macOS System"]:::system
    end

    %% Runtime Layer
    subgraph RT["Hammerspoon Runtime"]
        HSRuntime["Hammerspoon Engine"]:::system
        LuaEngine["Lua Script Engine"]:::system
    end

    %% Core Components
    subgraph CORE["Core Components"]
        WinMgr["Window Manager"]:::core
        EventHandler["Event Handlers"]:::core
        SysCtrl["System Controls"]:::core
    end

    %% Functional Modules
    subgraph FUNC["Functional Modules"]
        WinPlace["WindowPlacer"]:::function
        AudioSwitch["AudioSwitcher"]:::function
        PlayerCtrl["PlayerControl"]:::function
        ChromeInt["Chrome Integration"]:::function
        SysMon["System Monitoring"]:::function
    end

    %% Helper Utilities
    subgraph HELP["Helper Utilities"]
        Debug["Debug Tools"]:::helper
        Ext["Extensions"]:::helper
        HotKey["Hotkey Management"]:::helper
        Util["Utilities"]:::helper
    end

    %% Spoons/Plugins
    subgraph SPOON["Spoons (Plugins)"]
        WinMgrSpoon["MiroWindowsManager"]:::spoon
        DevTools["EmmyLua"]:::spoon
    end

    %% Configuration
    Config["Configuration Layer"]:::system

    %% Relationships
    MacOS <--> HSRuntime
    HSRuntime <--> LuaEngine
    LuaEngine --> CORE
    CORE --> FUNC
    FUNC --> HELP
    HELP --> SPOON
    Config --> HSRuntime

    %% Click Events
    click WinMgr "https://github.com/muescha/dot_hammerspoon/blob/master/Functions/WindowManager.lua"
    click EventHandler "https://github.com/muescha/dot_hammerspoon/blob/master/Helpers/Extensions/WindowFilterEvents.lua"
    click WinPlace "https://github.com/muescha/dot_hammerspoon/blob/master/Functions/WindowPlacer.lua"
    click AudioSwitch "https://github.com/muescha/dot_hammerspoon/blob/master/Functions/AudioSwitcher.lua"
    click PlayerCtrl "https://github.com/muescha/dot_hammerspoon/blob/master/Functions/PlayerGlobalControl.lua"
    click Debug "https://github.com/muescha/dot_hammerspoon/blob/master/Helpers/Debug.lua"
    click Ext "https://github.com/muescha/dot_hammerspoon/tree/master/Helpers/Extensions/"
    click HotKey "https://github.com/muescha/dot_hammerspoon/blob/master/Helpers/HotkeyBindCycle.lua"
    click Util "https://github.com/muescha/dot_hammerspoon/blob/master/Helpers/Util.lua"
    click SPOON "https://github.com/muescha/dot_hammerspoon/tree/master/Spoons/"
    click WinMgrSpoon "https://github.com/muescha/dot_hammerspoon/tree/master/Spoons/MiroWindowsManager.spoon/"
    click Config "https://github.com/muescha/dot_hammerspoon/blob/master/init.lua"
    click ChromeInt "https://github.com/muescha/dot_hammerspoon/blob/master/Functions/ChromeTabAudioActivate.lua"
    click SysMon "https://github.com/muescha/dot_hammerspoon/blob/master/Functions/MemoryBar.lua"
    click DevTools "https://github.com/muescha/dot_hammerspoon/tree/master/Spoons/EmmyLua.spoon/"

    %% Legend
    subgraph Legend
        L1["System Components"]:::system
        L2["Core Components"]:::core
        L3["Function Modules"]:::function
        L4["Helper Utilities"]:::helper
        L5["Spoons/Plugins"]:::spoon
    end
```
