# nigh/i-wanna-clean-keyboard architecture

> Architecture diagram of the GitHub repository nigh/i-wanna-clean-keyboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nigh/i-wanna-clean-keyboard
- Repository: https://github.com/nigh/i-wanna-clean-keyboard

## Overview

##### Project type and purpose
- This is a small desktop utility written in AutoHotkey (AHK v2).
- Purpose: provide a simple GUI to block/unblock keyboard input when the user is eating, cleaning, or otherwise occupying the keyboard.

##### File structure
- Top-level files:
- main.ahk – the entry-point script with GUI and event handlers
- meta.ahk – metadata (version, author, build info)
- distribution.ahk – build/packaging script
- .gitmodules + ahk-compile-toolset/ – submodule for compiling AHK to an EXE
- html/index.html + web_gui/ – optional HTML-based GUI assets (if used)
- logo/ – image assets for branding
- Configuration & docs:
- README.md, LICENSE, .gitignore
- Build pipeline:
- distribution.ahk uses the ahk-compile-toolset submodule to produce a standalone executable.

##### README for additional insights
- Confirms use of AHK v2.0.4, Neutron.ahk for GDI+ graphics, and a dark UI style.
- Specifies user interactions: “Block” toggles keyboard hook, “Exit” unhooks and closes, title bar click & drag.

##### Components & interactions
a. Main components:
- AHK Runtime (engine provided by Windows)
- Script Modules:
– main.ahk (GUI + event loop)
– meta.ahk (build/config metadata)
- External Libraries:
– Neutron.ahk (GDI+ wrapper)
- UI Layer:
– Buttons (“Block”, “Exit”), draggable title
- System Hook:
– Windows keyboard hook to intercept/block input
- Assets:
– logo images, html GUI (if applicable)
- Packaging Pipeline:
– distribution.ahk + ahk-compile-toolset → EXE

b. Relationships & data flow:
1. User clicks GUI button → main.ahk event handler
2. Handler invokes keyboard hook APIs via Neutron.ahk
3. Keyboard events are either passed through or swallowed
4. UI is updated (button label toggles)
5. distribution.ahk reads meta.ahk & main.ahk → invokes compile toolset → outputs final binary

c. Architectural patterns & design principles:
- Event-driven GUI loop
- Modular scripts (separate build/config metadata)
- Clear separation: UI logic vs. packaging vs. assets

d. Key technologies & libraries:
- AutoHotkey v2
- Neutron.ahk (GDI+ library)
- ahk-compile-toolset (for bundling into EXE)

- Use clear labels: “AHK Engine,” “main.ahk,” “Neutron.ahk,” “Keyboard Hook”
- GUI events → Script Handlers
- Script Handlers → System Hook
- packaging script → compile toolset → output binary
- Green for external libraries
- Orange for system components (keyboard hook, OS APIs)
- Gray for assets (logo, HTML)

## Diagram (Mermaid)

```mermaid
graph TB
  %% Run-Time Environment
  subgraph "Run-Time Environment"
    Engine["AHK Engine"]:::system
  end

  %% Scripts
  subgraph "Scripts"
    Main["main.ahk"]:::script
    Meta["meta.ahk"]:::script
  end

  %% External Library
  subgraph "External Library"
    Neutron["Neutron.ahk"]:::lib
  end

  %% UI Components
  subgraph "UI Components"
    Buttons["Buttons: Block, Exit"]:::ui
    Title["Draggable Title Bar"]:::ui
  end

  %% System Hook
  Hook["Keyboard Hook (OS API)"]:::system

  %% Assets
  subgraph "Assets"
    Logo["logo/"]:::asset
    HTML["html/index.html"]:::asset
    WebGUI["web_gui/"]:::asset
    Readme["README.md"]:::asset
    License["LICENSE"]:::asset
    Gitmodules[".gitmodules"]:::asset
    Gitignore[".gitignore"]:::asset
  end

  %% Build Pipeline
  subgraph "Build Pipeline"
    Dist["distribution.ahk"]:::script
    Toolset["ahk-compile-toolset/"]:::lib
    EXE["Output: EXE"]:::system
  end

  %% Connections
  Buttons -->|click| Main
  Title -->|drag/click| Main
  Main -->|loads| Neutron
  Main -->|invokes| Hook
  Hook -->|intercepts| Engine
  Engine -->|runs| Main

  Dist -->|reads| Meta
  Dist -->|includes| Main
  Dist -->|uses| Toolset
  Toolset -->|produces| EXE

  Main -->|uses| Logo
  HTML -.->|optional GUI| Main
  WebGUI -.->|optional assets| Main

  %% Click Events
  click Main "https://github.com/nigh/i-wanna-clean-keyboard/blob/master/main.ahk"
  click Meta "https://github.com/nigh/i-wanna-clean-keyboard/blob/master/meta.ahk"
  click Dist "https://github.com/nigh/i-wanna-clean-keyboard/blob/master/distribution.ahk"
  click Toolset "https://github.com/nigh/i-wanna-clean-keyboard/tree/master/ahk-compile-toolset/"
  click HTML "https://github.com/nigh/i-wanna-clean-keyboard/blob/master/html/index.html"
  click WebGUI "https://github.com/nigh/i-wanna-clean-keyboard/tree/master/web_gui/"
  click Logo "https://github.com/nigh/i-wanna-clean-keyboard/tree/master/logo/"
  click Readme "https://github.com/nigh/i-wanna-clean-keyboard/blob/master/README.md"
  click License "https://github.com/nigh/i-wanna-clean-keyboard/tree/master/LICENSE"
  click Gitmodules "https://github.com/nigh/i-wanna-clean-keyboard/blob/master/.gitmodules"
  click Gitignore "https://github.com/nigh/i-wanna-clean-keyboard/blob/master/.gitignore"

  %% Styles
  classDef script fill:#D0E8FF,stroke:#0366d6,color:#0366d6
  classDef lib fill:#E2F0D9,stroke:#228B22,color:#228B22
  classDef system fill:#FFE5B4,stroke:#FF8C00,color:#FF8C00
  classDef asset fill:#F0F0F0,stroke:#CCCCCC,color:#333333
  classDef ui fill:#FFF0F5,stroke:#FF1493,color:#FF1493
```
