# thanas-fuqi/brookshearmachine_py architecture

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

- Interactive diagram: https://gitdiagram.com/thanas-fuqi/brookshearmachine_py
- Repository: https://github.com/thanas-fuqi/brookshearmachine_py

## Overview

This repository is a Brookshear machine emulator plus raw-hex example programs, including interactive and visual demos. The main workflow is to create a Machine, load a hex program, and run its fetch/decode/execute loop; programs may register custom display opcodes that render machine state. The graph includes all indexed core programs and documented debug tools. Relationships are based on the excerpts and README; unsampled README-listed features are represented at their documented directory paths.

Main entry points: [`Machine_language_CORE.py`](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py) (Fetch and execute), [`Pong/Pong_ML.py`](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Pong/Pong_ML.py) (Pong program), [`Snake/Snake_ML.py`](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Snake/Snake_ML.py) (Snake program), [`7_Segment_Display/ML_Hexadecimal.py`](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/7_Segment_Display/ML_Hexadecimal.py) (7-segment program)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_emulator["Machine emulator"]
  node_machine["Machine runtime"]
  node_loader["Hex loader"]
  node_execution["Fetch and execute"]
  node_isa["Instruction set"]
  node_state[("RAM and registers")]
  node_debug["Debug dumps"]
end

subgraph group_demos["Visual demos"]
  node_display7["7-segment program<br/>[ML_Hexadecimal.py]"]
  node_life["Conway's Life"]
  node_sort["Sorting visualizer<br/>[Sort_ML.py]"]
  node_wave["Wave animation<br/>[ML_Wave_Loop.py]"]
  node_hexcap["Hex display capability"]
  node_life_cap["Life capability"]
  node_sort_cap["Sort capability"]
  node_wave_cap["Wave capability"]
end

subgraph group_interactive["Interactive games"]
  node_pong["Pong program<br/>[Pong_ML.py]"]
  node_snake["Snake program<br/>[Snake_ML.py]"]
  node_pong_cap["Pong capability"]
  node_snake_cap["Snake capability"]
end

subgraph group_examples["Example programs"]
  node_basic["Basic diagnostic"]
end

node_user(("Program runner"))
node_terminal(("Terminal"))
node_keyboard(("Keyboard input"))

node_user -->|"runs"| node_display7
node_user -->|"runs"| node_life
node_user -->|"runs"| node_pong
node_user -->|"runs"| node_snake
node_user -->|"runs"| node_sort
node_user -->|"runs"| node_wave
node_user -->|"runs"| node_basic
node_display7 -->|"loads hex"| node_loader
node_life -->|"loads hex"| node_loader
node_pong -->|"loads hex"| node_loader
node_snake -->|"loads hex"| node_loader
node_sort -->|"loads hex"| node_loader
node_wave -->|"loads hex"| node_loader
node_basic -->|"loads hex"| node_loader
node_loader -->|"writes program"| node_state
node_display7 -->|"creates and runs"| node_machine
node_life -->|"creates and runs"| node_machine
node_pong -->|"creates and runs"| node_machine
node_snake -->|"creates and runs"| node_machine
node_sort -->|"creates and runs"| node_machine
node_wave -->|"creates and runs"| node_machine
node_basic -->|"creates and runs"| node_machine
node_machine -->|"runs"| node_execution
node_execution -->|"fetches and updates"| node_state
node_execution -->|"dispatches opcode"| node_isa
node_machine -->|"provides dumps"| node_debug
node_display7 -->|"registers display opcode"| node_execution
node_life -->|"registers display opcode"| node_execution
node_pong -->|"registers display opcode"| node_execution
node_snake -->|"registers display opcode"| node_execution
node_sort -->|"registers display opcode"| node_execution
node_wave -->|"registers display opcode"| node_execution
node_execution -->|"logs output"| node_terminal
node_display7 -->|"renders frames"| node_terminal
node_life -->|"renders frames"| node_terminal
node_pong -->|"renders game"| node_terminal
node_snake -->|"renders game"| node_terminal
node_sort -->|"renders bars"| node_terminal
node_wave -->|"renders frames"| node_terminal
node_keyboard -->|"provides keys"| node_pong
node_keyboard -->|"provides keys"| node_snake
node_display7 -->|"implements"| node_hexcap
node_life -->|"implements"| node_life_cap
node_pong -->|"implements"| node_pong_cap
node_snake -->|"implements"| node_snake_cap
node_sort -->|"implements"| node_sort_cap
node_wave -->|"implements"| node_wave_cap

