# gniziemazity/leo architecture

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

- Interactive diagram: https://gitdiagram.com/gniziemazity/leo
- Repository: https://github.com/gniziemazity/leo

## Overview

LEO is a Windows teaching tool that advances through lesson-plan code and auto-types it into the active editor. The README describes plan loading, editing, formatting, cursor jumping, pause and playback; sampled code shows Tkinter UI wiring, block management, progress highlighting and AutoHotkey script generation. Progress is shared with the AHK process through temporary files. AHK internals and some BlockManager methods were not fully sampled, so uncertain runtime links are omitted.

Main entry points: [`code/BlockManager.py`](https://github.com/gniziemazity/leo/blob/main/code/BlockManager.py) (Block manager), [`code/Main.py`](https://github.com/gniziemazity/leo/blob/main/code/Main.py) (App startup), [`code/TopBar.py`](https://github.com/gniziemazity/leo/blob/main/code/TopBar.py) (Top controls), [`code/RightBar.py`](https://github.com/gniziemazity/leo/blob/main/code/RightBar.py) (Edit controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Lesson interface"]
  node_main["App startup<br/>[Main.py]"]
  node_topbar["Top controls<br/>[TopBar.py]"]
  node_sidebar["Edit controls<br/>[RightBar.py]"]
end

subgraph group_plans["Plan editing"]
  node_textareas["Lesson blocks<br/>[TextArea.py]"]
  node_manager["Block manager<br/>[BlockManager.py]"]
  node_planfile["JSON lesson plan<br/>[Demo.json]"]
end

subgraph group_playback["Typing playback"]
  node_helpers["Text helpers<br/>[Utils.py]"]
  node_ahk["AutoHotkey runner<br/>[BlockManager.py]"]
end

subgraph group_state["Progress coordination"]
  node_progress["Progress files<br/>[cnt.txt]"]
  node_sync["Sync counter<br/>[sync.txt]"]
  node_safe["Safe counter<br/>[safe_cnt.txt]"]
  node_loadstate["Last-load path<br/>[last_load.txt]"]
end

node_user(("Teacher"))
node_editor(("Active code editor"))

node_user -->|"opens"| node_main
node_main -->|"creates"| node_topbar
node_main -->|"creates"| node_sidebar
node_main -->|"creates"| node_manager
node_topbar -->|"invokes actions"| node_manager
node_sidebar -->|"invokes actions"| node_manager
node_manager -->|"creates and edits"| node_textareas
node_manager -->|"loads and saves"| node_planfile
node_manager -->|"records path"| node_loadstate
node_manager -->|"counts and maps keys"| node_helpers
node_manager -->|"writes count"| node_progress
node_manager -->|"writes count"| node_sync
node_ahk -->|"reads and updates"| node_progress
node_ahk -->|"types lesson"| node_editor
node_manager -->|"launches script"| node_ahk
node_manager -->|"copies for reading"| node_safe
node_manager -->|"reads for highlighting"| node_safe

click node_main "https://github.com/gniziemazity/leo/blob/main/code/Main.py"
click node_topbar "https://github.com/gniziemazity/leo/blob/main/code/TopBar.py"
click node_sidebar "https://github.com/gniziemazity/leo/blob/main/code/RightBar.py"
click node_textareas "https://github.com/gniziemazity/leo/blob/main/code/TextArea.py"
click node_manager "https://github.com/gniziemazity/leo/blob/main/code/BlockManager.py"
click node_planfile "https://github.com/gniziemazity/leo/blob/main/plans/Demo.json"
click node_helpers "https://github.com/gniziemazity/leo/blob/main/code/Utils.py"
click node_ahk "https://github.com/gniziemazity/leo/blob/main/code/BlockManager.py"
click node_progress "https://github.com/gniziemazity/leo/blob/main/tmp/cnt.txt"
click node_sync "https://github.com/gniziemazity/leo/blob/main/tmp/sync.txt"
click node_safe "https://github.com/gniziemazity/leo/blob/main/tmp/safe_cnt.txt"
click node_loadstate "https://github.com/gniziemazity/leo/blob/main/tmp/last_load.txt"

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,node_topbar,node_sidebar toneBlue
class node_textareas,node_manager,node_planfile toneAmber
class node_helpers,node_ahk toneMint
class node_progress,node_sync,node_safe,node_loadstate toneRose
class node_user,node_editor toneIndigo
```

## Components

### Lesson interface

- [App startup](https://github.com/gniziemazity/leo/blob/main/code/Main.py): `code/Main.py`
- [Top controls](https://github.com/gniziemazity/leo/blob/main/code/TopBar.py): `code/TopBar.py`
- [Edit controls](https://github.com/gniziemazity/leo/blob/main/code/RightBar.py): `code/RightBar.py`

### Plan editing

- [Lesson blocks](https://github.com/gniziemazity/leo/blob/main/code/TextArea.py): `code/TextArea.py`
- [Block manager](https://github.com/gniziemazity/leo/blob/main/code/BlockManager.py): `code/BlockManager.py`
- [JSON lesson plan](https://github.com/gniziemazity/leo/blob/main/plans/Demo.json): `plans/Demo.json`

### Typing playback

- [Text helpers](https://github.com/gniziemazity/leo/blob/main/code/Utils.py): `code/Utils.py`
- [AutoHotkey runner](https://github.com/gniziemazity/leo/blob/main/code/BlockManager.py): `code/BlockManager.py`

### Progress coordination

- [Progress files](https://github.com/gniziemazity/leo/blob/main/tmp/cnt.txt): `tmp/cnt.txt`
- [Sync counter](https://github.com/gniziemazity/leo/blob/main/tmp/sync.txt): `tmp/sync.txt`
- [Safe counter](https://github.com/gniziemazity/leo/blob/main/tmp/safe_cnt.txt): `tmp/safe_cnt.txt`
- [Last-load path](https://github.com/gniziemazity/leo/blob/main/tmp/last_load.txt): `tmp/last_load.txt`

### Other components

- **Teacher**
- **Active code editor**

## Connections

- Teacher → App startup: opens
- App startup → Top controls: creates
- App startup → Edit controls: creates
- App startup → Block manager: creates
- Top controls → Block manager: invokes actions
- Edit controls → Block manager: invokes actions
- Block manager → Lesson blocks: creates and edits
- Block manager → JSON lesson plan: loads and saves
- Block manager → Last-load path: records path
- Block manager → Text helpers: counts and maps keys
- Block manager → Progress files: writes count
- Block manager → Sync counter: writes count
- AutoHotkey runner → Progress files: reads and updates
- AutoHotkey runner → Active code editor: types lesson
- Block manager → AutoHotkey runner: launches script
- Block manager → Safe counter: copies for reading
- Block manager → Safe counter: reads for highlighting
