# hrishikesh-coder/bangla_keyboard architecture

> Architecture diagram of the GitHub repository hrishikesh-coder/bangla_keyboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hrishikesh-coder/bangla_keyboard
- Repository: https://github.com/hrishikesh-coder/bangla_keyboard

## Overview

Shobdomala is a Windows system-wide Bengali IME: a user types Roman keys in a focused application, the global hook captures them, and the active input mode produces Bengali text that is injected back into that application. Phonetic mode tokenizes and context-resolves candidates before Unicode composition; fixed-layout mode maps keys directly. The product also supports candidate selection, prediction/correction, macros, special characters, settings, and UI controls. Some subsystem links follow README documentation or declarations because their implementation excerpts were not sampled.

Main entry points: [`src/native/KeyboardHook.cpp`](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/native/KeyboardHook.cpp) (Keyboard hook), [`src/main.cpp`](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/main.cpp) (Application setup), [`src/core/PhoneticEngine.cpp`](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/PhoneticEngine.cpp) (Phonetic engine), [`src/core/CandidateResolver.cpp`](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/CandidateResolver.cpp) (Candidate resolver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Input capture"]
  node_hook["Keyboard hook<br/>[KeyboardHook.cpp]"]
  node_buffer["Roman input buffer<br/>[InputBuffer.cpp]"]
  node_state["Mode and shortcuts<br/>[KeyboardState.cpp]"]
end

subgraph group_engine["Transliteration engine"]
  node_phonetic["Phonetic engine<br/>[PhoneticEngine.cpp]"]
  node_tokenizer["Longest-match tokenizer<br/>[Tokenizer.cpp]"]
  node_context["Context analysis"]
  node_rules["Symbol rules<br/>[SymbolTable.cpp]"]
  node_exceptions["Word exceptions"]
  node_composer["Unicode composer"]
  node_fixed["Fixed layout"]
  node_picker["Special characters"]
end

subgraph group_assist["Typing assistance"]
  node_dictionary[("Word dictionary<br/>[WordDictionary.cpp]")]
  node_resolver["Candidate resolver"]
  node_policy["Suggestion policy"]
  node_ngram["N-gram model<br/>[NgramModel.cpp]"]
  node_userwords[("User dictionary<br/>[UserDictionary.cpp]")]
  node_macros["Macro engine<br/>[MacroEngine.cpp]"]
end

subgraph group_interface["User interface"]
  node_candidateui["Candidate window"]
  node_tray["Tray controls<br/>[TrayIcon.cpp]"]
  node_keyboardui["On-screen keyboard"]
  node_macrodialog["Macro dialog<br/>[MacroDialog.cpp]"]
end

subgraph group_platform["Windows integration"]
  node_main["Application setup<br/>[main.cpp]"]
  node_settings[("Settings<br/>[Settings.cpp]")]
  node_injector["Unicode injector<br/>[InputInjector.cpp]"]
end

node_user(("Typist"))
node_target["Focused app"]

node_user -->|"presses keys"| node_hook
node_hook -->|"buffers input"| node_buffer
node_hook -->|"checks mode"| node_state
node_hook -->|"requests composition"| node_phonetic
node_hook -->|"maps keys"| node_fixed
node_hook -->|"opens picker"| node_picker
node_phonetic -->|"tokenizes"| node_tokenizer
node_phonetic -->|"analyzes context"| node_context
node_phonetic -->|"looks up rules"| node_rules
node_phonetic -->|"checks overrides"| node_exceptions
node_phonetic -->|"composes text"| node_composer
node_main -->|"loads rules"| node_phonetic
node_main -->|"loads layout"| node_fixed
node_hook -->|"updates display"| node_candidateui
node_candidateui -->|"selects candidate"| node_hook
node_hook -->|"queries words"| node_dictionary
node_hook -->|"resolves candidates"| node_resolver
node_main -->|"configures resolver"| node_resolver
node_resolver -->|"looks up words"| node_dictionary
node_hook -->|"requests suggestions"| node_policy
node_policy -->|"scores context"| node_ngram
node_hook -->|"records corrections"| node_userwords
node_hook -->|"expands shortcut"| node_macros
node_main -->|"loads and saves"| node_settings
node_main -->|"installs hook"| node_hook
node_main -->|"initializes controls"| node_tray
node_main -->|"initializes keyboard"| node_keyboardui
node_main -->|"initializes dialog"| node_macrodialog
node_hook -->|"injects composed text"| node_injector
node_injector -->|"sends Unicode"| node_target
node_user -->|"types in"| node_target

click node_main "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/main.cpp"
click node_hook "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/native/KeyboardHook.cpp"
click node_buffer "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/InputBuffer.cpp"
click node_state "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/native/KeyboardState.cpp"
click node_phonetic "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/PhoneticEngine.cpp"
click node_tokenizer "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/Tokenizer.cpp"
click node_context "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/ContextAnalyzer.cpp"
click node_rules "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/SymbolTable.cpp"
click node_exceptions "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/ExceptionDictionary.cpp"
click node_composer "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/UnicodeComposer.cpp"
click node_fixed "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/FixedLayoutEngine.cpp"
click node_picker "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/SpecialCharPicker.cpp"
click node_dictionary "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/WordDictionary.cpp"
click node_resolver "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/CandidateResolver.cpp"
click node_policy "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/SuggestionPolicy.cpp"
click node_ngram "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/NgramModel.cpp"
click node_userwords "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/UserDictionary.cpp"
click node_macros "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/MacroEngine.cpp"
click node_candidateui "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/ui/CandidateWindow.cpp"
click node_tray "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/ui/TrayIcon.cpp"
click node_keyboardui "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/ui/OnScreenKeyboard.cpp"
click node_macrodialog "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/ui/MacroDialog.cpp"
click node_settings "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/native/Settings.cpp"
click node_injector "https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/native/InputInjector.cpp"

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_hook,node_buffer,node_state toneBlue
class node_phonetic,node_tokenizer,node_context,node_rules,node_exceptions,node_composer,node_fixed,node_picker toneAmber
class node_dictionary,node_resolver,node_policy,node_ngram,node_userwords,node_macros toneMint
class node_candidateui,node_tray,node_keyboardui,node_macrodialog toneRose
class node_main,node_settings,node_injector,node_user,node_target toneIndigo
```

## Components

### Input capture

- [Keyboard hook](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/native/KeyboardHook.cpp): `src/native/KeyboardHook.cpp`
- [Roman input buffer](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/InputBuffer.cpp): `src/core/InputBuffer.cpp`
- [Mode and shortcuts](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/native/KeyboardState.cpp): `src/native/KeyboardState.cpp`

### Transliteration engine

- [Phonetic engine](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/PhoneticEngine.cpp): `src/core/PhoneticEngine.cpp`
- [Longest-match tokenizer](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/Tokenizer.cpp): `src/core/Tokenizer.cpp`
- [Context analysis](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/ContextAnalyzer.cpp): `src/core/ContextAnalyzer.cpp`
- [Symbol rules](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/SymbolTable.cpp): `src/core/SymbolTable.cpp`
- [Word exceptions](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/ExceptionDictionary.cpp): `src/core/ExceptionDictionary.cpp`
- [Unicode composer](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/UnicodeComposer.cpp): `src/core/UnicodeComposer.cpp`
- [Fixed layout](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/FixedLayoutEngine.cpp): `src/core/FixedLayoutEngine.cpp`
- [Special characters](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/SpecialCharPicker.cpp): `src/core/SpecialCharPicker.cpp`

### Typing assistance

- [Word dictionary](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/WordDictionary.cpp): `src/core/WordDictionary.cpp`
- [Candidate resolver](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/CandidateResolver.cpp): `src/core/CandidateResolver.cpp`
- [Suggestion policy](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/SuggestionPolicy.cpp): `src/core/SuggestionPolicy.cpp`
- [N-gram model](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/NgramModel.cpp): `src/core/NgramModel.cpp`
- [User dictionary](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/UserDictionary.cpp): `src/core/UserDictionary.cpp`
- [Macro engine](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/core/MacroEngine.cpp): `src/core/MacroEngine.cpp`

### User interface

- [Candidate window](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/ui/CandidateWindow.cpp): `src/ui/CandidateWindow.cpp`
- [Tray controls](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/ui/TrayIcon.cpp): `src/ui/TrayIcon.cpp`
- [On-screen keyboard](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/ui/OnScreenKeyboard.cpp): `src/ui/OnScreenKeyboard.cpp`
- [Macro dialog](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/ui/MacroDialog.cpp): `src/ui/MacroDialog.cpp`

### Windows integration

- [Application setup](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/main.cpp): `src/main.cpp`
- [Settings](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/native/Settings.cpp): `src/native/Settings.cpp`
- [Unicode injector](https://github.com/hrishikesh-coder/bangla_keyboard/blob/main/src/native/InputInjector.cpp): `src/native/InputInjector.cpp`

### Other components

- **Typist**
- **Focused app**

## Connections

- Typist → Keyboard hook: presses keys
- Keyboard hook → Roman input buffer: buffers input
- Keyboard hook → Mode and shortcuts: checks mode
- Keyboard hook → Phonetic engine: requests composition
- Keyboard hook → Fixed layout: maps keys
- Keyboard hook → Special characters: opens picker
- Phonetic engine → Longest-match tokenizer: tokenizes
- Phonetic engine → Context analysis: analyzes context
- Phonetic engine → Symbol rules: looks up rules
- Phonetic engine → Word exceptions: checks overrides
- Phonetic engine → Unicode composer: composes text
- Application setup → Phonetic engine: loads rules
- Application setup → Fixed layout: loads layout
- Keyboard hook → Candidate window: updates display
- Candidate window → Keyboard hook: selects candidate
- Keyboard hook → Word dictionary: queries words
- Keyboard hook → Candidate resolver: resolves candidates
- Application setup → Candidate resolver: configures resolver
- Candidate resolver → Word dictionary: looks up words
- Keyboard hook → Suggestion policy: requests suggestions
- Suggestion policy → N-gram model: scores context
- Keyboard hook → User dictionary: records corrections
- Keyboard hook → Macro engine: expands shortcut
- Application setup → Settings: loads and saves
- Application setup → Keyboard hook: installs hook
- Application setup → Tray controls: initializes controls
- Application setup → On-screen keyboard: initializes keyboard
- Application setup → Macro dialog: initializes dialog
- Keyboard hook → Unicode injector: injects composed text
- Unicode injector → Focused app: sends Unicode
- Typist → Focused app: types in
