# tar3q-az1z/avro-keyboard architecture

> Architecture diagram of the GitHub repository tar3q-az1z/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/tar3q-az1z/avro-keyboard
- Repository: https://github.com/tar3q-az1z/avro-keyboard

## Overview

1. **Repository shape**
   - This is a Delphi 2010 codebase for a small suite of related Windows desktop tools centered on **Avro Keyboard**, a Bangla IME (input method editor).
   - The repo is not one app: it contains a main keyboard engine plus companion executables for **spell checking**, **layout editing**, **skin design**, and a **Unicode-to-Bijoy converter**.

2. **Main product boundary: Avro Keyboard**
   - The `Keyboard and Spell checker` project is the primary runtime application.
   - It combines low-level input capture, transliteration, autocorrect, layout handling, update notification, and user configuration into one interactive system-tray style desktop app.

3. **Core input pipeline**
   - User keystrokes are intercepted through keyboard-hook and virtual-key handling units, then routed into layout-specific processing.
   - The key transformation path is phonetic Bangla typing: English keystrokes are interpreted by phonetic rules and converted into Bangla text.
   - Supporting logic includes abbreviation expansion, keyboard macros, auto-correction, and edit-distance / regex-based suggestion search.

4. **Shared engine and language logic**
   - The `Classes` and `Units` folders hold most of the reusable engine code.
   - Important responsibilities here include:
     - phonetic rule generation and matching,
     - Bangla character mapping,
     - layout abstraction,
     - Levenshtein/similarity ranking,
     - process/window interaction,
     - file/folder and locale helpers,
     - registry or XML-backed settings.

5. **Configuration and persistence**
   - Settings are split between **registry-based** and **XML-based** handling, reflecting the app’s standard vs portable modes.
   - `ProjectDefines.inc` controls that packaging choice; this affects where runtime state is stored and how the app behaves when deployed.
   - `NativeXml` is part of the source tree and is used for structured config/storage.

6. **UI layer in the main app**
   - The `Forms` directory contains the visible shell and dialogs: options, about, update notification, conflict handling, layout viewer, spell/auto-correct related dialogs, splash screen, and toolbar components.
   - These forms are mostly presentation wrappers around the shared engine rather than separate business logic layers.

7. **Layout and skin subsystem**
   - Layouts and skins are first-class concepts, not just themes.
   - Runtime code loads keyboard layouts and skin resources from internal `.rc/.res` assets and from files handled by `KeyboardLayoutLoader` and `SkinLoader`.
   - The layout/skin converters bridge designer tools and runtime formats, so layout assets can be edited externally and consumed by the keyboard app.

8. **Companion tool: Layout Editor**
   - `Layout Editor` is a separate executable for editing keyboard layouts.
   - It reuses the same registry/settings and skin/layout conversion code, which indicates the editor writes data consumed directly by the main IME.

9. **Companion tool: Skin Designer**
   - `Skin Designer` is another standalone desktop tool for creating the visual skin assets used by the keyboard runtime.
   - It includes image/frame editing helpers and a skin creation form, showing that skinning is a packaged asset pipeline separate from the IME’s core typing logic.

10. **Spell checker subsystem**
   - The `SpellChecker` project is a distinct executable focused on spelling assistance.
   - It has its own forms and engine code for:
     - dictionary lookup,
     - custom dictionaries,
     - clipboard interaction,
     - phonetic and regex-based search,
     - edit-distance ranking,
     - suggestion generation.
   - This is a separate boundary from the main keyboard app, though it uses the same Bangla/phonetic domain logic.

11. **Spell checking dependencies**
   - The spell checker includes hashing, memo parsing, reverse phonetic matching, and suggestion builders.
   - The presence of `DISQLite3` in the README suggests dictionary or linguistic data may be persisted through SQLite-backed storage in parts of the system, even if the exact database access is abstracted by local units.

12. **Utility tool: Unicode to Bijoy converter**
   - `Unicode to ascii converter` is a lightweight standalone converter from Unicode Bangla text to Bijoy encoding.
   - It shares the same language-domain knowledge but is operationally isolated from the IME runtime.

13. **External libraries and platform dependencies**
   - The repo depends on Delphi Windows desktop infrastructure plus several external libraries that materially shape the architecture:
     - **PCRE** for regex-driven phonetic matching,
     - **NativeXml** for structured settings/data,
     - **DISQLite3** for database access,
     - **ICS** and **JEDI (JVCL/JCL)** as supporting Delphi frameworks.
   - These are not incidental: they underpin search, configuration, and integration features.

14. **Resource packaging**
   - Icons, skins, layouts, and form assets are compiled into resource files (`.rc`, `.res`, `.rsb`) and loaded at runtime.
   - That means the architecture relies heavily on embedded assets plus a few editable external formats rather than web services or cloud dependencies.

