# initialcommit-com/git-sim architecture

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

- Interactive diagram: https://gitdiagram.com/initialcommit-com/git-sim
- Repository: https://github.com/initialcommit-com/git-sim

## Overview

1. **What this repository is**
   - `git-sim` is a Python CLI that **reads a local Git repository and renders a visual simulation** of a chosen Git command.
   - It does not act like a Git server or IDE plugin; the main boundary is the **current working directory’s repo state** plus the user’s requested command.

2. **Primary execution path**
   - The CLI entry point is centered around `src/git_sim/__main__.py`, with package-level exposure in `src/git_sim/__init__.py`.
   - Command parsing and dispatch are organized through `commands.py` and the shared base in `git_sim_base_command.py`.
   - The flow is: **parse global flags + subcommand → build command-specific simulation → render output media**.

3. **Command-per-file structure**
   - Each supported Git operation has its own module, such as `add.py`, `commit.py`, `merge.py`, `rebase.py`, `status.py`, `push.py`, etc.
   - This gives the repo a **plugin-like command architecture**: each subcommand owns its own argument handling and simulation behavior, while sharing common command infrastructure.
   - The supported commands cover local history, workspace operations, branch/ref operations, and remote synchronization.

4. **Shared command model**
   - The base command layer in `git_sim_base_command.py` likely abstracts the common mechanics used by all subcommands: argument normalization, repo inspection, output configuration, and rendering setup.
   - That shared layer is important architecturally because it keeps the individual command modules focused on **what changes in the Git graph or working tree**, not on CLI boilerplate.

5. **Repository state and domain modeling**
   - `config.py`, `settings.py`, and `enums.py` act as the shared configuration/domain boundary.
   - These modules centralize things like output mode, light/dark theme, animation options, media paths, commit coloring, and style choices.
   - The architecture suggests a **state-to-visualization pipeline** rather than a mutation engine: the tool simulates Git outcomes and turns them into a displayable snapshot.

6. **Rendering subsystem**
   - `animations.py` is the core visualization layer.
   - The README makes clear that the tool can produce **static images** and **animated videos**, which means the rendering layer is responsible for both one-shot diagram generation and stepwise animations.
   - Manim is the major runtime dependency here and is the primary graphics/rendering boundary of the project.

7. **Output and media management**
   - Generated artifacts are written to a media directory, defaulting to `git-sim_media/`, with configurable format support for `jpg`, `png`, `mp4`, and `webm`.
   - The CLI also supports non-visual output modes like `--stdout` and `--output-only-path`, which means the architecture includes a **terminal-output boundary** in addition to file-based media output.

8. **Behavioral categories of commands**
   - The subcommands fall into a few architectural groups:
     - **Workspace/staging**: `add`, `restore`, `rm`, `mv`, `clean`, `stash`, `status`
     - **History graph changes**: `commit`, `reset`, `revert`, `cherry-pick`, `rebase`, `merge`
     - **Branch/ref management**: `branch`, `checkout`, `switch`, `tag`
     - **Remote/network simulation**: `clone`, `fetch`, `pull`, `push`, `remote`
     - **Metadata/info**: `log`, `config`, `init`
   - This grouping matters because each category drives different visual outcomes in the rendered graph.

9. **Simulation boundaries**
   - The tool is designed to **simulate** Git behavior for visualization, not replace Git itself.
   - For commands involving remotes, the repo still remains a local simulation model; the output shows what would happen to local refs and history rather than relying on a real network service.

10. **User-facing configuration model**
   - Global options from the README are a major part of the architecture: animation toggles, commit display depth, branch ordering, merge visibility, color-by mode, light mode, reverse history, and style.
   - Environment variables prefixed with `git_sim_` override defaults, and command-line flags override environment values.
   - That means configuration resolution is an explicit cross-cutting concern before rendering starts.

11. **Packaging and deployment**
   - `pyproject.toml`, `MANIFEST.in`, and `Dockerfile` show that this is a packaged Python application with a containerized execution path.
   - Docker is an important architectural option because Manim and its rendering dependencies can be heavy and environment-sensitive.

12. **Testing strategy**
   - Tests are split into `unit_tests` and `e2e_tests`.
   - The end-to-end tests include `reference_files`, indicating that the important contract is the **generated visual/output behavior**, not just pure function results.
   - That aligns with the repo’s architecture: correctness is measured by whether the simulated media matches expected Git visuals.

13. **How to diagram it**
   - A clean architecture diagram would show:
     - **CLI entry point**
     - **shared command/config layer**
     - **per-subcommand simulation modules**
     - **repo-state interpretation**
     - **rendering via Manim**
     - **media/file/terminal outputs**
   - The main external dependencies to show are **local Git repository data**, **Manim**, and optionally **Docker** as an execution wrapper.

