# tabris17/traymond architecture

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

- Interactive diagram: https://gitdiagram.com/tabris17/traymond
- Repository: https://github.com/tabris17/traymond

## Overview

##### Project type and purpose
- This is a native Windows desktop tool written in C++/Win32 (“Traymond”), whose purpose is to let users minimize arbitrary windows into the system tray, customize hotkeys and window-hiding rules, and run automatically on startup.

##### File structure
- Top-level:
- traymond.sln / .vcxproj – Visual Studio solution and project files
- src/ – all C++ source and resource files
- locale/ – language resource files for internationalization
- Makefile – build script
- LICENSE.md, CONTRIBUTING.md, README.md
- src/ breakdown:
- traymond.cpp/h – application entry point, WinMain, Tray API initialization
- options.cpp/h – Options dialog implementation and config persistence
- rules.cpp/h – Window‐hiding rule engine
- winevent.cpp/h – Windows event hooking (e.g. WM_HOTKEY, window messages)
- i18n.cpp/h – localization strings loader
- logging.h – logging utility macros
- resource.h, Traymond.rc – Win32 resource definitions (dialogs, menus)

##### README for additional insights
- Core features:
- Global hotkeys (minimize, restore last, show list)
- Rules‐based automatic hiding
- Options dialog for hotkeys, auto-run, rules
- Chinese UI, localization support

##### Main components
a. Components
1. Windows OS / Win32 API
2. Application Core (“Traymond”)
- Startup & Initialization
- Global Hotkey Manager
- Window Event Manager
- Rule Engine
- Options UI & Config Manager
- i18n / Localization Loader
- Logging Utility
b. Relationships & Interactions
- Hotkey Manager listens for WM_HOTKEY → dispatches to minimize/restore logic in Core → calls Win32 ShowWindow/SetWindowLong to hide/show target windows.
- Options UI writes updated hotkeys, auto-run flags, and rules to configuration storage (e.g., registry or file) → Core reloads on next start or on Apply.
- Rule Engine hooks into window creation events via Winevent module → automatically applies hide rules.
- i18n module loads string tables from locale/ at initialization → UI components fetch localized labels.
- Logging Utility writes debug/info messages to file or Output window.
c. Architectural patterns / design principles
- Modular layering: UI (Options Dialog) vs. core logic (Hotkey Manager, Rule Engine) vs. OS integration.
- Single responsibility: each src/*.cpp is a focused module.
- Event-driven architecture: relies on Win32 message loop and event callbacks.
- Resource-based configuration: uses .rc files for UI, images, and localization.
d. Technologies / frameworks
- C++ with Win32 API
- Visual Studio / MSBuild project files
- Windows Resource Compiler (.rc)
- Scoop installer support via JSON manifest

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        classDef ui fill:#9f6,stroke:#333,stroke-width:1px
        TrayIcon["Tray Icon Manager"]:::ui
        Options["Options UI & Config Manager"]:::ui
    end

    %% Core Logic Layer
    subgraph "Core Logic"
        classDef core fill:#6cf,stroke:#333,stroke-width:1px
        Init["Startup & Initialization"]:::core
        Hotkey["Global Hotkey Manager"]:::core
        EventMgr["Window Event Manager"]:::core
        RuleEngine["Rule Engine"]:::core
        I18n["i18n / Localization Loader"]:::core
        Logging["Logging Utility"]:::core
    end

    %% Storage
    subgraph "Configuration Storage"
        classDef storage fill:#fc9,stroke:#333,stroke-width:1px
        ConfigStore[(Config Storage)]:::storage
    end

    %% OS Boundary
    subgraph "Windows OS / Win32 API" 
        classDef external fill:#ddd,stroke:#333,stroke-width:1px
        Win32API["Win32 API"]:::external
        ShellNotify["Shell_NotifyIcon"]:::external
    end

    %% Interactions
    Init -->|"load config"| ConfigStore
    Init -->|"load i18n strings"| I18n
    Init -->|"initialize tray icon"| TrayIcon
    Init -->|"register hotkeys"| Hotkey
    ConfigStore -->|"provide settings"| Options
    Options -->|"save settings"| ConfigStore
    Options -->|"apply settings"| Init
    Hotkey -->|"RegisterHotKey()"| Win32API
    Win32API -->|"WM_HOTKEY event"| Hotkey
    Hotkey -->|"minimize/restore calls"| Win32API
    ShellNotify <-->|"Shell_NotifyIcon()"| TrayIcon
    TrayIcon -->|"open options"| Options
    Win32API -->|"window events"| EventMgr
    EventMgr -->|"trigger rules"| RuleEngine
    RuleEngine -->|"hide logic calls"| Win32API
    I18n -->|"provide strings"| TrayIcon
    I18n -->|"provide strings"| Options
    Logging -->|"log messages"| ConfigStore

    %% Click Events
    click Init "https://github.com/tabris17/traymond/blob/master/src/traymond.cpp"
    click Hotkey "https://github.com/tabris17/traymond/blob/master/src/winevent.cpp"
    click EventMgr "https://github.com/tabris17/traymond/blob/master/src/winevent.cpp"
    click TrayIcon "https://github.com/tabris17/traymond/blob/master/src/icons.cpp"
    click RuleEngine "https://github.com/tabris17/traymond/blob/master/src/rules.cpp"
    click Options "https://github.com/tabris17/traymond/blob/master/src/options.cpp"
    click I18n "https://github.com/tabris17/traymond/blob/master/src/i18n.cpp"
    click I18n "https://github.com/tabris17/traymond/tree/master/locale/"
    click Logging "https://github.com/tabris17/traymond/blob/master/src/logging.h"
    click ConfigStore "https://github.com/tabris17/traymond/blob/master/src/Traymond.rc"

    %% Styles
    class Init,Hotkey,EventMgr,RuleEngine,I18n,Logging core
    class TrayIcon,Options ui
    class ConfigStore storage
    class Win32API,ShellNotify external
```
