# pcottle/learngitbranching architecture

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

- Interactive diagram: https://gitdiagram.com/pcottle/learngitbranching
- Repository: https://github.com/pcottle/learngitbranching

## Overview

LearnGitBranching is a client-side Git visualizer and learning game. A learner enters commands in the sandbox or a lesson; command handling applies simulated Git operations to an in-memory repository, and the visualization reflects the resulting commit graph. Lessons add goals, solution checking, progress, and level-building; the app also supports Mercurial mode, localization, and shareable command/tree state. Edges are limited to README workflow statements and relationships visible in the supplied excerpts or SOURCE INDEX; unsampled implementation details are not assumed.

Main entry points: [`src/js/level/index.js`](https://github.com/pcottle/learngitbranching/blob/main/src/js/level/index.js) (Lesson controller), [`src/js/app/index.js`](https://github.com/pcottle/learngitbranching/blob/main/src/js/app/index.js) (Application shell), [`src/js/commands/index.js`](https://github.com/pcottle/learngitbranching/blob/main/src/js/commands/index.js) (Command routing), [`src/js/git/index.js`](https://github.com/pcottle/learngitbranching/blob/main/src/js/git/index.js) (Git engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["App interaction"]
  node_app["Application shell<br/>[index.js]"]
  node_command_ui["Command interface<br/>[commandViews.js]"]
  node_sandbox["Sandbox mode<br/>[index.js]"]
end

subgraph group_simulation["Command simulation"]
  node_parser["Command routing<br/>[index.js]"]
  node_option_parser["Option parsing<br/>[optionParser.js]"]
  node_git_commands["Git commands<br/>[commands.js]"]
  node_git_engine["Git engine<br/>[index.js]"]
  node_graph_ops["Graph algorithms<br/>[treeCompare.js]"]
  node_hg_commands["Mercurial commands<br/>[commands.js]"]
end

subgraph group_learning["Lessons and progress"]
  node_lesson_controller["Lesson controller<br/>[index.js]"]
  node_level_store["Level and progress store<br/>[LevelStore.js]"]
  node_lesson_catalog["Lesson sequences<br/>[sequenceInfo.js]"]
  node_level_builder["Level builder<br/>[builder.js]"]
end

subgraph group_presentation["Visualization and support"]
  node_visualization["Commit visualization<br/>[visualization.js]"]
  node_visual_components["Graph drawing<br/>[index.js]"]
  node_dialogs["Dialogs and views<br/>[index.js]"]
  node_certificates["Completion certificates<br/>[certificateView.js]"]
  node_localization["Localization<br/>[index.js]"]
  node_share["Permalink sharing<br/>[sharing.js]"]
end

node_learner(("Learner"))

node_learner -->|"opens"| node_app
node_app -->|"initializes"| node_sandbox
node_app -->|"loads"| node_command_ui
node_learner -->|"enters commands"| node_command_ui
node_command_ui -.->|"submits commands"| node_parser
node_parser -->|"parses options"| node_option_parser
node_parser -->|"routes Git"| node_git_commands
node_parser -->|"routes Mercurial"| node_hg_commands
node_git_commands -.->|"applies operations"| node_git_engine
node_git_engine -->|"uses graph logic"| node_graph_ops
node_git_engine -.->|"updates repository view"| node_visualization
node_visualization -.->|"draws graph"| node_visual_components
node_learner -->|"starts lessons"| node_lesson_controller
node_lesson_controller -->|"loads progress and levels"| node_level_store
node_level_store -->|"reads sequences"| node_lesson_catalog
node_lesson_controller -->|"creates lesson view"| node_visualization
node_lesson_controller -->|"shows lesson dialogs"| node_dialogs
node_learner -->|"builds levels"| node_level_builder
node_level_builder -.->|"presents builder flow"| node_dialogs
node_lesson_controller -->|"offers completion"| node_certificates
node_learner -->|"shares permalinks"| node_share
node_app -->|"loads strings"| node_localization

click node_app "https://github.com/pcottle/learngitbranching/blob/main/src/js/app/index.js"
click node_command_ui "https://github.com/pcottle/learngitbranching/blob/main/src/js/views/commandViews.js"
click node_sandbox "https://github.com/pcottle/learngitbranching/blob/main/src/js/sandbox/index.js"
click node_parser "https://github.com/pcottle/learngitbranching/blob/main/src/js/commands/index.js"
click node_option_parser "https://github.com/pcottle/learngitbranching/blob/main/src/js/commands/optionParser.js"
click node_git_commands "https://github.com/pcottle/learngitbranching/blob/main/src/js/git/commands.js"
click node_git_engine "https://github.com/pcottle/learngitbranching/blob/main/src/js/git/index.js"
click node_graph_ops "https://github.com/pcottle/learngitbranching/blob/main/src/js/graph/treeCompare.js"
click node_hg_commands "https://github.com/pcottle/learngitbranching/blob/main/src/js/mercurial/commands.js"
click node_lesson_controller "https://github.com/pcottle/learngitbranching/blob/main/src/js/level/index.js"
click node_level_store "https://github.com/pcottle/learngitbranching/blob/main/src/js/stores/LevelStore.js"
click node_lesson_catalog "https://github.com/pcottle/learngitbranching/blob/main/src/levels/sequenceInfo.js"
click node_level_builder "https://github.com/pcottle/learngitbranching/blob/main/src/js/level/builder.js"
click node_visualization "https://github.com/pcottle/learngitbranching/blob/main/src/js/visuals/visualization.js"
click node_visual_components "https://github.com/pcottle/learngitbranching/blob/main/src/js/visuals/index.js"
click node_dialogs "https://github.com/pcottle/learngitbranching/blob/main/src/js/views/index.js"
click node_certificates "https://github.com/pcottle/learngitbranching/blob/main/src/js/views/certificateView.js"
click node_localization "https://github.com/pcottle/learngitbranching/blob/main/src/js/intl/index.js"
click node_share "https://github.com/pcottle/learngitbranching/blob/main/src/js/util/sharing.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_command_ui,node_sandbox toneBlue
class node_parser,node_option_parser,node_git_commands,node_git_engine,node_graph_ops,node_hg_commands toneAmber
class node_lesson_controller,node_level_store,node_lesson_catalog,node_level_builder toneMint
class node_visualization,node_visual_components,node_dialogs,node_certificates,node_localization,node_share toneRose
class node_learner toneIndigo
```

## Components

### App interaction

- [Application shell](https://github.com/pcottle/learngitbranching/blob/main/src/js/app/index.js): `src/js/app/index.js`
- [Command interface](https://github.com/pcottle/learngitbranching/blob/main/src/js/views/commandViews.js): `src/js/views/commandViews.js`
- [Sandbox mode](https://github.com/pcottle/learngitbranching/blob/main/src/js/sandbox/index.js): `src/js/sandbox/index.js`

### Command simulation

- [Command routing](https://github.com/pcottle/learngitbranching/blob/main/src/js/commands/index.js): `src/js/commands/index.js`
- [Option parsing](https://github.com/pcottle/learngitbranching/blob/main/src/js/commands/optionParser.js): `src/js/commands/optionParser.js`
- [Git commands](https://github.com/pcottle/learngitbranching/blob/main/src/js/git/commands.js): `src/js/git/commands.js`
- [Git engine](https://github.com/pcottle/learngitbranching/blob/main/src/js/git/index.js): `src/js/git/index.js`
- [Graph algorithms](https://github.com/pcottle/learngitbranching/blob/main/src/js/graph/treeCompare.js): `src/js/graph/treeCompare.js`
- [Mercurial commands](https://github.com/pcottle/learngitbranching/blob/main/src/js/mercurial/commands.js): `src/js/mercurial/commands.js`

### Lessons and progress

- [Lesson controller](https://github.com/pcottle/learngitbranching/blob/main/src/js/level/index.js): `src/js/level/index.js`
- [Level and progress store](https://github.com/pcottle/learngitbranching/blob/main/src/js/stores/LevelStore.js): `src/js/stores/LevelStore.js`
- [Lesson sequences](https://github.com/pcottle/learngitbranching/blob/main/src/levels/sequenceInfo.js): `src/levels/sequenceInfo.js`
- [Level builder](https://github.com/pcottle/learngitbranching/blob/main/src/js/level/builder.js): `src/js/level/builder.js`

### Visualization and support

- [Commit visualization](https://github.com/pcottle/learngitbranching/blob/main/src/js/visuals/visualization.js): `src/js/visuals/visualization.js`
- [Graph drawing](https://github.com/pcottle/learngitbranching/blob/main/src/js/visuals/index.js): `src/js/visuals/index.js`
- [Dialogs and views](https://github.com/pcottle/learngitbranching/blob/main/src/js/views/index.js): `src/js/views/index.js`
- [Completion certificates](https://github.com/pcottle/learngitbranching/blob/main/src/js/views/certificateView.js): `src/js/views/certificateView.js`
- [Localization](https://github.com/pcottle/learngitbranching/blob/main/src/js/intl/index.js): `src/js/intl/index.js`
- [Permalink sharing](https://github.com/pcottle/learngitbranching/blob/main/src/js/util/sharing.js): `src/js/util/sharing.js`

### Other components

- **Learner**

## Connections

- Learner → Application shell: opens (evidence: `README.md`)
- Application shell → Sandbox mode: initializes (evidence: `src/js/app/index.js`)
- Application shell → Command interface: loads (evidence: `src/js/app/index.js`)
- Learner → Command interface: enters commands (evidence: `README.md`)
- Command interface → Command routing: submits commands
- Command routing → Option parsing: parses options (evidence: `src/js/commands/index.js`)
- Command routing → Git commands: routes Git (evidence: `src/js/commands/index.js`)
- Command routing → Mercurial commands: routes Mercurial (evidence: `src/js/commands/index.js`)
- Git commands → Git engine: applies operations
- Git engine → Graph algorithms: uses graph logic (evidence: `src/js/git/index.js`)
- Git engine → Commit visualization: updates repository view
- Commit visualization → Graph drawing: draws graph
- Learner → Lesson controller: starts lessons (evidence: `README.md`)
- Lesson controller → Level and progress store: loads progress and levels (evidence: `src/js/level/index.js`)
- Level and progress store → Lesson sequences: reads sequences (evidence: `src/js/stores/LevelStore.js`)
- Lesson controller → Commit visualization: creates lesson view (evidence: `src/js/level/index.js`)
- Lesson controller → Dialogs and views: shows lesson dialogs (evidence: `src/js/level/index.js`)
- Learner → Level builder: builds levels (evidence: `README.md`)
- Level builder → Dialogs and views: presents builder flow
- Lesson controller → Completion certificates: offers completion (evidence: `src/js/level/index.js`)
- Learner → Permalink sharing: shares permalinks (evidence: `README.md`)
- Application shell → Localization: loads strings (evidence: `src/js/app/index.js`)