Main entry points: [`src/git_sim/commands.py`](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/commands.py) (Dispatch), [`src/git_sim/animations.py`](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/animations.py) (Animations), [`src/git_sim/git_sim_base_command.py`](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/git_sim_base_command.py) (Base command), [`src/git_sim/__main__.py`](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/__main__.py) (Entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_cli["CLI core"]
  node_n_main["Entry point<br/>cli entry<br/>[__main__.py]"]
  node_n_init["Package API<br/>package export<br/>[__init__.py]"]
  node_n_dispatch["Dispatch<br/>command router<br/>[commands.py]"]
  node_n_base["Base command<br/>shared command base"]
end

subgraph group_g_commands["Command modules"]
  node_n_add["Workspace ops<br/>staging commands<br/>[add.py]"]
  node_n_history["History ops<br/>history commands<br/>[commit.py]"]
  node_n_branch["Branch ops<br/>ref commands<br/>[branch.py]"]
  node_n_remote["Remote ops<br/>sync commands<br/>[clone.py]"]
  node_n_init_cmd["Init/log ops<br/>repo info commands<br/>[init.py]"]
end

subgraph group_g_state["State and config"]
  node_n_config["Config<br/>[config.py]"]
  node_n_settings["Settings<br/>[settings.py]"]
  node_n_enums["Enums<br/>[enums.py]"]
end

subgraph group_g_render["Rendering"]
  node_n_anim["Animations<br/>render pipeline<br/>[animations.py]"]
  node_n_media["Media output<br/>artifact output"]
  node_n_git[("Local repo<br/>git working copy")]
  node_n_manim{{"Manim<br/>render dependency"}}
end

subgraph group_g_delivery["Packaging and tests"]
  node_n_pyproject["Packaging<br/>build config<br/>[pyproject.toml]"]
  node_n_docker["Docker<br/>container runtime"]
  node_n_tests["Tests<br/>verification"]
end

node_n_main -->|"invokes"| node_n_dispatch
node_n_main -->|"exports"| node_n_init
node_n_dispatch -->|"builds"| node_n_base
node_n_base -->|"reads"| node_n_config
node_n_base -->|"applies"| node_n_settings
node_n_base -->|"uses"| node_n_enums
node_n_base -->|"inspects"| node_n_git
node_n_dispatch -->|"routes"| node_n_add
node_n_dispatch -->|"routes"| node_n_history
node_n_dispatch -->|"routes"| node_n_branch
node_n_dispatch -->|"routes"| node_n_remote
node_n_dispatch -->|"routes"| node_n_init_cmd
node_n_add -->|"simulates"| node_n_anim
node_n_history -->|"simulates"| node_n_anim
node_n_branch -->|"simulates"| node_n_anim
node_n_remote -->|"simulates"| node_n_anim
node_n_init_cmd -->|"simulates"| node_n_anim
node_n_anim -->|"renders with"| node_n_manim
node_n_anim -->|"writes"| node_n_media
node_n_pyproject -.->|"depends on"| node_n_manim
node_n_docker -.->|"packages"| node_n_manim
node_n_tests -->|"checks"| node_n_media
node_n_tests -->|"covers"| node_n_dispatch

click node_n_main "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/__main__.py"
click node_n_init "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/__init__.py"
click node_n_dispatch "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/commands.py"
click node_n_base "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/git_sim_base_command.py"
click node_n_add "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/add.py"
click node_n_history "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/commit.py"
click node_n_branch "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/branch.py"
click node_n_remote "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/clone.py"
click node_n_init_cmd "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/init.py"
click node_n_config "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/config.py"
click node_n_settings "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/settings.py"
click node_n_enums "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/enums.py"
click node_n_anim "https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/animations.py"
click node_n_pyproject "https://github.com/initialcommit-com/git-sim/blob/main/pyproject.toml"
click node_n_docker "https://github.com/initialcommit-com/git-sim/tree/main/Dockerfile"
click node_n_tests "https://github.com/initialcommit-com/git-sim/tree/main/tests"

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_n_main,node_n_init,node_n_dispatch,node_n_base toneBlue
class node_n_add,node_n_history,node_n_branch,node_n_remote,node_n_init_cmd toneAmber
class node_n_config,node_n_settings,node_n_enums toneMint
class node_n_anim,node_n_media,node_n_git,node_n_manim toneRose
class node_n_pyproject,node_n_docker,node_n_tests toneIndigo
```

## Components

### CLI core

Entry point, command dispatch, and shared command behavior.

- [Entry point](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/__main__.py): cli entry · Starts the git-sim command-line application. · `src/git_sim/__main__.py`
- [Package API](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/__init__.py): package export · Package-level import surface for git-sim. · `src/git_sim/__init__.py`
- [Dispatch](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/commands.py): command router · Parses global flags and routes to subcommands. · `src/git_sim/commands.py`
- [Base command](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/git_sim_base_command.py): shared command base · Common argument, repo, and render setup for all subcommands. · `src/git_sim/git_sim_base_command.py`

### Command modules

Per-git-command simulation modules organized by behavior area.

- [Workspace ops](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/add.py): staging commands · Workspace and staging simulations such as add, restore, rm, mv, clean, stash, and status. · `src/git_sim/add.py`
- [History ops](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/commit.py): history commands · Commit and history-shaping simulations such as commit, reset, revert, cherry-pick, rebase, and merge. · `src/git_sim/commit.py`
- [Branch ops](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/branch.py): ref commands · Branch, checkout, switch, and tag simulations for ref movement. · `src/git_sim/branch.py`
- [Remote ops](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/clone.py): sync commands · Clone, fetch, pull, push, and remote simulations for local mirror state. · `src/git_sim/clone.py`
- [Init/log ops](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/init.py): repo info commands · Repository bootstrap and inspection commands such as init and log. · `src/git_sim/init.py`

### State and config

Shared configuration, enums, and runtime settings.

- [Config](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/config.py): runtime config · User-facing configuration resolution and defaults. · `src/git_sim/config.py`
- [Settings](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/settings.py): display settings · Rendering and behavior settings such as themes, animation, and output options. · `src/git_sim/settings.py`
- [Enums](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/enums.py): domain enums · Shared enumerations for modes, styles, and command choices. · `src/git_sim/enums.py`

### Rendering

Visualization and media generation layer.

- [Animations](https://github.com/initialcommit-com/git-sim/blob/main/src/git_sim/animations.py): render pipeline · Core visualization layer that generates static and animated output. · `src/git_sim/animations.py`
- **Media output**: artifact output · Rendered images, videos, and terminal-facing output paths.
- **Local repo**: git working copy · The local Git repository state being inspected and simulated.
- **Manim**: render dependency · Primary graphics runtime used for visualization generation.

### Packaging and tests

Build, containerization, and verification surfaces.

- [Packaging](https://github.com/initialcommit-com/git-sim/blob/main/pyproject.toml): build config · Project packaging and dependency declaration. · `pyproject.toml`
- [Docker](https://github.com/initialcommit-com/git-sim/tree/main/Dockerfile): container runtime · Containerized execution path for the renderer and dependencies. · `Dockerfile`
- [Tests](https://github.com/initialcommit-com/git-sim/tree/main/tests): verification · Unit and end-to-end tests with reference output checks. · `tests`

## Connections

- Entry point → Dispatch: invokes · CLI entry delegates parsing and command routing.
- Entry point → Package API: exports · Package entry points expose the CLI.
- Dispatch → Base command: builds · Dispatch uses the shared command base.
- Base command → Config: reads · Common command logic resolves runtime configuration.
- Base command → Settings: applies · Command setup uses display and output settings.
- Base command → Enums: uses · Shared command logic relies on common modes and choices.
- Base command → Local repo: inspects · Commands inspect the local repository state.
- Dispatch → Workspace ops: routes · Dispatch sends workspace-related commands to their module.
- Dispatch → History ops: routes · Dispatch sends history-shaping commands to their module.
- Dispatch → Branch ops: routes · Dispatch sends ref-management commands to their module.
- Dispatch → Remote ops: routes · Dispatch sends remote-sync commands to their module.
- Dispatch → Init/log ops: routes · Dispatch sends repo info and bootstrap commands to their module.
- Workspace ops → Animations: simulates · Workspace changes are turned into visual steps.
- History ops → Animations: simulates · History graph changes are rendered as command outcomes.
- Branch ops → Animations: simulates · Branch and ref movement feeds the visualization layer.
- Remote ops → Animations: simulates · Remote operations update the local model for rendering.
- Init/log ops → Animations: simulates · Init and log output are visualized like other commands.
- Animations → Manim: renders with · Animation and image generation run on Manim.
- Animations → Media output: writes · Rendered artifacts are written to media or stdout paths.
- Packaging → Manim: depends on · Packaging declares the rendering dependency stack.
- Docker → Manim: packages · Container image wraps the renderer and its heavy dependencies.
- Tests → Media output: checks · End-to-end tests validate generated visual output.
- Tests → Dispatch: covers · Tests exercise CLI command parsing and execution paths.
