# wiegerw/gambatools architecture

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

- Interactive diagram: https://gitdiagram.com/wiegerw/gambatools
- Repository: https://github.com/wiegerw/gambatools

## Overview

GAMBA tools is an educational formal-language library and notebook exercise toolkit. The principal workflow is to enter a formal-language answer, parse it into a model, generate or analyze its language, and receive checking feedback. The graph includes the major automata, grammar, regex, and Turing-machine domains, plus notebook exercises and the shared language-generation layer. Relationships reflect excerpts, SOURCE INDEX references, or README statements; some notebook capabilities are documented but their full implementations were not sampled.

Main entry points: [`src/gambatools/notebook.py`](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/notebook.py) (Exercise checking), [`src/gambatools/language_generator.py`](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/language_generator.py) (Language generation), [`src/gambatools/dfa_algorithms.py`](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/dfa_algorithms.py) (DFA operations), [`src/gambatools/nfa_algorithms.py`](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/nfa_algorithms.py) (NFA operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_models["Language models"]
  node_automaton_model["Automaton model<br/>[automaton.py]"]
  node_dfa["DFA<br/>[dfa.py]"]
  node_nfa["NFA<br/>[nfa.py]"]
  node_pda["PDA<br/>[pda.py]"]
  node_tm["Turing machine<br/>[tm.py]"]
  node_cfg["Grammar<br/>[cfg.py]"]
  node_regexp["Regular expression<br/>[regexp.py]"]
end

subgraph group_analysis["Algorithms and analysis"]
  node_automaton_ops["Automaton operations"]
  node_dfa_ops["DFA operations<br/>[dfa_algorithms.py]"]
  node_nfa_ops["NFA operations<br/>[nfa_algorithms.py]"]
  node_pda_ops["PDA operations<br/>[pda_algorithms.py]"]
  node_tm_ops["TM operations<br/>[tm_algorithms.py]"]
  node_cfg_ops["Grammar operations<br/>[cfg_algorithms.py]"]
  node_regexp_ops["Regex operations"]
  node_language_generation["Language generation"]
end

subgraph group_input["Parsing and input"]
  node_automaton_input["Automaton input"]
  node_grammar_input["Grammar input<br/>[cfg_parser.py]"]
  node_regex_input["Regex input<br/>[regexp_parser.py]"]
end

subgraph group_learning["Notebook learning"]
  node_notebook_helpers["Exercise checking<br/>[notebook.py]"]
  node_notebook_exercises["Exercise modules<br/>[notebook_dfa.py]"]
  node_notebook_generator["Notebook exercises<br/>[notebook_cfg.py]"]
end

node_learner(("Learner"))

node_learner -->|"submits answers"| node_notebook_helpers
node_learner -->|"practises with"| node_notebook_exercises
node_notebook_exercises -->|"uses checking"| node_notebook_helpers
node_notebook_helpers -->|"generates words"| node_language_generation
node_notebook_helpers -->|"parses automata"| node_automaton_input
node_automaton_input -->|"builds model"| node_automaton_model
node_grammar_input -->|"builds grammar"| node_cfg
node_regex_input -->|"builds expression"| node_regexp
node_language_generation -->|"dispatches generation"| node_dfa_ops
node_language_generation -->|"dispatches generation"| node_nfa_ops
node_language_generation -->|"dispatches generation"| node_pda_ops
node_language_generation -->|"dispatches generation"| node_tm_ops
node_language_generation -->|"dispatches generation"| node_cfg_ops
node_language_generation -->|"dispatches generation"| node_regexp_ops
node_nfa_ops -->|"constructs DFA"| node_dfa
node_dfa_ops -->|"uses operations"| node_automaton_ops
node_notebook_helpers -->|"parses grammar"| node_grammar_input
node_notebook_helpers -->|"parses regex"| node_regex_input
node_notebook_helpers -->|"supports exercises"| node_notebook_generator
node_notebook_generator -->|"uses checking"| node_notebook_helpers

click node_automaton_model "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/automaton.py"
click node_dfa "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/dfa.py"
click node_nfa "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/nfa.py"
click node_pda "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/pda.py"
click node_tm "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/tm.py"
click node_cfg "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/cfg.py"
click node_regexp "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/regexp.py"
click node_automaton_ops "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/automaton_algorithms.py"
click node_dfa_ops "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/dfa_algorithms.py"
click node_nfa_ops "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/nfa_algorithms.py"
click node_pda_ops "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/pda_algorithms.py"
click node_tm_ops "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/tm_algorithms.py"
click node_cfg_ops "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/cfg_algorithms.py"
click node_regexp_ops "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/regexp_algorithms.py"
click node_language_generation "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/language_generator.py"
click node_automaton_input "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/automaton_algorithms.py"
click node_grammar_input "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/cfg_parser.py"
click node_regex_input "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/regexp_parser.py"
click node_notebook_helpers "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/notebook.py"
click node_notebook_exercises "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/notebook_dfa.py"
click node_notebook_generator "https://github.com/wiegerw/gambatools/blob/main/src/gambatools/notebook_cfg.py"

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_automaton_model,node_dfa,node_nfa,node_pda,node_tm,node_cfg,node_regexp toneBlue
class node_automaton_ops,node_dfa_ops,node_nfa_ops,node_pda_ops,node_tm_ops,node_cfg_ops,node_regexp_ops,node_language_generation toneAmber
class node_automaton_input,node_grammar_input,node_regex_input toneMint
class node_notebook_helpers,node_notebook_exercises,node_notebook_generator toneRose
class node_learner toneIndigo
```

## Components

### Language models

- [Automaton model](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/automaton.py): `src/gambatools/automaton.py`
- [DFA](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/dfa.py): `src/gambatools/dfa.py`
- [NFA](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/nfa.py): `src/gambatools/nfa.py`
- [PDA](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/pda.py): `src/gambatools/pda.py`
- [Turing machine](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/tm.py): `src/gambatools/tm.py`
- [Grammar](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/cfg.py): `src/gambatools/cfg.py`
- [Regular expression](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/regexp.py): `src/gambatools/regexp.py`

### Algorithms and analysis

- [Automaton operations](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/automaton_algorithms.py): `src/gambatools/automaton_algorithms.py`
- [DFA operations](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/dfa_algorithms.py): `src/gambatools/dfa_algorithms.py`
- [NFA operations](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/nfa_algorithms.py): `src/gambatools/nfa_algorithms.py`
- [PDA operations](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/pda_algorithms.py): `src/gambatools/pda_algorithms.py`
- [TM operations](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/tm_algorithms.py): `src/gambatools/tm_algorithms.py`
- [Grammar operations](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/cfg_algorithms.py): `src/gambatools/cfg_algorithms.py`
- [Regex operations](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/regexp_algorithms.py): `src/gambatools/regexp_algorithms.py`
- [Language generation](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/language_generator.py): `src/gambatools/language_generator.py`

### Parsing and input

- [Automaton input](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/automaton_algorithms.py): `src/gambatools/automaton_algorithms.py`
- [Grammar input](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/cfg_parser.py): `src/gambatools/cfg_parser.py`
- [Regex input](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/regexp_parser.py): `src/gambatools/regexp_parser.py`

### Notebook learning

- [Exercise checking](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/notebook.py): `src/gambatools/notebook.py`
- [Exercise modules](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/notebook_dfa.py): `src/gambatools/notebook_dfa.py`
- [Notebook exercises](https://github.com/wiegerw/gambatools/blob/main/src/gambatools/notebook_cfg.py): `src/gambatools/notebook_cfg.py`

### Other components

- **Learner**

## Connections

- Learner → Exercise checking: submits answers
- Learner → Exercise modules: practises with
- Exercise modules → Exercise checking: uses checking (evidence: `src/gambatools/notebook_dfa.py`)
- Exercise checking → Language generation: generates words (evidence: `src/gambatools/notebook.py`)
- Exercise checking → Automaton input: parses automata (evidence: `src/gambatools/notebook.py`)
- Automaton input → Automaton model: builds model (evidence: `src/gambatools/automaton_algorithms.py`)
- Grammar input → Grammar: builds grammar (evidence: `src/gambatools/cfg_parser.py`)
- Regex input → Regular expression: builds expression (evidence: `src/gambatools/regexp_parser.py`)
- Language generation → DFA operations: dispatches generation (evidence: `src/gambatools/language_generator.py`)
- Language generation → NFA operations: dispatches generation (evidence: `src/gambatools/language_generator.py`)
- Language generation → PDA operations: dispatches generation (evidence: `src/gambatools/language_generator.py`)
- Language generation → TM operations: dispatches generation (evidence: `src/gambatools/language_generator.py`)
- Language generation → Grammar operations: dispatches generation (evidence: `src/gambatools/language_generator.py`)
- Language generation → Regex operations: dispatches generation (evidence: `src/gambatools/language_generator.py`)
- NFA operations → DFA: constructs DFA (evidence: `src/gambatools/nfa_algorithms.py`)
- DFA operations → Automaton operations: uses operations (evidence: `src/gambatools/dfa_algorithms.py`)
- Exercise checking → Grammar input: parses grammar (evidence: `src/gambatools/notebook.py`)
- Exercise checking → Regex input: parses regex (evidence: `src/gambatools/notebook.py`)
- Exercise checking → Notebook exercises: supports exercises (evidence: `src/gambatools/notebook_cfg.py`)
- Notebook exercises → Exercise checking: uses checking (evidence: `src/gambatools/notebook_cfg.py`)