15. **Overall architectural picture**
   - At the center is a **Windows input method engine** with a phonetic conversion core.
   - Around it are **configuration/storage**, **input/system integration**, **visual skin/layout management**, and **spell-check/suggestion** subsystems.
   - Separate tools exist to author the data consumed by the runtime, making this a small ecosystem of tightly related Delphi executables rather than a single monolithic app.

Main entry points: [`Keyboard and Spell checker/Avro_Keyboard.dpr`](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Avro_Keyboard.dpr) (Main app), [`Keyboard and Spell checker/Classes/clsSkinLayoutConverter.pas`](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Classes/clsSkinLayoutConverter.pas) (Layout/skin bridge), [`Keyboard and Spell checker/Classes/clsAvroPhonetic.pas`](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Classes/clsAvroPhonetic.pas) (Phonetic core), [`Keyboard and Spell checker/Units/uRegistrySettings.pas`](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/uRegistrySettings.pas) (Settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_main["Avro Keyboard"]
  node_n_main_dpr["Main app<br/>Delphi exe<br/>[Avro_Keyboard.dpr]"]
  node_n_forms["Main forms<br/>ui shell<br/>[uForm1.pas]"]
  node_n_resources["Runtime assets<br/>embedded resources<br/>[Avro_Keyboard.rc]"]
end

subgraph group_grp_spell["Spell Checker"]
  node_n_spell_dpr["Spell app<br/>Delphi exe"]
  node_n_spell_engine["Spell engine<br/>dictionary search"]
  node_n_spell_search["Spell search<br/>ranked search"]
  node_n_spell_dict["Dictionary store<br/>dictionary data"]
  node_n_spell_ui["Spell forms<br/>ui shell<br/>[ufrmSpell.pas]"]
end

subgraph group_grp_tools["Authoring Tools"]
  node_n_layout_editor["Layout editor<br/>Delphi exe<br/>[LayoutEditor.dpr]"]
  node_n_skin_designer["Skin designer<br/>Delphi exe<br/>[SkinDesigner.dpr]"]
  node_n_bijoy["Bijoy converter<br/>converter exe"]
end

subgraph group_grp_shared["Shared Engine"]
  node_n_input_hook["Input hook<br/>keyboard capture<br/>[KeyboardHook.pas]"]
  node_n_key_funcs["Key funcs<br/>key handling"]
  node_n_phonetic["Phonetic core<br/>transliteration"]
  node_n_layout_loader["Layout loader<br/>layout runtime"]
  node_n_skin_loader["Skin loader<br/>skin runtime<br/>[SkinLoader.pas]"]
  node_n_autocorrect["Auto-correct<br/>text assist<br/>[uAutoCorrect.pas]"]
  node_n_search["Search engine<br/>phonetic search"]
  node_n_settings["Settings<br/>config storage"]
  node_n_layout_model["Layout model<br/>[clsLayout.pas]"]
  node_n_process["OS bridge<br/>window/process"]
  node_n_converter["Layout/skin bridge<br/>asset conversion"]
end

node_n_main_dpr -->|"captures keys"| node_n_input_hook
node_n_main_dpr -->|"shows UI"| node_n_forms
node_n_input_hook -->|"normalizes input"| node_n_key_funcs
node_n_key_funcs -->|"routes typing"| node_n_phonetic
node_n_phonetic -->|"applies rules"| node_n_layout_model
node_n_layout_model -->|"loads layouts"| node_n_layout_loader
node_n_main_dpr -->|"assists typing"| node_n_autocorrect
node_n_autocorrect -->|"suggests matches"| node_n_search
node_n_search -->|"shares phonetics"| node_n_phonetic
node_n_main_dpr -->|"reads config"| node_n_settings
node_n_settings -->|"integrates OS"| node_n_process
node_n_main_dpr -->|"loads skin"| node_n_skin_loader
node_n_skin_loader -->|"uses assets"| node_n_resources
node_n_converter -->|"bridges formats"| node_n_layout_loader
node_n_converter -->|"bridges formats"| node_n_skin_loader
node_n_layout_editor -->|"edits layouts"| node_n_converter
node_n_layout_editor -->|"shares config"| node_n_settings
node_n_skin_designer -->|"builds skins"| node_n_converter
node_n_spell_dpr -->|"runs engine"| node_n_spell_engine
node_n_spell_engine -->|"ranks results"| node_n_spell_search
node_n_spell_search -->|"looks up words"| node_n_spell_dict
node_n_spell_dpr -->|"shows dialogs"| node_n_spell_ui
node_n_spell_dpr -->|"reuses config"| node_n_settings
node_n_bijoy -->|"shares domain"| node_n_phonetic

click node_n_main_dpr "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Avro_Keyboard.dpr"
click node_n_input_hook "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Units/KeyboardHook.pas"
click node_n_key_funcs "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Units/KeyboardFunctions.pas"
click node_n_phonetic "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Classes/clsAvroPhonetic.pas"
click node_n_layout_loader "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Units/KeyboardLayoutLoader.pas"
click node_n_skin_loader "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Units/SkinLoader.pas"
click node_n_autocorrect "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Units/uAutoCorrect.pas"
click node_n_search "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Units/uRegExPhoneticSearch.pas"
click node_n_settings "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Units/uRegistrySettings.pas"
click node_n_layout_model "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Classes/clsLayout.pas"
click node_n_process "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Units/uProcessHandler.pas"
click node_n_forms "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Forms/uForm1.pas"
click node_n_resources "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Avro_Keyboard.rc"
click node_n_spell_dpr "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/SpellChecker/Avro_Spell_Checker.dpr"
click node_n_spell_engine "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/SpellChecker/clsSpellPhoneticSuggestionBuilder.pas"
click node_n_spell_search "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/SpellChecker/uSpellEditDistanceSearch.pas"
click node_n_spell_dict "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/SpellChecker/uCustomDictionary.pas"
click node_n_spell_ui "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/SpellChecker/ufrmSpell.pas"
click node_n_layout_editor "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Layout Editor/LayoutEditor.dpr"
click node_n_skin_designer "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Skin Designer/SkinDesigner.dpr"
click node_n_bijoy "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Unicode to ascii converter/Unicode_to_Bijoy.dpr"
click node_n_converter "https://github.com/tar3q-az1z/avro-keyboard/blob/master/Keyboard and Spell checker/Classes/clsSkinLayoutConverter.pas"

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_n_main_dpr,node_n_forms,node_n_resources toneBlue
class node_n_spell_dpr,node_n_spell_engine,node_n_spell_search,node_n_spell_dict,node_n_spell_ui toneAmber
class node_n_layout_editor,node_n_skin_designer,node_n_bijoy toneMint
class node_n_input_hook,node_n_key_funcs,node_n_phonetic,node_n_layout_loader,node_n_skin_loader,node_n_autocorrect,node_n_search,node_n_settings,node_n_layout_model,node_n_process,node_n_converter toneRose
```

## Components

### Avro Keyboard

Primary keyboard IME runtime and its UI/settings flow.

- [Main app](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Avro_Keyboard.dpr): Delphi exe · Primary Avro Keyboard runtime entry point. · `Keyboard and Spell checker/Avro_Keyboard.dpr`
- [Main forms](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Forms/uForm1.pas): ui shell · Options, update, conflict, layout, and tray dialogs. · `Keyboard and Spell checker/Forms/uForm1.pas`
- [Runtime assets](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Avro_Keyboard.rc): embedded resources · Compiled layouts, skins, icons, and form resources. · `Keyboard and Spell checker/Avro_Keyboard.rc`

### Spell Checker

Standalone spelling assistance executable and its suggestion engine.

- [Spell app](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/Avro_Spell_Checker.dpr): Delphi exe · Standalone spell-checking application entry point. · `Keyboard and Spell checker/SpellChecker/Avro_Spell_Checker.dpr`
- [Spell engine](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/clsSpellPhoneticSuggestionBuilder.pas): dictionary search · Dictionary lookup, memo parsing, and suggestion building. · `Keyboard and Spell checker/SpellChecker/clsSpellPhoneticSuggestionBuilder.pas`
- [Spell search](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/uSpellEditDistanceSearch.pas): ranked search · Edit-distance, regex, and reverse phonetic matching. · `Keyboard and Spell checker/SpellChecker/uSpellEditDistanceSearch.pas`
- [Dictionary store](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/uCustomDictionary.pas): dictionary data · Custom dictionary and persistence layer. · `Keyboard and Spell checker/SpellChecker/uCustomDictionary.pas`
- [Spell forms](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/SpellChecker/ufrmSpell.pas): ui shell · Spell checker dialogs, popup, and options. · `Keyboard and Spell checker/SpellChecker/ufrmSpell.pas`

### Authoring Tools

Separate desktop tools for layout and skin creation.

- [Layout editor](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Layout%20Editor/LayoutEditor.dpr): Delphi exe · Standalone layout authoring tool. · `Layout Editor/LayoutEditor.dpr`
- [Skin designer](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Skin%20Designer/SkinDesigner.dpr): Delphi exe · Standalone skin authoring tool. · `Skin Designer/SkinDesigner.dpr`
- [Bijoy converter](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Unicode%20to%20ascii%20converter/Unicode_to_Bijoy.dpr): converter exe · Unicode Bangla to Bijoy encoding converter. · `Unicode to ascii converter/Unicode_to_Bijoy.dpr`

### Shared Engine

Reusable language, input, and integration units shared across executables.

- [Input hook](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/KeyboardHook.pas): keyboard capture · Interprets low-level keystrokes and virtual keys. · `Keyboard and Spell checker/Units/KeyboardHook.pas`
- [Key funcs](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/KeyboardFunctions.pas): key handling · Keyboard utility logic and key translation helpers. · `Keyboard and Spell checker/Units/KeyboardFunctions.pas`
- [Phonetic core](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Classes/clsAvroPhonetic.pas): transliteration · Phonetic Bangla conversion and rule matching. · `Keyboard and Spell checker/Classes/clsAvroPhonetic.pas`
- [Layout loader](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/KeyboardLayoutLoader.pas): layout runtime · Loads and applies keyboard layouts. · `Keyboard and Spell checker/Units/KeyboardLayoutLoader.pas`
- [Skin loader](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/SkinLoader.pas): skin runtime · Loads visual skin resources for the IME shell. · `Keyboard and Spell checker/Units/SkinLoader.pas`
- [Auto-correct](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/uAutoCorrect.pas): text assist · Abbreviation expansion, macros, and correction logic. · `Keyboard and Spell checker/Units/uAutoCorrect.pas`
- [Search engine](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/uRegExPhoneticSearch.pas): phonetic search · Regex-driven phonetic and edit-distance suggestion search. · `Keyboard and Spell checker/Units/uRegExPhoneticSearch.pas`
- [Settings](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/uRegistrySettings.pas): config storage · Registry/XML-backed configuration and portable-mode state. · `Keyboard and Spell checker/Units/uRegistrySettings.pas`
- [Layout model](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Classes/clsLayout.pas): layout model · Layout abstractions and Bangla/English mapping structures. · `Keyboard and Spell checker/Classes/clsLayout.pas`
- [OS bridge](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Units/uProcessHandler.pas): window/process · Process, window, and system interaction helpers. · `Keyboard and Spell checker/Units/uProcessHandler.pas`
- [Layout/skin bridge](https://github.com/tar3q-az1z/avro-keyboard/blob/HEAD/Keyboard%20and%20Spell%20checker/Classes/clsSkinLayoutConverter.pas): asset conversion · Converts between editable authoring formats and runtime resources. · `Keyboard and Spell checker/Classes/clsSkinLayoutConverter.pas`

## Connections

- Main app → Input hook: captures keys · The main IME starts by intercepting keyboard input.
- Main app → Main forms: shows UI · Launches tray dialogs, options, and notifications.
- Input hook → Key funcs: normalizes input · Captured events are converted into usable key state.
- Key funcs → Phonetic core: routes typing · Keystrokes are handed to phonetic Bangla conversion.
- Phonetic core → Layout model: applies rules · Transliteration depends on layout-specific mappings.
- Layout model → Layout loader: loads layouts · Layout definitions are materialized at runtime.
- Main app → Auto-correct: assists typing · Macro and abbreviation logic enrich the input pipeline.
- Auto-correct → Search engine: suggests matches · Correction uses regex and similarity-based lookup.
- Search engine → Phonetic core: shares phonetics · Search reuses the same Bangla phonetic rules.
- Main app → Settings: reads config · Runtime behavior is driven by registry or XML settings.
- Settings → OS bridge: integrates OS · Settings support process/window and environment interaction.
- Main app → Skin loader: loads skin · The shell applies runtime skin resources.
- Skin loader → Runtime assets: uses assets · Skin and layout data are packaged in embedded resources.
- Layout/skin bridge → Layout loader: bridges formats · Authoring data is converted into runtime layout assets.
- Layout/skin bridge → Skin loader: bridges formats · Skin authoring output feeds the runtime loader.
- Layout editor → Layout/skin bridge: edits layouts · Layout Editor writes data consumed by the IME.
- Layout editor → Settings: shares config · Uses the same configuration conventions as the runtime.
- Skin designer → Layout/skin bridge: builds skins · Skin Designer creates assets for the keyboard runtime.
- Spell app → Spell engine: runs engine · Spell checker entry point starts suggestion generation.
- Spell engine → Spell search: ranks results · Suggestions are ranked through search and edit distance.
- Spell search → Dictionary store: looks up words · Search consults the dictionary store for candidates.
- Spell app → Spell forms: shows dialogs · Spell checker provides dedicated forms and popups.
- Spell app → Settings: reuses config · Spell checker shares registry/XML settings patterns.
- Bijoy converter → Phonetic core: shares domain · Unicode-to-Bijoy conversion uses the same Bangla language knowledge.
