# esteban-crln/git-train architecture

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

- Interactive diagram: https://gitdiagram.com/esteban-crln/git-train
- Repository: https://github.com/esteban-crln/git-train

## Overview

This is a browser-based Git teaching simulator: users enter Git-like or shell commands, the simulator updates an immutable JSON state, and the UI presents command output, commit history, and Git zones. The parser dispatches specialized remote, history-rewrite, stash, and tag commands; the engine supplies shared repository behavior. The README documents broader command coverage than the sampled excerpts, so those capabilities are represented at subsystem level. Edges reflect shown calls/import references or README statements; unsampled details are not inferred.

Main entry points: [`js/main.js`](https://github.com/esteban-crln/git-train/blob/main/js/main.js) (App coordinator), [`js/parser.js`](https://github.com/esteban-crln/git-train/blob/main/js/parser.js) (Command parser), [`js/engine.js`](https://github.com/esteban-crln/git-train/blob/main/js/engine.js) (Git state engine), [`js/terminal.js`](https://github.com/esteban-crln/git-train/blob/main/js/terminal.js) (Command terminal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Browser interface"]
  node_app["App coordinator<br/>[main.js]"]
  node_terminal["Command terminal<br/>[terminal.js]"]
end

subgraph group_core["Git simulation"]
  node_parser["Command parser<br/>[parser.js]"]
  node_engine["Git state engine<br/>[engine.js]"]
end

subgraph group_extensions["History features"]
  node_rewrite["History rewriting<br/>[rewrite.js]"]
  node_stash["Stash operations<br/>[stash.js]"]
  node_tags["Tag operations<br/>[tags.js]"]
end

subgraph group_remote["Remote simulation"]
  node_remote["Remote and forge<br/>[remote.js]"]
end

subgraph group_display["State display"]
  node_graph["Commit graph<br/>[graph.js]"]
  node_zones["Git zones panel<br/>[main.js]"]
end

node_user(("Learner"))
node_browserstore[("Browser storage")]

node_user -->|"enters commands"| node_terminal
node_terminal -->|"submits input"| node_app
node_app -->|"executes commands"| node_parser
node_parser -->|"dispatches Git commands"| node_engine
node_parser -->|"dispatches remote commands"| node_remote
node_parser -->|"dispatches rewrite commands"| node_rewrite
node_parser -->|"dispatches stash commands"| node_stash
node_parser -->|"dispatches tag commands"| node_tags
node_remote -->|"uses shared state helpers"| node_engine
node_rewrite -->|"uses merge and state helpers"| node_engine
node_stash -->|"uses repository helpers"| node_engine
node_tags -->|"uses repository helpers"| node_engine
node_app -->|"reads and updates state"| node_engine
node_app -->|"renders command output"| node_terminal
node_app -->|"renders commit graph"| node_graph
node_graph -->|"reads commit data"| node_engine
node_app -->|"renders Git zones"| node_zones
node_app -->|"saves simulator state"| node_browserstore

click node_app "https://github.com/esteban-crln/git-train/blob/main/js/main.js"
click node_terminal "https://github.com/esteban-crln/git-train/blob/main/js/terminal.js"
click node_parser "https://github.com/esteban-crln/git-train/blob/main/js/parser.js"
click node_engine "https://github.com/esteban-crln/git-train/blob/main/js/engine.js"
click node_rewrite "https://github.com/esteban-crln/git-train/blob/main/js/rewrite.js"
click node_stash "https://github.com/esteban-crln/git-train/blob/main/js/stash.js"
click node_tags "https://github.com/esteban-crln/git-train/blob/main/js/tags.js"
click node_remote "https://github.com/esteban-crln/git-train/blob/main/js/remote.js"
click node_graph "https://github.com/esteban-crln/git-train/blob/main/js/graph.js"
click node_zones "https://github.com/esteban-crln/git-train/blob/main/js/main.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_terminal toneBlue
class node_parser,node_engine,node_browserstore toneAmber
class node_rewrite,node_stash,node_tags toneMint
class node_remote toneRose
class node_graph,node_zones,node_user toneIndigo
```

## Components

### Browser interface

- [App coordinator](https://github.com/esteban-crln/git-train/blob/main/js/main.js): `js/main.js`
- [Command terminal](https://github.com/esteban-crln/git-train/blob/main/js/terminal.js): `js/terminal.js`

### Git simulation

- [Command parser](https://github.com/esteban-crln/git-train/blob/main/js/parser.js): `js/parser.js`
- [Git state engine](https://github.com/esteban-crln/git-train/blob/main/js/engine.js): `js/engine.js`

### History features

- [History rewriting](https://github.com/esteban-crln/git-train/blob/main/js/rewrite.js): `js/rewrite.js`
- [Stash operations](https://github.com/esteban-crln/git-train/blob/main/js/stash.js): `js/stash.js`
- [Tag operations](https://github.com/esteban-crln/git-train/blob/main/js/tags.js): `js/tags.js`

### Remote simulation

- [Remote and forge](https://github.com/esteban-crln/git-train/blob/main/js/remote.js): `js/remote.js`

### State display

- [Commit graph](https://github.com/esteban-crln/git-train/blob/main/js/graph.js): `js/graph.js`
- [Git zones panel](https://github.com/esteban-crln/git-train/blob/main/js/main.js): `js/main.js`

### Other components

- **Learner**
- **Browser storage**

## Connections

- Learner → Command terminal: enters commands (evidence: `js/terminal.js`)
- Command terminal → App coordinator: submits input (evidence: `js/terminal.js`)
- App coordinator → Command parser: executes commands (evidence: `js/main.js`)
- Command parser → Git state engine: dispatches Git commands (evidence: `js/parser.js`)
- Command parser → Remote and forge: dispatches remote commands (evidence: `js/parser.js`)
- Command parser → History rewriting: dispatches rewrite commands (evidence: `js/parser.js`)
- Command parser → Stash operations: dispatches stash commands (evidence: `js/parser.js`)
- Command parser → Tag operations: dispatches tag commands (evidence: `js/parser.js`)
- Remote and forge → Git state engine: uses shared state helpers (evidence: `js/remote.js`)
- History rewriting → Git state engine: uses merge and state helpers (evidence: `js/rewrite.js`)
- Stash operations → Git state engine: uses repository helpers (evidence: `js/stash.js`)
- Tag operations → Git state engine: uses repository helpers (evidence: `js/tags.js`)
- App coordinator → Git state engine: reads and updates state (evidence: `js/main.js`)
- App coordinator → Command terminal: renders command output (evidence: `js/main.js`)
- App coordinator → Commit graph: renders commit graph (evidence: `js/main.js`)
- Commit graph → Git state engine: reads commit data (evidence: `js/graph.js`)
- App coordinator → Git zones panel: renders Git zones (evidence: `js/main.js`)
- App coordinator → Browser storage: saves simulator state (evidence: `README.md`)
