# ytl001g/hanyeong-converter architecture

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

- Interactive diagram: https://gitdiagram.com/ytl001g/hanyeong-converter
- Repository: https://github.com/ytl001g/hanyeong-converter

## Overview

HanYeong is a Windows tray utility that corrects text typed with the wrong Korean/English keyboard layout. A user types in another app; the global hook and Controller track the input, then either convert the tracked segment on Ctrl+Space or ask the frequency-based detector whether to correct a completed word. The Controller replaces text through synthetic input, or reads and replaces a selected region. Tray and settings manage automatic mode and exceptions. The README documents further behaviors, including per-app rules and password-field protection; unsampled implementation details are not expanded beyond documented capabilities.

Main entry points: [`src/HanYeong/Controller.cs`](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Controller.cs) (Input controller), [`src/HanYeong/TrayContext.cs`](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/TrayContext.cs) (Tray controls), [`src/HanYeong/Native.cs`](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Native.cs) (Windows interop), [`src/HanYeong.Core/AutoDetector.cs`](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/AutoDetector.cs) (Auto detector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Tray application"]
  node_program["Program startup<br/>[Program.cs]"]
  node_tray["Tray controls<br/>[TrayContext.cs]"]
end

subgraph group_input["Input handling"]
  node_controller["Input controller<br/>[Controller.cs]"]
  node_hooks["Global hooks<br/>[GlobalHooks.cs]"]
  node_focus["Focus tracker<br/>[FocusTracker.cs]"]
  node_hotkey["Hotkey model<br/>[Hotkey.cs]"]
  node_selection["Selection reader<br/>[SelectionReader.cs]"]
  node_sender["Synthetic input<br/>[InputSender.cs]"]
  node_ime["IME control<br/>[Ime.cs]"]
  node_native["Windows interop<br/>[Native.cs]"]
end

subgraph group_conversion["Conversion engine"]
  node_segment["Typed segment<br/>[TypedSegment.cs]"]
  node_detector["Auto detector<br/>[AutoDetector.cs]"]
  node_frequency[("Word frequencies<br/>[WordFrequency.cs]")]
  node_converter["Layout converter<br/>[LayoutConverter.cs]"]
  node_composer["Hangul composer<br/>[HangulComposer.cs]"]
  node_decomposer["Hangul decomposer"]
  node_jamo["Jamo operations<br/>[Jamo.cs]"]
  node_common["Common syllables<br/>[CommonSyllables.cs]"]
  node_dubeolsik["Dubeolsik mapping<br/>[Dubeolsik.cs]"]
end

subgraph group_preferences["Preferences and diagnostics"]
  node_settingsform["Settings dialog<br/>[SettingsForm.cs]"]
  node_settings["User settings<br/>[Settings.cs]"]
  node_log["Diagnostic log<br/>[Log.cs]"]
end

node_user(("User"))
node_targetapp["Text app"]
node_windows["Windows"]

node_user -.->|"types text"| node_targetapp
node_program -->|"starts"| node_tray
node_tray -->|"creates"| node_controller
node_tray -->|"opens"| node_settingsform
node_tray -->|"updates"| node_settings
node_tray -->|"checks app"| node_focus
node_controller -->|"registers callbacks"| node_hooks
node_controller -->|"checks focus"| node_focus
node_controller -->|"reads rules"| node_settings
node_controller -->|"judges words"| node_detector
node_controller -->|"tracks typing"| node_segment
node_controller -->|"converts selection"| node_converter
node_controller -->|"reads selection"| node_selection
node_controller -->|"replaces text"| node_sender
node_controller -->|"checks layout"| node_ime
node_controller -->|"matches shortcuts"| node_hotkey
node_controller -->|"records events"| node_log
node_hooks -->|"installs hooks"| node_native
node_hooks -->|"filters injected keys"| node_sender
node_hooks -->|"records events"| node_log
node_focus -->|"queries windows"| node_native
node_focus -->|"checks focused control"| node_ime
node_selection -->|"queries focus"| node_native
node_selection -->|"requests copy"| node_sender
node_selection -->|"records failures"| node_log
node_sender -->|"sends keystrokes"| node_native
node_ime -->|"queries IME"| node_native
node_detector -->|"scores words"| node_frequency
node_detector -->|"tests conversions"| node_converter
node_detector -->|"checks Hangul"| node_jamo
node_detector -->|"checks common forms"| node_common
node_converter -->|"composes Korean"| node_composer
node_converter -->|"decomposes Korean"| node_decomposer
node_composer -->|"composes syllables"| node_jamo
node_composer -->|"maps keys"| node_dubeolsik
node_decomposer -->|"splits syllables"| node_jamo
node_decomposer -->|"maps keys"| node_dubeolsik
node_user -.->|"configures"| node_tray
node_native -->|"calls APIs"| node_windows
node_sender -.->|"types replacement"| node_targetapp

click node_program "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Program.cs"
click node_tray "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/TrayContext.cs"
click node_settingsform "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/SettingsForm.cs"
click node_settings "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Settings.cs"
click node_log "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Log.cs"
click node_controller "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Controller.cs"
click node_hooks "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/GlobalHooks.cs"
click node_focus "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/FocusTracker.cs"
click node_hotkey "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Hotkey.cs"
click node_selection "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/SelectionReader.cs"
click node_sender "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/InputSender.cs"
click node_ime "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Ime.cs"
click node_native "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Native.cs"
click node_segment "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/TypedSegment.cs"
click node_detector "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/AutoDetector.cs"
click node_frequency "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/WordFrequency.cs"
click node_converter "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/LayoutConverter.cs"
click node_composer "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/HangulComposer.cs"
click node_decomposer "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/HangulDecomposer.cs"
click node_jamo "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/Jamo.cs"
click node_common "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/CommonSyllables.cs"
click node_dubeolsik "https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/Dubeolsik.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_program,node_tray,node_user toneBlue
class node_controller,node_hooks,node_focus,node_hotkey,node_selection,node_sender,node_ime,node_native toneAmber
class node_segment,node_detector,node_frequency,node_converter,node_composer,node_decomposer,node_jamo,node_common,node_dubeolsik toneMint
class node_settingsform,node_settings,node_log toneRose
class node_targetapp,node_windows toneIndigo
```

## Components

### Tray application

- [Program startup](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Program.cs): `src/HanYeong/Program.cs`
- [Tray controls](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/TrayContext.cs): `src/HanYeong/TrayContext.cs`

### Input handling

- [Input controller](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Controller.cs): `src/HanYeong/Controller.cs`
- [Global hooks](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/GlobalHooks.cs): `src/HanYeong/GlobalHooks.cs`
- [Focus tracker](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/FocusTracker.cs): `src/HanYeong/FocusTracker.cs`
- [Hotkey model](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Hotkey.cs): `src/HanYeong/Hotkey.cs`
- [Selection reader](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/SelectionReader.cs): `src/HanYeong/SelectionReader.cs`
- [Synthetic input](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/InputSender.cs): `src/HanYeong/InputSender.cs`
- [IME control](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Ime.cs): `src/HanYeong/Ime.cs`
- [Windows interop](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Native.cs): `src/HanYeong/Native.cs`

### Conversion engine

- [Typed segment](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/TypedSegment.cs): `src/HanYeong.Core/TypedSegment.cs`
- [Auto detector](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/AutoDetector.cs): `src/HanYeong.Core/AutoDetector.cs`
- [Word frequencies](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/WordFrequency.cs): `src/HanYeong.Core/WordFrequency.cs`
- [Layout converter](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/LayoutConverter.cs): `src/HanYeong.Core/LayoutConverter.cs`
- [Hangul composer](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/HangulComposer.cs): `src/HanYeong.Core/HangulComposer.cs`
- [Hangul decomposer](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/HangulDecomposer.cs): `src/HanYeong.Core/HangulDecomposer.cs`
- [Jamo operations](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/Jamo.cs): `src/HanYeong.Core/Jamo.cs`
- [Common syllables](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/CommonSyllables.cs): `src/HanYeong.Core/CommonSyllables.cs`
- [Dubeolsik mapping](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong.Core/Dubeolsik.cs): `src/HanYeong.Core/Dubeolsik.cs`

### Preferences and diagnostics

- [Settings dialog](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/SettingsForm.cs): `src/HanYeong/SettingsForm.cs`
- [User settings](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Settings.cs): `src/HanYeong/Settings.cs`
- [Diagnostic log](https://github.com/ytl001g/hanyeong-converter/blob/main/src/HanYeong/Log.cs): `src/HanYeong/Log.cs`

### Other components

- **User**
- **Text app**
- **Windows**

## Connections

- User → Text app: types text (evidence: `README.md`)
- Program startup → Tray controls: starts (evidence: `src/HanYeong/Program.cs`)
- Tray controls → Input controller: creates (evidence: `src/HanYeong/TrayContext.cs`)
- Tray controls → Settings dialog: opens (evidence: `src/HanYeong/TrayContext.cs`)
- Tray controls → User settings: updates (evidence: `src/HanYeong/TrayContext.cs`)
- Tray controls → Focus tracker: checks app (evidence: `src/HanYeong/TrayContext.cs`)
- Input controller → Global hooks: registers callbacks (evidence: `src/HanYeong/Controller.cs`)
- Input controller → Focus tracker: checks focus (evidence: `src/HanYeong/Controller.cs`)
- Input controller → User settings: reads rules (evidence: `src/HanYeong/Controller.cs`)
- Input controller → Auto detector: judges words (evidence: `src/HanYeong/Controller.cs`)
- Input controller → Typed segment: tracks typing (evidence: `src/HanYeong/Controller.cs`)
- Input controller → Layout converter: converts selection (evidence: `src/HanYeong/Controller.cs`)
- Input controller → Selection reader: reads selection (evidence: `src/HanYeong/Controller.cs`)
- Input controller → Synthetic input: replaces text (evidence: `src/HanYeong/Controller.cs`)
- Input controller → IME control: checks layout (evidence: `src/HanYeong/Controller.cs`)
- Input controller → Hotkey model: matches shortcuts (evidence: `src/HanYeong/Controller.cs`)
- Input controller → Diagnostic log: records events (evidence: `src/HanYeong/Controller.cs`)
- Global hooks → Windows interop: installs hooks (evidence: `src/HanYeong/GlobalHooks.cs`)
- Global hooks → Synthetic input: filters injected keys (evidence: `src/HanYeong/GlobalHooks.cs`)
- Global hooks → Diagnostic log: records events (evidence: `src/HanYeong/GlobalHooks.cs`)
- Focus tracker → Windows interop: queries windows (evidence: `src/HanYeong/FocusTracker.cs`)
- Focus tracker → IME control: checks focused control (evidence: `src/HanYeong/FocusTracker.cs`)
- Selection reader → Windows interop: queries focus (evidence: `src/HanYeong/SelectionReader.cs`)
- Selection reader → Synthetic input: requests copy (evidence: `src/HanYeong/SelectionReader.cs`)
- Selection reader → Diagnostic log: records failures (evidence: `src/HanYeong/SelectionReader.cs`)
- Synthetic input → Windows interop: sends keystrokes (evidence: `src/HanYeong/InputSender.cs`)
- IME control → Windows interop: queries IME (evidence: `src/HanYeong/Ime.cs`)
- Auto detector → Word frequencies: scores words (evidence: `src/HanYeong.Core/AutoDetector.cs`)
- Auto detector → Layout converter: tests conversions (evidence: `src/HanYeong.Core/AutoDetector.cs`)
- Auto detector → Jamo operations: checks Hangul (evidence: `src/HanYeong.Core/AutoDetector.cs`)
- Auto detector → Common syllables: checks common forms (evidence: `src/HanYeong.Core/AutoDetector.cs`)
- Layout converter → Hangul composer: composes Korean (evidence: `src/HanYeong.Core/LayoutConverter.cs`)
- Layout converter → Hangul decomposer: decomposes Korean (evidence: `src/HanYeong.Core/LayoutConverter.cs`)
- Hangul composer → Jamo operations: composes syllables (evidence: `src/HanYeong.Core/HangulComposer.cs`)
- Hangul composer → Dubeolsik mapping: maps keys (evidence: `src/HanYeong.Core/HangulComposer.cs`)
- Hangul decomposer → Jamo operations: splits syllables (evidence: `src/HanYeong.Core/HangulDecomposer.cs`)
- Hangul decomposer → Dubeolsik mapping: maps keys (evidence: `src/HanYeong.Core/HangulDecomposer.cs`)
- User → Tray controls: configures (evidence: `README.md`)
- Windows interop → Windows: calls APIs (evidence: `src/HanYeong/Native.cs`)
- Synthetic input → Text app: types replacement
