# rcmdnk/vim_ahk architecture

> Architecture diagram of the GitHub repository rcmdnk/vim_ahk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rcmdnk/vim_ahk
- Repository: https://github.com/rcmdnk/vim_ahk

## Overview

##### Main Script and Core Library
- The primary file is “vim.ahk”, which serves as the entry point for initializing and managing Vim emulation.
- The “lib” directory contains various AutoHotkey modules separated by purpose:
– The “lib/bind” folder encapsulates the key mapping modules (e.g., vim_command.ahk, vim_move.ahk, vim_visual.ahk) which implement the actual movement and command logic.
– The “lib/util” folder holds utility scripts (e.g., vim_ahk_setting.ahk, vim_callstack.ahk, vim_ime.ahk) that support configuration, state management, and integration with system functions.
– Other modules (like vim_about.ahk, vim_gui.ahk, vim_state.ahk) provide application information, GUI-related functionality, and state tracking.

##### Build and Deployment
- The “build.bat” script shows that there’s a build process to generate a standalone executable from the AutoHotkey files.
- The “.github” directory with workflows and funding files indicates that continuous integration (CI) is in place (via GitHub actions) for tasks such as build and test automation.

##### Testing Infrastructure
- The “tests” directory houses the test-related scripts (run_vimahk_tests.ahk, testcases.txt, etc.) that simulate keystroke inputs to verify the correctness of keybinding responses and logic.

##### Assets and Additional Resources
- Configuration files (like renovate.json, .gitignore, and LICENSE) form part of regular project maintenance and dependency management.

– Label a “Core Engine” component which corresponds to the “vim.ahk” file. This acts as the central controller that initializes Vim emulation.
– Represent the “Library Modules” component (from the lib directory). Subdivide this into:
- “Key Bindings” (from lib/bind)
- “Utilities and Configuration” (from lib/util and other lib files).
– Include a “Build & Deployment” component that covers the process driven by “build.bat” plus the CI workflows (in .github/workflows).
– Show the “Testing” component (tests directory) that interacts with the core engine.

B. Map the Relationships and Data Flows
– Show a two-way relationship between “Core Engine” and “GUI/Visual Assets” to illustrate that mode changes and settings updates trigger GUI updates.

C. Highlight Architectural Patterns and Design Principles
– Emphasize the modular design: the project separates its functionality (key bindings, GUI handling, build processes) into separate modules.
– Note that the project uses a scripting language (AutoHotkey v2) to implement an event-driven model (key strokes, mode changes, and GUI responses) and facilitates standalone executable builds.
– Specify that the project follows principles of configuration-driven behavior (via variables defined in vim.ahk before loading libraries).

D. Include Relevant Technologies and Frameworks
– Clearly annotate that the project is implemented in AutoHotkey v2.
– Mention the external dependency on AutoHotkey runtime (when not using the standalone executable) and the use of GitHub Actions for CI.

- “Core Engine (vim.ahk)”
- “Library Modules” with subdivisions for “Key Bindings” and “Utilities”
- “Testing Suite”
- “Build & CI Pipeline” (include GitHub workflows and build.bat)
- For example, demonstrate how user key presses in a Windows application are intercepted by the “Core Engine”, which then invokes specific “Key Bindings” logic.
– Be detailed by ensuring every component is broken down to the level where a developer can quickly see which modules call or depend on others.
– With a full-stack perspective, even though this is not a traditional client-server architecture, emphasize that the separation between runtime logic (user input handling and mode transitions) and configuration/build processes is clear.

- At the center, the core script “vim.ahk” interacts with multiple library modules providing Vim-like behavior.
- Surrounding components represent build automation, testing, and assets, clearly delineated to show how the overall system functions together.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Runtime Components"
        CE["Core Engine (vim.ahk)"]:::runtime
        subgraph "Library Modules"
            KB["Key Bindings"]:::libnode
            UC["Utilities & Configuration"]:::libnode
        end
        subgraph "GUI & Assets"
            P["Pictures"]:::gui
            VI["vim_ahk_icons"]:::gui
        end
        TS["Testing Suite"]:::test
    end

    subgraph "Build & Deployment"
        BB["build.bat"]:::build
        CIw["CI Workflows"]:::build
        RA["Release Artifact (vim_ahk.exe)"]:::artifact
    end

    CE -->|"calls"| KB
    CE -->|"calls"| UC
    CE <-->|"updates"| P
    CE <-->|"updates"| VI
    TS -->|"inputs"| CE
    BB -->|"builds"| RA
    CIw -->|"triggers"| TS

    click CE "https://github.com/rcmdnk/vim_ahk/blob/master/vim.ahk"
    click KB "https://github.com/rcmdnk/vim_ahk/tree/master/lib/bind"
    click UC "https://github.com/rcmdnk/vim_ahk/tree/master/lib/util"
    click BB "https://github.com/rcmdnk/vim_ahk/blob/master/build.bat"
    click CIw "https://github.com/rcmdnk/vim_ahk/blob/master/.github/workflows/build_test.yml"
    click TS "https://github.com/rcmdnk/vim_ahk/tree/master/tests"
    click P "https://github.com/rcmdnk/vim_ahk/tree/master/pictures"
    click VI "https://github.com/rcmdnk/vim_ahk/tree/master/vim_ahk_icons"

    classDef runtime fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef libnode fill:#99CCFF,stroke:#333,stroke-width:2px;
    classDef gui fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef test fill:#FFC0CB,stroke:#333,stroke-width:2px;
    classDef build fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef artifact fill:#FFA07A,stroke:#333,stroke-width:2px;
```
