# git-school/visualizing-git architecture

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

- Interactive diagram: https://gitdiagram.com/git-school/visualizing-git
- Repository: https://github.com/git-school/visualizing-git

## Overview

##### Project type and purpose
- Type: Static, front-end visualization tool (hosted on GitHub Pages)
- Purpose: Let users type Git commands, parse them in the browser, update an in-memory commit graph, and render it with D3.

##### File structure
- Top level: index.html (entry point), README, LICENSE
- css/: layout & styling (1140.css grid, normalize, project CSS, images)
- js/: core logic
- main.js – app bootstrap and wiring
- controlbox.js – command input UI and parser
- historyview.js – command-history panel
- explaingit.js – core Git interpreter & data-model logic
- demos.js – pre-loaded examples & scenarios
- vendor/: D3.js (and any other third-party libs)
- images/: UI assets and animations
- examples/: markdown docs for example scenarios

##### Pull additional insights from README
- Supports commands: branch, merge, rebase, cherry-pick, remote operations, etc.
- No server or API: everything runs in the browser

##### Main components
A. User Interface Layer
- History View Panel (historyview.js)
- Visualization Canvas (SVG injected by D3)
B. Application Logic
- Command Parser & Interpreter (explaingit.js)
- Demo & Example Loader (demos.js)
- State Manager / In-Memory Graph Model
C. Rendering Engine
- D3.js Library (js/vendor/)
- SVG Output in index.html
D. Static Assets
- CSS Stylesheets (css/)
- Images (images/)
- Examples Markdown (examples/)
E. Hosting / Deployment
- GitHub Pages (static file host – optional to show)

##### Relationships & data flow
1) User types “git …” into Command Input →
2) controlbox.js captures input →
3) explaingit.js parses + mutates the in-memory Git graph model →
4) historyview.js appends the command to the history pane →
5) main.js invokes D3.js to re-render the SVG graph based on updated model →
6) Visualization Canvas updates on screen

##### Architectural patterns & design principles
- MVC-style separation:
- View (HTML + CSS + D3 rendering)
- Controller (controlbox.js + main.js orchestrating events)
- Model (graph data structure in explaingit.js)
- Single-Page Application (all logic in browser)
- Plug-and-play demos: demo scenarios separated in demos.js

##### Technologies & libraries
- D3.js (data-driven docs)
- Vanilla JavaScript modules
- CSS Grid (1140.css) + normalize.css
- GitHub Pages (static hosting)

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User Browser"]:::external

    subgraph "Static Assets"
        CSSGrid["1140.css"]:::static
        CSSNorm["normalize.css"]:::static
        CSSProj["explaingit.css"]:::static
        CSSImg["css/images/"]:::static
        ImgAssets["images/"]:::static
        Examples["examples/"]:::static
        Docs["README.md & LICENSE.md"]:::static
    end

    subgraph "View Layer"
        HTML["index.html"]:::view
    end

    subgraph "UI Controller Layer"
        Control["Command Input Box"]:::ui
        History["History View Panel"]:::ui
    end

    subgraph "Command Interpreter Layer"
        Parser["explaingit.js"]:::logic
        Demos["demos.js"]:::logic
    end

    subgraph "Rendering Engine"
        Main["main.js"]:::logic
        D3["D3.js (vendor/)"]:::third
    end

    SVG["SVG Visualization Canvas"]:::view
    Display["Browser Display"]:::external
    Pages["GitHub Pages"]:::external

    User -->|interacts| HTML
    CSSGrid -->|loaded by| HTML
    CSSNorm -->|loaded by| HTML
    CSSProj -->|loaded by| HTML
    CSSImg -->|loaded by| HTML
    HTML -->|bootstrap| Main
    Main -->|init UI| Control
    Control -->|userCommand| Parser
    Control -->|historyEvent| History
    Demos -->|loadScenario| Parser
    Parser -->|graphUpdated| Main
    Main -->|invoke D3| D3
    D3 -->|render| SVG
    SVG -->|display| Display
    Pages -->|serves| HTML

    click Control "https://github.com/git-school/visualizing-git/blob/gh-pages/js/controlbox.js"
    click History "https://github.com/git-school/visualizing-git/blob/gh-pages/js/historyview.js"
    click HTML "https://github.com/git-school/visualizing-git/blob/gh-pages/index.html"
    click Main "https://github.com/git-school/visualizing-git/blob/gh-pages/js/main.js"
    click Parser "https://github.com/git-school/visualizing-git/blob/gh-pages/js/explaingit.js"
    click Demos "https://github.com/git-school/visualizing-git/blob/gh-pages/js/demos.js"
    click D3 "https://github.com/git-school/visualizing-git/tree/gh-pages/js/vendor/"
    click CSSGrid "https://github.com/git-school/visualizing-git/blob/gh-pages/css/1140.css"
    click CSSNorm "https://github.com/git-school/visualizing-git/blob/gh-pages/css/normalize.css"
    click CSSProj "https://github.com/git-school/visualizing-git/blob/gh-pages/css/explaingit.css"
    click CSSImg "https://github.com/git-school/visualizing-git/tree/gh-pages/css/images/"
    click ImgAssets "https://github.com/git-school/visualizing-git/tree/gh-pages/images/"
    click Examples "https://github.com/git-school/visualizing-git/tree/gh-pages/examples/"
    click Docs "https://github.com/git-school/visualizing-git/blob/gh-pages/README.md"

    classDef ui fill:#cfe2f3,stroke:#000
    classDef logic fill:#d9ead3,stroke:#000
    classDef third fill:#fce5cd,stroke:#000
    classDef static fill:#e5e0ec,stroke:#000
    classDef view fill:#b4a7d6,stroke:#000
    classDef external fill:#fff2cc,stroke:#000
```