click node_machine "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py"
click node_loader "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py"
click node_execution "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py"
click node_isa "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py"
click node_state "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py"
click node_debug "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py"
click node_display7 "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/7_Segment_Display/ML_Hexadecimal.py"
click node_life "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Conways_Game_Of_Life/Cellular_Automata_ML.py"
click node_sort "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Sort/Sort_ML.py"
click node_wave "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Wave_Animation/ML_Wave_Loop.py"
click node_pong "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Pong/Pong_ML.py"
click node_snake "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Snake/Snake_ML.py"
click node_basic "https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Simple_Examples/Machine_language_BASIC.py"
click node_hexcap "https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/7_Segment_Display"
click node_life_cap "https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/Conways_Game_Of_Life"
click node_pong_cap "https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/Pong"
click node_snake_cap "https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/Snake"
click node_sort_cap "https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/Sort"
click node_wave_cap "https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/Wave_Animation"

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_machine,node_loader,node_execution,node_isa,node_state,node_debug toneBlue
class node_display7,node_life,node_sort,node_wave,node_hexcap,node_life_cap,node_sort_cap,node_wave_cap toneAmber
class node_pong,node_snake,node_pong_cap,node_snake_cap toneMint
class node_basic toneRose
class node_user,node_terminal,node_keyboard toneIndigo
```

## Components

### Machine emulator

- [Machine runtime](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py): `Machine_language_CORE.py`
- [Hex loader](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py): `Machine_language_CORE.py`
- [Fetch and execute](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py): `Machine_language_CORE.py`
- [Instruction set](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py): `Machine_language_CORE.py`
- [RAM and registers](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py): `Machine_language_CORE.py`
- [Debug dumps](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Machine_language_CORE.py): `Machine_language_CORE.py`

### Visual demos

- [7-segment program](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/7_Segment_Display/ML_Hexadecimal.py): `7_Segment_Display/ML_Hexadecimal.py`
- [Conway's Life](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Conways_Game_Of_Life/Cellular_Automata_ML.py): `Conways_Game_Of_Life/Cellular_Automata_ML.py`
- [Sorting visualizer](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Sort/Sort_ML.py): `Sort/Sort_ML.py`
- [Wave animation](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Wave_Animation/ML_Wave_Loop.py): `Wave_Animation/ML_Wave_Loop.py`
- [Hex display capability](https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/7_Segment_Display): `7_Segment_Display`
- [Life capability](https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/Conways_Game_Of_Life): `Conways_Game_Of_Life`
- [Sort capability](https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/Sort): `Sort`
- [Wave capability](https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/Wave_Animation): `Wave_Animation`

### Interactive games

- [Pong program](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Pong/Pong_ML.py): `Pong/Pong_ML.py`
- [Snake program](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Snake/Snake_ML.py): `Snake/Snake_ML.py`
- [Pong capability](https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/Pong): `Pong`
- [Snake capability](https://github.com/thanas-fuqi/brookshearmachine_py/tree/main/Snake): `Snake`

### Example programs

- [Basic diagnostic](https://github.com/thanas-fuqi/brookshearmachine_py/blob/main/Simple_Examples/Machine_language_BASIC.py): `Simple_Examples/Machine_language_BASIC.py`

### Other components

- **Program runner**
- **Terminal**
- **Keyboard input**

## Connections

- Program runner → 7-segment program: runs (evidence: `7_Segment_Display/ML_Hexadecimal.py`)
- Program runner → Conway's Life: runs (evidence: `Conways_Game_Of_Life/Cellular_Automata_ML.py`)
- Program runner → Pong program: runs (evidence: `Pong/Pong_ML.py`)
- Program runner → Snake program: runs (evidence: `Snake/Snake_ML.py`)
- Program runner → Sorting visualizer: runs (evidence: `Sort/Sort_ML.py`)
- Program runner → Wave animation: runs (evidence: `Wave_Animation/ML_Wave_Loop.py`)
- Program runner → Basic diagnostic: runs (evidence: `Simple_Examples/Machine_language_BASIC.py`)
- 7-segment program → Hex loader: loads hex (evidence: `7_Segment_Display/ML_Hexadecimal.py`)
- Conway's Life → Hex loader: loads hex (evidence: `Conways_Game_Of_Life/Cellular_Automata_ML.py`)
- Pong program → Hex loader: loads hex (evidence: `Pong/Pong_ML.py`)
- Snake program → Hex loader: loads hex (evidence: `Snake/Snake_ML.py`)
- Sorting visualizer → Hex loader: loads hex (evidence: `Sort/Sort_ML.py`)
- Wave animation → Hex loader: loads hex (evidence: `Wave_Animation/ML_Wave_Loop.py`)
- Basic diagnostic → Hex loader: loads hex (evidence: `Simple_Examples/Machine_language_BASIC.py`)
- Hex loader → RAM and registers: writes program (evidence: `Machine_language_CORE.py`)
- 7-segment program → Machine runtime: creates and runs (evidence: `7_Segment_Display/ML_Hexadecimal.py`)
- Conway's Life → Machine runtime: creates and runs (evidence: `Conways_Game_Of_Life/Cellular_Automata_ML.py`)
- Pong program → Machine runtime: creates and runs (evidence: `Pong/Pong_ML.py`)
- Snake program → Machine runtime: creates and runs (evidence: `Snake/Snake_ML.py`)
- Sorting visualizer → Machine runtime: creates and runs (evidence: `Sort/Sort_ML.py`)
- Wave animation → Machine runtime: creates and runs (evidence: `Wave_Animation/ML_Wave_Loop.py`)
- Basic diagnostic → Machine runtime: creates and runs (evidence: `Simple_Examples/Machine_language_BASIC.py`)
- Machine runtime → Fetch and execute: runs (evidence: `Machine_language_CORE.py`)
- Fetch and execute → RAM and registers: fetches and updates (evidence: `Machine_language_CORE.py`)
- Fetch and execute → Instruction set: dispatches opcode (evidence: `Machine_language_CORE.py`)
- Machine runtime → Debug dumps: provides dumps (evidence: `README.md`)
- 7-segment program → Fetch and execute: registers display opcode (evidence: `7_Segment_Display/ML_Hexadecimal.py`)
- Conway's Life → Fetch and execute: registers display opcode (evidence: `Conways_Game_Of_Life/Cellular_Automata_ML.py`)
- Pong program → Fetch and execute: registers display opcode (evidence: `Pong/Pong_ML.py`)
- Snake program → Fetch and execute: registers display opcode (evidence: `Snake/Snake_ML.py`)
- Sorting visualizer → Fetch and execute: registers display opcode (evidence: `Sort/Sort_ML.py`)
- Wave animation → Fetch and execute: registers display opcode (evidence: `Wave_Animation/ML_Wave_Loop.py`)
- Fetch and execute → Terminal: logs output (evidence: `Machine_language_CORE.py`)
- 7-segment program → Terminal: renders frames (evidence: `7_Segment_Display/ML_Hexadecimal.py`)
- Conway's Life → Terminal: renders frames (evidence: `Conways_Game_Of_Life/Cellular_Automata_ML.py`)
- Pong program → Terminal: renders game (evidence: `Pong/Pong_ML.py`)
- Snake program → Terminal: renders game (evidence: `Snake/Snake_ML.py`)
- Sorting visualizer → Terminal: renders bars (evidence: `Sort/Sort_ML.py`)
- Wave animation → Terminal: renders frames (evidence: `Wave_Animation/ML_Wave_Loop.py`)
- Keyboard input → Pong program: provides keys (evidence: `Pong/Pong_ML.py`)
- Keyboard input → Snake program: provides keys (evidence: `Snake/Snake_ML.py`)
- 7-segment program → Hex display capability: implements (evidence: `README.md`)
- Conway's Life → Life capability: implements (evidence: `README.md`)
- Pong program → Pong capability: implements (evidence: `README.md`)
- Snake program → Snake capability: implements (evidence: `README.md`)
- Sorting visualizer → Sort capability: implements (evidence: `README.md`)
- Wave animation → Wave capability: implements (evidence: `README.md`)
