# mugli/avro-keyboard architecture

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

- Interactive diagram: https://gitdiagram.com/mugli/avro-keyboard
- Repository: https://github.com/mugli/avro-keyboard

## Overview

1. **Repository shape**
   - This is a Delphi-based Windows desktop product centered on **Avro Keyboard**, a Bangla IME (input method editor).
   - The repo is organized as a **multi-project suite**: the main keyboard app, a standalone spell checker, and three companion tools for layout editing, skin design, and Unicode-to-Bijoy conversion.

2. **Main runtime application**
   - The primary executable lives under **`Keyboard and Spell checker/Avro_Keyboard.*`**.
   - Its job is to run in the background, hook keyboard input, interpret keystrokes according to the selected Bangla typing mode, and emit the resulting text into the active Windows application.

3. **Input capture and text conversion pipeline**
   - The core data flow is: **Windows keyboard hook → key/code interpretation → layout or phonetic conversion → insertion into target window**.
   - Relevant units include **`KeyboardHook.pas`**, **`KeyboardFunctions.pas`**, **`VirtualKeyCode.pas`**, **`KeyboardLayoutLoader.pas`**, **`uRegExPhoneticSearch.pas`**, and **`uAutoCorrect.pas`**.
   - The app supports both **fixed keyboard layouts** and **phonetic typing**, which are handled by separate conversion and search utilities.

4. **Typing modes and conversion engines**
   - The product contains multiple conversion strategies:
     - **Phonetic Bangla typing** via regex-based phonetic builders/search.
     - **Fixed layout typing** via layout files loaded from `assets/keyboard-layouts`.
     - **Unicode/Bijoy-style transformations** via dedicated converter code.
   - Shared character tables and language-specific logic are in units such as **`BanglaChars.pas`**, **`Phonetic_RegExp_Constants.pas`**, and the conversion classes under `Classes/`.

5. **Persistent settings and installation model**
   - Configuration is stored through **registry/XML setting helpers** like **`uRegistrySettings.pas`** and **`clsRegistry_XMLSetting.pas`**.
   - The README’s `PortableOn` compiler define indicates two deployment modes:
     - **Standard install**: uses persistent system integration.
     - **Portable**: avoids machine-wide state where possible.
   - This distinction matters architecturally because several features depend on Windows registry and system integration.

6. **System integration boundary**
   - The main app includes code for **window/process handling**, **admin elevation**, and **font installation**.
   - Units such as **`uWindowHandlers.pas`**, **`uProcessHandler.pas`**, **`u_Admin.pas`**, and **`u_VirtualFontInstall.pas`** indicate tight integration with Windows desktop behavior and installed fonts.
   - This is not a browser-based or cross-platform app; it is a Windows-native IME with OS-level hooks.

7. **Spell checker as a separate executable**
   - The **`SpellChecker/`** folder is its own project with its own `dpr` and forms.
   - It has a separate runtime boundary from the keyboard app, but shares the same language domain and some registry/settings concepts.
   - Core responsibilities include **dictionary lookup**, **candidate generation**, and **popup/editor UI for spell correction**.

8. **Spell-checking data flow**
   - The spell checker uses a combination of:
     - **Dictionary storage and custom dictionaries**
     - **Phonetic matching**
     - **Edit-distance / similarity ranking**
   - Important units include **`uCustomDictionary.pas`**, **`uDBase.pas`**, **`uSpellEditDistanceSearch.pas`**, **`uRegExPhoneticSearch_Spell.pas`**, **`clsSpellPhoneticSuggestionBuilder.pas`**, **`uSimilarSort_Spell.pas`**, and **`Levenshtein.pas`**.
   - The included **`assets/Database.db3`** and **`assets/autodict.dct`** suggest packaged dictionary data and auto-dictionary behavior.

9. **UI layer of the main application**
   - The main app’s user-facing pieces are mostly Delphi forms under **`Forms/`**.
   - These cover settings and auxiliary dialogs such as:
     - **options/configuration**
     - **auto-correct**
     - **macro/shortcut editing**
     - **update notifications**
     - **layout preview/viewer**
     - **conflict and encoding warnings**
     - **about/splash/top bar**
   - The UI is a control layer over the typing engine rather than the primary business logic.

