# carsig/grep_learn architecture

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

- Interactive diagram: https://gitdiagram.com/carsig/grep_learn
- Repository: https://github.com/carsig/grep_learn

## Overview

Terminal Trainer is a browser-based command-line and Neovim practice environment. Learners choose a module, read lessons or reference material, enter commands or Vim keys, and have their result checked against a solution or simulated state. Its runtime combines a content registry and UI with a mock shell, command emulators, and mock files, processes, Git history, and AWS account. README statements establish the main wiring; source excerpts show shell and editor responsibilities, but not every dispatch, so unsampled links are omitted.

Main entry points: [`js/core/shell.js`](https://github.com/carsig/grep_learn/blob/main/js/core/shell.js) (Shell runtime), [`js/ui/app.js`](https://github.com/carsig/grep_learn/blob/main/js/ui/app.js) (Navigation and task UI), [`js/commands/git.js`](https://github.com/carsig/grep_learn/blob/main/js/commands/git.js) (Git emulator), [`js/ui/help.js`](https://github.com/carsig/grep_learn/blob/main/js/ui/help.js) (Command explainer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Learning experience"]
  node_app["Navigation and task UI<br/>[app.js]"]
  node_content["Lessons and tasks"]
  node_registry["Content registry<br/>[trainer.js]"]
  node_reference["Command reference<br/>[reference.js]"]
  node_help["Command explainer<br/>[help.js]"]
end

subgraph group_terminal["Terminal simulation"]
  node_shell["Shell runtime<br/>[shell.js]"]
  node_regex["Regex and glob helpers<br/>[regex.js]"]
  node_textcmd["Text commands<br/>[text.js]"]
  node_grep["grep command<br/>[grep.js]"]
  node_gitcmd["Git emulator<br/>[git.js]"]
  node_procs["Process commands<br/>[procs.js]"]
  node_awscmd["AWS emulator<br/>[aws.js]"]
end

subgraph group_state["Mock state"]
  node_files[("Mock files<br/>[files.js]")]
  node_processdata[("Mock processes<br/>[processes.js]")]
  node_repodata[("Mock Git history<br/>[repo.js]")]
  node_awsdata[("Mock AWS account<br/>[aws.js]")]
end

subgraph group_editor["Neovim emulator"]
  node_vimcore["Vim key engine<br/>[vim.js]"]
  node_editorui["Editor pane<br/>[editor.js]"]
end

node_learner(("Learner"))

node_learner -->|"uses"| node_app
node_app -->|"loads content"| node_registry
node_content -->|"registers lessons"| node_registry
node_app -->|"runs commands"| node_shell
node_app -->|"presents editor"| node_editorui
node_app -->|"shows reference"| node_reference
node_app -->|"opens help"| node_help
node_shell -->|"dispatches commands"| node_textcmd
node_shell -->|"dispatches commands"| node_grep
node_shell -->|"dispatches commands"| node_gitcmd
node_shell -->|"dispatches commands"| node_procs
node_shell -->|"dispatches commands"| node_awscmd
node_shell -->|"uses glob helper"| node_regex
node_grep -->|"builds patterns"| node_regex
node_gitcmd -->|"reads worktree"| node_files
node_gitcmd -->|"reads history"| node_repodata
node_procs -->|"uses process table"| node_processdata
node_awscmd -->|"loads account"| node_awsdata
node_shell -->|"uses mock files"| node_files
node_editorui -->|"renders and feeds"| node_vimcore
node_help -->|"reads command docs"| node_reference

click node_app "https://github.com/carsig/grep_learn/blob/main/js/ui/app.js"
click node_content "https://github.com/carsig/grep_learn/tree/main/content/modules"
click node_registry "https://github.com/carsig/grep_learn/blob/main/js/core/trainer.js"
click node_reference "https://github.com/carsig/grep_learn/blob/main/js/ui/reference.js"
click node_help "https://github.com/carsig/grep_learn/blob/main/js/ui/help.js"
click node_shell "https://github.com/carsig/grep_learn/blob/main/js/core/shell.js"
click node_regex "https://github.com/carsig/grep_learn/blob/main/js/core/regex.js"
click node_textcmd "https://github.com/carsig/grep_learn/blob/main/js/commands/text.js"
click node_grep "https://github.com/carsig/grep_learn/blob/main/js/commands/grep.js"
click node_gitcmd "https://github.com/carsig/grep_learn/blob/main/js/commands/git.js"
click node_procs "https://github.com/carsig/grep_learn/blob/main/js/commands/procs.js"
click node_awscmd "https://github.com/carsig/grep_learn/blob/main/js/commands/aws.js"
click node_files "https://github.com/carsig/grep_learn/blob/main/data/files.js"
click node_processdata "https://github.com/carsig/grep_learn/blob/main/data/processes.js"
click node_repodata "https://github.com/carsig/grep_learn/blob/main/data/repo.js"
click node_awsdata "https://github.com/carsig/grep_learn/blob/main/data/aws.js"
click node_vimcore "https://github.com/carsig/grep_learn/blob/main/js/vim/vim.js"
click node_editorui "https://github.com/carsig/grep_learn/blob/main/js/vim/editor.js"

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_app,node_content,node_registry,node_reference,node_help toneBlue
class node_shell,node_regex,node_textcmd,node_grep,node_gitcmd,node_procs,node_awscmd toneAmber
class node_files,node_processdata,node_repodata,node_awsdata toneMint
class node_vimcore,node_editorui toneRose
class node_learner toneIndigo
```

## Components

### Learning experience

- [Navigation and task UI](https://github.com/carsig/grep_learn/blob/main/js/ui/app.js): `js/ui/app.js`
- [Lessons and tasks](https://github.com/carsig/grep_learn/tree/main/content/modules): `content/modules`
- [Content registry](https://github.com/carsig/grep_learn/blob/main/js/core/trainer.js): `js/core/trainer.js`
- [Command reference](https://github.com/carsig/grep_learn/blob/main/js/ui/reference.js): `js/ui/reference.js`
- [Command explainer](https://github.com/carsig/grep_learn/blob/main/js/ui/help.js): `js/ui/help.js`

### Terminal simulation

- [Shell runtime](https://github.com/carsig/grep_learn/blob/main/js/core/shell.js): `js/core/shell.js`
- [Regex and glob helpers](https://github.com/carsig/grep_learn/blob/main/js/core/regex.js): `js/core/regex.js`
- [Text commands](https://github.com/carsig/grep_learn/blob/main/js/commands/text.js): `js/commands/text.js`
- [grep command](https://github.com/carsig/grep_learn/blob/main/js/commands/grep.js): `js/commands/grep.js`
- [Git emulator](https://github.com/carsig/grep_learn/blob/main/js/commands/git.js): `js/commands/git.js`
- [Process commands](https://github.com/carsig/grep_learn/blob/main/js/commands/procs.js): `js/commands/procs.js`
- [AWS emulator](https://github.com/carsig/grep_learn/blob/main/js/commands/aws.js): `js/commands/aws.js`

### Mock state

- [Mock files](https://github.com/carsig/grep_learn/blob/main/data/files.js): `data/files.js`
- [Mock processes](https://github.com/carsig/grep_learn/blob/main/data/processes.js): `data/processes.js`
- [Mock Git history](https://github.com/carsig/grep_learn/blob/main/data/repo.js): `data/repo.js`
- [Mock AWS account](https://github.com/carsig/grep_learn/blob/main/data/aws.js): `data/aws.js`

### Neovim emulator

- [Vim key engine](https://github.com/carsig/grep_learn/blob/main/js/vim/vim.js): `js/vim/vim.js`
- [Editor pane](https://github.com/carsig/grep_learn/blob/main/js/vim/editor.js): `js/vim/editor.js`

### Other components

- **Learner**

## Connections

- Learner → Navigation and task UI: uses
- Navigation and task UI → Content registry: loads content
- Lessons and tasks → Content registry: registers lessons
- Navigation and task UI → Shell runtime: runs commands
- Navigation and task UI → Editor pane: presents editor
- Navigation and task UI → Command reference: shows reference
- Navigation and task UI → Command explainer: opens help
- Shell runtime → Text commands: dispatches commands
- Shell runtime → grep command: dispatches commands
- Shell runtime → Git emulator: dispatches commands
- Shell runtime → Process commands: dispatches commands
- Shell runtime → AWS emulator: dispatches commands
- Shell runtime → Regex and glob helpers: uses glob helper (evidence: `js/core/shell.js`)
- grep command → Regex and glob helpers: builds patterns
- Git emulator → Mock files: reads worktree (evidence: `js/commands/git.js`)
- Git emulator → Mock Git history: reads history (evidence: `js/commands/git.js`)
- Process commands → Mock processes: uses process table
- AWS emulator → Mock AWS account: loads account
- Shell runtime → Mock files: uses mock files
- Editor pane → Vim key engine: renders and feeds (evidence: `js/vim/editor.js`)
- Command explainer → Command reference: reads command docs (evidence: `js/ui/help.js`)
