# jackstanton6/alice_tokenizer architecture

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

- Interactive diagram: https://gitdiagram.com/jackstanton6/alice_tokenizer
- Repository: https://github.com/jackstanton6/alice_tokenizer

## Overview

alice_tokenizer is a Python byte-pair tokenizer with two main workflows: build a vocabulary from a text file, then encode, decode, and visualize text through the Python API or interactive CLI. Training handles optional GPT-2-style pretokenization and vocabulary saving; the CLI also offers help and sample tests. The source index identifies the built-in vocabulary as a substantial core module, but it was not excerpted, so its internal structure and loading details are not expanded here.

Main entry points: [`src/alice_tokenizer/tokenisation.py`](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/tokenisation.py) (Tokenizer), [`src/alice_tokenizer/cli/terminal.py`](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/cli/terminal.py) (Interactive terminal), [`src/alice_tokenizer/train_tokeniser.py`](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/train_tokeniser.py) (BPE training), [`src/alice_tokenizer/cli/main.py`](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/cli/main.py) (CLI entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Vocabulary building"]
  node_training["BPE training<br/>[train_tokeniser.py]"]
  node_dataset["Training text"]
  node_vocabfile["Saved vocabulary"]
end

subgraph group_runtime["Tokenization runtime"]
  node_api["Public API<br/>[__init__.py]"]
  node_tokeniser["Tokenizer<br/>[tokenisation.py]"]
end

subgraph group_cli["Interactive CLI"]
  node_terminal["Interactive terminal<br/>[terminal.py]"]
  node_entry["CLI entry point<br/>[main.py]"]
end

subgraph group_assets["Tokenizer resources"]
  node_defaultvocab[("Built-in vocabulary<br/>[vocab.py]")]
  node_logo["Logo<br/>[logo.py]"]
  node_help["CLI help text<br/>[helpfile.py]"]
end

node_user(("Python or CLI user"))

node_user -->|"calls"| node_api
node_api -->|"exports"| node_tokeniser
node_user -->|"runs"| node_entry
node_entry -->|"starts"| node_terminal
node_entry -->|"configures"| node_tokeniser
node_terminal -->|"invokes"| node_tokeniser
node_terminal -->|"prints"| node_help
node_terminal -->|"prints"| node_logo
node_user -->|"provides"| node_dataset
node_tokeniser -->|"reads"| node_dataset
node_tokeniser -->|"delegates training"| node_training
node_training -->|"writes"| node_vocabfile
node_tokeniser -->|"loads"| node_defaultvocab
node_training -.->|"builds merges"| node_defaultvocab

click node_api "https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/__init__.py"
click node_tokeniser "https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/tokenisation.py"
click node_training "https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/train_tokeniser.py"
click node_defaultvocab "https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/util/vocab.py"
click node_logo "https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/util/logo.py"
click node_terminal "https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/cli/terminal.py"
click node_entry "https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/cli/main.py"
click node_help "https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/util/helpfile.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_training,node_dataset,node_vocabfile,node_user toneBlue
class node_api,node_tokeniser toneAmber
class node_terminal,node_entry toneMint
class node_defaultvocab,node_logo,node_help toneRose
```

## Components

### Vocabulary building

- [BPE training](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/train_tokeniser.py): `src/alice_tokenizer/train_tokeniser.py`
- **Training text**
- **Saved vocabulary**

### Tokenization runtime

- [Public API](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/__init__.py): `src/alice_tokenizer/__init__.py`
- [Tokenizer](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/tokenisation.py): `src/alice_tokenizer/tokenisation.py`

### Interactive CLI

- [Interactive terminal](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/cli/terminal.py): `src/alice_tokenizer/cli/terminal.py`
- [CLI entry point](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/cli/main.py): `src/alice_tokenizer/cli/main.py`

### Tokenizer resources

- [Built-in vocabulary](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/util/vocab.py): `src/alice_tokenizer/util/vocab.py`
- [Logo](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/util/logo.py): `src/alice_tokenizer/util/logo.py`
- [CLI help text](https://github.com/jackstanton6/alice_tokenizer/blob/main/src/alice_tokenizer/util/helpfile.py): `src/alice_tokenizer/util/helpfile.py`

### Other components

- **Python or CLI user**

## Connections

- Python or CLI user → Public API: calls (evidence: `README.md`)
- Public API → Tokenizer: exports (evidence: `src/alice_tokenizer/__init__.py`)
- Python or CLI user → CLI entry point: runs (evidence: `README.md`)
- CLI entry point → Interactive terminal: starts (evidence: `src/alice_tokenizer/cli/main.py`)
- CLI entry point → Tokenizer: configures (evidence: `src/alice_tokenizer/cli/main.py`)
- Interactive terminal → Tokenizer: invokes (evidence: `src/alice_tokenizer/cli/terminal.py`)
- Interactive terminal → CLI help text: prints (evidence: `src/alice_tokenizer/cli/terminal.py`)
- Interactive terminal → Logo: prints (evidence: `src/alice_tokenizer/cli/terminal.py`)
- Python or CLI user → Training text: provides (evidence: `README.md`)
- Tokenizer → Training text: reads (evidence: `README.md`)
- Tokenizer → BPE training: delegates training (evidence: `src/alice_tokenizer/tokenisation.py`)
- BPE training → Saved vocabulary: writes (evidence: `README.md`)
- Tokenizer → Built-in vocabulary: loads (evidence: `src/alice_tokenizer/tokenisation.py`)
- BPE training → Built-in vocabulary: builds merges