10. **Layout system and assets**
   - Keyboard layouts are not hardcoded only; they are represented as external assets in **`assets/keyboard-layouts/*.avrolayout`**.
   - The main app includes layout management and conversion helpers such as **`clsGenericLayoutModern.pas`**, **`clsGenericLayoutOld.pas`**, **`clsLayout.pas`**, and **`clsSkinLayoutConverter.pas`**.
   - This makes layout definitions a first-class content boundary separate from the executable code.

11. **Skinning and visual customization**
   - The app supports customizable skins from **`assets/skins/*.avroskin`**.
   - Rendering and theme support are handled by loaders and converters such as **`SkinLoader.pas`**, **`WindowsDarkMode.pas`**, and skin-related forms/classes.
   - The **Skin Designer** project is a separate tool for authoring these skin assets, indicating a clean separation between runtime UI and skin asset creation.

12. **Companion editors/tools**
   - **Layout Editor** is a separate project for editing keyboard layout files and likely validates/converts layout definitions.
   - **Skin Designer** builds and previews skin packages.
   - **Unicode to ascii converter** is another utility project focused on converting Unicode Bangla text to Bijoy/ASCII-style output.
   - These tools operate on the same domain assets but are distinct executables, which is important for an architecture diagram.

13. **Shared classes and reusable domain logic**
   - The `Classes/` and `Units/` folders in the main app hold the reusable implementation behind the forms.
   - They include phonetic builders, abbreviation handling, file/version helpers, image handlers, command-line helpers, and update download logic.
   - The overall architecture is “**thin UI, rich shared domain logic, multiple small executables**” rather than a monolithic single-form app.

14. **Packaging and documentation assets**
   - The `assets/docs`, `assets/fonts`, `assets/images`, `assets/icons`, and `assets/database` folders show that the product ships with bundled help content, images, fonts, and data.
   - Those assets are consumed at runtime by the main app and companion editors, and they also form part of the installer/runtime packaging boundary.

15. **Build and project organization**
   - The repo is a Delphi **project group** (`WholeProject.groupproj`) with multiple `.dpr/.dproj` targets.
   - `ProjectDefines.inc` controls build-time behavior such as portable mode and debug logging.
   - From an architecture perspective, build-time defines materially affect runtime integration, persistence, and diagnostics.

