# uqqu/cadans architecture

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

- Interactive diagram: https://gitdiagram.com/uqqu/cadans
- Repository: https://github.com/uqqu/cadans
- Video tour (about a minute): https://gitdiagram.com/uqqu/cadans/video

## Overview

Cadans is a Windows input-remapping system: users define assignments and combine them with conditions and active layers; keyboard or mouse events are interpreted as taps, holds, chords, or gestures, then trigger actions or continue interaction chains. The README documents this product workflow, while the sampled implementation is the separate C keyboard-hook prototype under c_test. The AutoHotkey runtime and GUI modules are present in the tree but were not sampled, so their internal links are documented at a high level rather than treated as inspected calls.

Main entry points: [`core/gesture_processing.ahk`](https://github.com/uqqu/cadans/blob/main/core/gesture_processing.ahk) (Gesture processing), [`gui/gui.ahk`](https://github.com/uqqu/cadans/blob/main/gui/gui.ahk) (Assignment GUI), [`c_test/keyboard_hook.c`](https://github.com/uqqu/cadans/blob/main/c_test/keyboard_hook.c) (Keyboard hook), [`c_test/tdfw.c`](https://github.com/uqqu/cadans/blob/main/c_test/tdfw.c) (C prototype entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Configuration interface"]
  node_gui["Assignment GUI<br/>[gui.ahk]"]
  node_gui_forms["Assignment forms<br/>[gui_forms.ahk]"]
  node_gui_gestures["Gesture editor<br/>[gui_gestures.ahk]"]
  node_gui_layers["Layer editor<br/>[gui_layers.ahk]"]
end

subgraph group_runtime["Input runtime"]
  node_main["Runtime entry<br/>[main.ahk]"]
  node_config["Global settings<br/>[config.ahk]"]
  node_processing["Gesture processing"]
  node_gestures["Gesture rules<br/>[gestures.ahk]"]
  node_keys["Key definitions<br/>[keys.ahk]"]
  node_processes["Process context<br/>[processes.ahk]"]
  node_functions["Callable actions"]
end

subgraph group_presets["Assignment data"]
  node_layers[("Layer assignments")]
  node_user_functions["Custom functions<br/>[user_functions.ahk]"]
end

subgraph group_prototype["C hook prototype"]
  node_c_entry["C prototype entry<br/>[tdfw.c]"]
  node_c_hook["Keyboard hook<br/>[keyboard_hook.c]"]
  node_c_parser["Mapping parser<br/>[json_parser.c]"]
  node_c_json["cJSON parser<br/>[cJSON.c]"]
  node_c_structures["Mapping structures<br/>[structures.h]"]
  node_c_buffers["Key buffers<br/>[keybuffer.c]"]
  node_c_utils["Mapping lookup<br/>[utils.c]"]
  node_c_data["Prototype mapping<br/>[c_test.json]"]
end

node_user(("Cadans user"))
node_actor_input(("Keyboard or mouse"))
node_actions["Input and text actions"]

node_user -->|"configures"| node_gui
node_gui -.->|"edits assignments"| node_gui_forms
node_gui -.->|"edits gestures"| node_gui_gestures
node_gui -.->|"edits layers"| node_gui_layers
node_gui -->|"uses presets"| node_layers
node_actor_input -->|"provides events"| node_main
node_main -.->|"loads rules"| node_config
node_main -.->|"dispatches events"| node_processing
node_processing -.->|"recognizes gestures"| node_gestures
node_processing -.->|"interprets keys"| node_keys
node_processing -.->|"checks context"| node_processes
node_processing -->|"selects assignments"| node_layers
node_processing -.->|"resolves actions"| node_functions
node_functions -.->|"calls custom code"| node_user_functions
node_functions -->|"simulates input"| node_actions
node_c_entry -->|"loads mappings"| node_c_parser
node_c_entry -->|"installs hook"| node_c_hook
node_c_parser -->|"parses JSON"| node_c_json
node_c_parser -->|"builds mappings"| node_c_structures
node_c_entry -.->|"reads mapping"| node_c_data
node_c_hook -->|"tracks pressed keys"| node_c_buffers
node_c_hook -->|"looks up entries"| node_c_structures
node_c_hook -->|"finds mappings"| node_c_utils
node_c_hook -->|"sends values"| node_actions

click node_gui "https://github.com/uqqu/cadans/blob/main/gui/gui.ahk"
click node_gui_forms "https://github.com/uqqu/cadans/blob/main/gui/gui_forms.ahk"
click node_gui_gestures "https://github.com/uqqu/cadans/blob/main/gui/gui_gestures.ahk"
click node_gui_layers "https://github.com/uqqu/cadans/blob/main/gui/gui_layers.ahk"
click node_main "https://github.com/uqqu/cadans/blob/main/main.ahk"
click node_config "https://github.com/uqqu/cadans/blob/main/core/config.ahk"
click node_processing "https://github.com/uqqu/cadans/blob/main/core/gesture_processing.ahk"
click node_gestures "https://github.com/uqqu/cadans/blob/main/core/gestures.ahk"
click node_keys "https://github.com/uqqu/cadans/blob/main/core/keys.ahk"
click node_processes "https://github.com/uqqu/cadans/blob/main/core/processes.ahk"
click node_functions "https://github.com/uqqu/cadans/blob/main/core/callable_functions.ahk"
click node_layers "https://github.com/uqqu/cadans/tree/main/layers"
click node_user_functions "https://github.com/uqqu/cadans/blob/main/user_functions.ahk"
click node_c_entry "https://github.com/uqqu/cadans/blob/main/c_test/tdfw.c"
click node_c_hook "https://github.com/uqqu/cadans/blob/main/c_test/keyboard_hook.c"
click node_c_parser "https://github.com/uqqu/cadans/blob/main/c_test/json_parser.c"
click node_c_json "https://github.com/uqqu/cadans/blob/main/c_test/cJSON.c"
click node_c_structures "https://github.com/uqqu/cadans/blob/main/c_test/structures.h"
click node_c_buffers "https://github.com/uqqu/cadans/blob/main/c_test/keybuffer.c"
click node_c_utils "https://github.com/uqqu/cadans/blob/main/c_test/utils.c"
click node_c_data "https://github.com/uqqu/cadans/blob/main/c_test/c_test.json"

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_gui,node_gui_forms,node_gui_gestures,node_gui_layers,node_user toneBlue
class node_main,node_config,node_processing,node_gestures,node_keys,node_processes,node_functions toneAmber
class node_layers,node_user_functions toneMint
class node_c_entry,node_c_hook,node_c_parser,node_c_json,node_c_structures,node_c_buffers,node_c_utils,node_c_data toneRose
class node_actor_input,node_actions toneIndigo
```

## Components

### Configuration interface

- [Assignment GUI](https://github.com/uqqu/cadans/blob/main/gui/gui.ahk): `gui/gui.ahk`
- [Assignment forms](https://github.com/uqqu/cadans/blob/main/gui/gui_forms.ahk): `gui/gui_forms.ahk`
- [Gesture editor](https://github.com/uqqu/cadans/blob/main/gui/gui_gestures.ahk): `gui/gui_gestures.ahk`
- [Layer editor](https://github.com/uqqu/cadans/blob/main/gui/gui_layers.ahk): `gui/gui_layers.ahk`

### Input runtime

- [Runtime entry](https://github.com/uqqu/cadans/blob/main/main.ahk): `main.ahk`
- [Global settings](https://github.com/uqqu/cadans/blob/main/core/config.ahk): `core/config.ahk`
- [Gesture processing](https://github.com/uqqu/cadans/blob/main/core/gesture_processing.ahk): `core/gesture_processing.ahk`
- [Gesture rules](https://github.com/uqqu/cadans/blob/main/core/gestures.ahk): `core/gestures.ahk`
- [Key definitions](https://github.com/uqqu/cadans/blob/main/core/keys.ahk): `core/keys.ahk`
- [Process context](https://github.com/uqqu/cadans/blob/main/core/processes.ahk): `core/processes.ahk`
- [Callable actions](https://github.com/uqqu/cadans/blob/main/core/callable_functions.ahk): `core/callable_functions.ahk`

### Assignment data

- [Layer assignments](https://github.com/uqqu/cadans/tree/main/layers): `layers`
- [Custom functions](https://github.com/uqqu/cadans/blob/main/user_functions.ahk): `user_functions.ahk`

### C hook prototype

- [C prototype entry](https://github.com/uqqu/cadans/blob/main/c_test/tdfw.c): `c_test/tdfw.c`
- [Keyboard hook](https://github.com/uqqu/cadans/blob/main/c_test/keyboard_hook.c): `c_test/keyboard_hook.c`
- [Mapping parser](https://github.com/uqqu/cadans/blob/main/c_test/json_parser.c): `c_test/json_parser.c`
- [cJSON parser](https://github.com/uqqu/cadans/blob/main/c_test/cJSON.c): `c_test/cJSON.c`
- [Mapping structures](https://github.com/uqqu/cadans/blob/main/c_test/structures.h): `c_test/structures.h`
- [Key buffers](https://github.com/uqqu/cadans/blob/main/c_test/keybuffer.c): `c_test/keybuffer.c`
- [Mapping lookup](https://github.com/uqqu/cadans/blob/main/c_test/utils.c): `c_test/utils.c`
- [Prototype mapping](https://github.com/uqqu/cadans/blob/main/c_test/c_test.json): `c_test/c_test.json`

### Other components

- **Cadans user**
- **Keyboard or mouse**
- **Input and text actions**

## Connections

- Cadans user → Assignment GUI: configures (evidence: `README.md`)
- Assignment GUI → Assignment forms: edits assignments
- Assignment GUI → Gesture editor: edits gestures
- Assignment GUI → Layer editor: edits layers
- Assignment GUI → Layer assignments: uses presets (evidence: `README.md`)
- Keyboard or mouse → Runtime entry: provides events (evidence: `README.md`)
- Runtime entry → Global settings: loads rules
- Runtime entry → Gesture processing: dispatches events
- Gesture processing → Gesture rules: recognizes gestures
- Gesture processing → Key definitions: interprets keys
- Gesture processing → Process context: checks context
- Gesture processing → Layer assignments: selects assignments (evidence: `README.md`)
- Gesture processing → Callable actions: resolves actions
- Callable actions → Custom functions: calls custom code
- Callable actions → Input and text actions: simulates input (evidence: `README.md`)
- C prototype entry → Mapping parser: loads mappings (evidence: `c_test/tdfw.c`)
- C prototype entry → Keyboard hook: installs hook (evidence: `c_test/tdfw.c`)
- Mapping parser → cJSON parser: parses JSON (evidence: `c_test/json_parser.c`)
- Mapping parser → Mapping structures: builds mappings (evidence: `c_test/json_parser.c`)
- C prototype entry → Prototype mapping: reads mapping
- Keyboard hook → Key buffers: tracks pressed keys (evidence: `c_test/keyboard_hook.c`)
- Keyboard hook → Mapping structures: looks up entries (evidence: `c_test/keyboard_hook.c`)
- Keyboard hook → Mapping lookup: finds mappings (evidence: `c_test/keyboard_hook.c`)
- Keyboard hook → Input and text actions: sends values