Main entry points: [`Keyboard and Spell checker/Avro_Keyboard.dpr`](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Avro_Keyboard.dpr) (Keyboard app), [`WholeProject.groupproj`](https://github.com/mugli/avro-keyboard/blob/master/WholeProject.groupproj) (Project group), [`Keyboard and Spell checker/Units/KeyboardFunctions.pas`](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/KeyboardFunctions.pas) (Key engine), [`Keyboard and Spell checker/SpellChecker/AvroSpell.dpr`](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/AvroSpell.dpr) (Spell app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_main_app["Main app"]
  node_main_dpr["Keyboard app<br/>desktop ime exe<br/>[Avro_Keyboard.dpr]"]
  node_hook["Keyboard hook<br/>input capture<br/>[KeyboardHook.pas]"]
  node_kbd_core["Key engine<br/>typing core"]
  node_vk_codes["Key codes<br/>key mapping<br/>[VirtualKeyCode.pas]"]
  node_layout_loader["Layout loader<br/>layout runtime"]
  node_phonetic_search["Phonetic search<br/>conversion engine"]
  node_autocorrect["Auto-correct<br/>text correction<br/>[uAutoCorrect.pas]"]
  node_registry["Settings store<br/>config persistence"]
  node_system_integration["System integration<br/>windows integration"]
  node_skin_loader["Skin loader<br/>theme runtime<br/>[SkinLoader.pas]"]
  node_layout_forms["Main UI<br/>forms layer<br/>[ufrmOptions.pas]"]
end

subgraph group_spell_checker["Spell checker"]
  node_spell_dpr["Spell app<br/>spell checker exe<br/>[AvroSpell.dpr]"]
  node_spell_ui["Spell UI<br/>forms layer<br/>[ufrmSpell.pas]"]
  node_dict_store[("Dictionary store<br/>lexicon data")]
  node_spell_phonetic["Phonetic match<br/>candidate engine"]
  node_spell_rank["Ranking"]
end

subgraph group_tools["Companion tools"]
  node_layout_editor["Layout editor<br/>layout tool<br/>[LayoutEditor.dpr]"]
  node_skin_designer["Skin designer<br/>skin tool<br/>[SkinDesigner.dpr]"]
  node_bijoy_conv["Bijoy converter<br/>unicode converter"]
end

subgraph group_assets["Assets"]
  node_layouts_asset["Keyboard layouts<br/>layout assets"]
  node_skins_asset["Skins<br/>skin assets"]
  node_docs_asset["Docs<br/>help assets<br/>[Overview.pdf]"]
  node_db_asset[("Packaged data<br/>dictionary assets<br/>[Database.db3]")]
end

node_proj_group["Project group<br/>delphi groupproj"]

node_proj_group -->|"builds"| node_main_dpr
node_proj_group -->|"builds"| node_spell_dpr
node_proj_group -->|"builds"| node_layout_editor
node_proj_group -->|"builds"| node_skin_designer
node_proj_group -->|"builds"| node_bijoy_conv
node_main_dpr -->|"runs"| node_hook
node_hook -->|"interprets"| node_vk_codes
node_vk_codes -->|"feeds"| node_kbd_core
node_kbd_core -->|"uses"| node_layout_loader
node_kbd_core -->|"uses"| node_phonetic_search
node_kbd_core -->|"applies"| node_autocorrect
node_layout_loader -->|"loads"| node_layouts_asset
node_main_dpr -->|"persists"| node_registry
node_main_dpr -->|"integrates"| node_system_integration
node_main_dpr -->|"themes"| node_skin_loader
node_main_dpr -->|"shows"| node_layout_forms
node_layout_forms -->|"references"| node_skins_asset
node_layout_forms -->|"helps"| node_docs_asset
node_spell_dpr -->|"loads"| node_dict_store
node_spell_dpr -->|"matches"| node_spell_phonetic
node_spell_phonetic -->|"ranks"| node_spell_rank
node_spell_rank -->|"scores"| node_dict_store
node_spell_dpr -->|"shows"| node_spell_ui
node_layout_editor -->|"edits"| node_layouts_asset
node_skin_designer -->|"creates"| node_skins_asset
node_bijoy_conv -->|"uses"| node_db_asset

click node_proj_group "https://github.com/mugli/avro-keyboard/blob/master/WholeProject.groupproj"
click node_main_dpr "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Avro_Keyboard.dpr"
click node_hook "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Units/KeyboardHook.pas"
click node_kbd_core "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Units/KeyboardFunctions.pas"
click node_vk_codes "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Units/VirtualKeyCode.pas"
click node_layout_loader "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Units/KeyboardLayoutLoader.pas"
click node_phonetic_search "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Units/uRegExPhoneticSearch.pas"
click node_autocorrect "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Units/uAutoCorrect.pas"
click node_registry "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Units/uRegistrySettings.pas"
click node_system_integration "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Units/uWindowHandlers.pas"
click node_skin_loader "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Units/SkinLoader.pas"
click node_layout_forms "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/Forms/ufrmOptions.pas"
click node_spell_dpr "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/SpellChecker/AvroSpell.dpr"
click node_spell_ui "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/SpellChecker/ufrmSpell.pas"
click node_dict_store "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/SpellChecker/uCustomDictionary.pas"
click node_spell_phonetic "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/SpellChecker/uRegExPhoneticSearch_Spell.pas"
click node_spell_rank "https://github.com/mugli/avro-keyboard/blob/master/Keyboard and Spell checker/SpellChecker/uSpellEditDistanceSearch.pas"
click node_layout_editor "https://github.com/mugli/avro-keyboard/blob/master/Layout Editor/LayoutEditor.dpr"
click node_skin_designer "https://github.com/mugli/avro-keyboard/blob/master/Skin Designer/SkinDesigner.dpr"
click node_bijoy_conv "https://github.com/mugli/avro-keyboard/blob/master/Unicode to ascii converter/Unicode_to_Bijoy.dpr"
click node_layouts_asset "https://github.com/mugli/avro-keyboard/blob/master/assets/keyboard-layouts/Avro Easy.avrolayout"
click node_skins_asset "https://github.com/mugli/avro-keyboard/blob/master/assets/skins/Avro Classic.avroskin"
click node_docs_asset "https://github.com/mugli/avro-keyboard/blob/master/assets/docs/Overview.pdf"
click node_db_asset "https://github.com/mugli/avro-keyboard/blob/master/assets/Database.db3"

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_main_dpr,node_hook,node_kbd_core,node_vk_codes,node_layout_loader,node_phonetic_search,node_autocorrect,node_registry,node_system_integration,node_skin_loader,node_layout_forms toneBlue
class node_spell_dpr,node_spell_ui,node_dict_store,node_spell_phonetic,node_spell_rank toneAmber
class node_layout_editor,node_skin_designer,node_bijoy_conv toneMint
class node_layouts_asset,node_skins_asset,node_docs_asset,node_db_asset toneRose
class node_proj_group toneNeutral
```

## Components

### Main app

Primary keyboard IME runtime and shared engine code.

- [Keyboard app](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Avro_Keyboard.dpr): desktop ime exe · Primary Avro Keyboard executable. · `Keyboard and Spell checker/Avro_Keyboard.dpr`
- [Keyboard hook](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/KeyboardHook.pas): input capture · Windows keyboard interception and event capture. · `Keyboard and Spell checker/Units/KeyboardHook.pas`
- [Key engine](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/KeyboardFunctions.pas): typing core · Key interpretation and keyboard behavior utilities. · `Keyboard and Spell checker/Units/KeyboardFunctions.pas`
- [Key codes](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/VirtualKeyCode.pas): key mapping · Virtual key constants and translation helpers. · `Keyboard and Spell checker/Units/VirtualKeyCode.pas`
- [Layout loader](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/KeyboardLayoutLoader.pas): layout runtime · Loads and applies external keyboard layout definitions. · `Keyboard and Spell checker/Units/KeyboardLayoutLoader.pas`
- [Phonetic search](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/uRegExPhoneticSearch.pas): conversion engine · Regex-based phonetic matching for Bangla typing. · `Keyboard and Spell checker/Units/uRegExPhoneticSearch.pas`
- [Auto-correct](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/uAutoCorrect.pas): text correction · Automatic correction and suggestion behavior. · `Keyboard and Spell checker/Units/uAutoCorrect.pas`
- [Settings store](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/uRegistrySettings.pas): config persistence · Registry-backed and XML-backed application settings. · `Keyboard and Spell checker/Units/uRegistrySettings.pas`
- [System integration](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/uWindowHandlers.pas): windows integration · Process, window, admin, and font-install integration. · `Keyboard and Spell checker/Units/uWindowHandlers.pas`
- [Skin loader](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/SkinLoader.pas): theme runtime · Loads skins and visual customization for the keyboard UI. · `Keyboard and Spell checker/Units/SkinLoader.pas`
- [Main UI](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Forms/ufrmOptions.pas): forms layer · Settings, dialogs, layout preview, and runtime UI forms. · `Keyboard and Spell checker/Forms/ufrmOptions.pas`

### Spell checker

Separate spelling runtime with dictionary and ranking pipeline.

- [Spell app](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/AvroSpell.dpr): spell checker exe · Standalone spell checker executable. · `Keyboard and Spell checker/SpellChecker/AvroSpell.dpr`
- [Spell UI](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/ufrmSpell.pas): forms layer · Spell editor, popup, and options UI. · `Keyboard and Spell checker/SpellChecker/ufrmSpell.pas`
- [Dictionary store](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/uCustomDictionary.pas): lexicon data · Custom dictionary and packaged database access. · `Keyboard and Spell checker/SpellChecker/uCustomDictionary.pas`
- [Phonetic match](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/uRegExPhoneticSearch_Spell.pas): candidate engine · Phonetic search and suggestion builder for spelling. · `Keyboard and Spell checker/SpellChecker/uRegExPhoneticSearch_Spell.pas`
- [Ranking](https://github.com/mugli/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/uSpellEditDistanceSearch.pas): similarity ranking · Edit-distance and similarity ordering for candidates. · `Keyboard and Spell checker/SpellChecker/uSpellEditDistanceSearch.pas`

### Companion tools

Standalone editors and converters built from the same domain.

- [Layout editor](https://github.com/mugli/avro-keyboard/blob/HEAD/Layout%20Editor/LayoutEditor.dpr): layout tool · Standalone editor for keyboard layouts. · `Layout Editor/LayoutEditor.dpr`
- [Skin designer](https://github.com/mugli/avro-keyboard/blob/HEAD/Skin%20Designer/SkinDesigner.dpr): skin tool · Standalone authoring tool for Avro skin assets. · `Skin Designer/SkinDesigner.dpr`
- [Bijoy converter](https://github.com/mugli/avro-keyboard/blob/HEAD/Unicode%20to%20ascii%20converter/Unicode_to_Bijoy.dpr): unicode converter · Unicode Bangla to Bijoy/ASCII conversion utility. · `Unicode to ascii converter/Unicode_to_Bijoy.dpr`

### Assets

Packaged layouts, skins, docs, data, and runtime resources.

- [Keyboard layouts](https://github.com/mugli/avro-keyboard/blob/HEAD/assets/keyboard-layouts/Avro%20Easy.avrolayout): layout assets · Packaged Avro keyboard layout files used at runtime. · `assets/keyboard-layouts/Avro Easy.avrolayout`
- [Skins](https://github.com/mugli/avro-keyboard/blob/HEAD/assets/skins/Avro%20Classic.avroskin): skin assets · Packaged visual themes for the runtime and designer. · `assets/skins/Avro Classic.avroskin`
- [Docs](https://github.com/mugli/avro-keyboard/blob/master/assets/docs/Overview.pdf): help assets · Bundled help and user documentation. · `assets/docs/Overview.pdf`
- [Packaged data](https://github.com/mugli/avro-keyboard/blob/master/assets/Database.db3): dictionary assets · Bundled database and autodictionary data. · `assets/Database.db3`

### Other components

- [Project group](https://github.com/mugli/avro-keyboard/blob/master/WholeProject.groupproj): delphi groupproj · Build entrypoint that ties all executables together. · `WholeProject.groupproj`

## Connections

- Project group → Keyboard app: builds · Project group includes the main keyboard executable.
- Project group → Spell app: builds · Project group includes the spell checker executable.
- Project group → Layout editor: builds · Project group includes the layout editor tool.
- Project group → Skin designer: builds · Project group includes the skin designer tool.
- Project group → Bijoy converter: builds · Project group includes the Unicode-to-Bijoy converter.
- Keyboard app → Keyboard hook: runs · Main executable starts the keyboard hook pipeline.
- Keyboard hook → Key codes: interprets · Captured events are mapped through virtual key codes.
- Key codes → Key engine: feeds · Key codes drive typing behavior and interpretation.
- Key engine → Layout loader: uses · Fixed-layout typing is resolved through loaded layouts.
- Key engine → Phonetic search: uses · Phonetic typing uses regex-based search and builders.
- Key engine → Auto-correct: applies · Typing flow can trigger autocorrect behavior.
- Layout loader → Keyboard layouts: loads · Runtime loads external .avrolayout files.
- Keyboard app → Settings store: persists · Main app stores user and integration settings.
- Keyboard app → System integration: integrates · Main app performs OS-level window, process, admin, and font actions.
- Keyboard app → Skin loader: themes · Main app loads skins for runtime UI.
- Keyboard app → Main UI: shows · Forms layer provides options, dialogs, and previews.
- Main UI → Skins: references · UI and preview features use packaged skins.
- Main UI → Docs: helps · User-facing dialogs connect to bundled documentation.
- Spell app → Dictionary store: loads · Spell checker reads dictionary data and custom dictionaries.
- Spell app → Phonetic match: matches · Spell checker generates phonetic candidates.
- Phonetic match → Ranking: ranks · Candidate generation is ordered by distance/similarity.
- Ranking → Dictionary store: scores · Ranking is applied against dictionary-backed candidates.
- Spell app → Spell UI: shows · Spell checker exposes popup and editor UI.
- Layout editor → Keyboard layouts: edits · Layout editor works on keyboard layout assets.
- Skin designer → Skins: creates · Skin designer produces avroskin assets.
- Bijoy converter → Packaged data: uses · Converter may rely on packaged language data.
