# jj-vcs/jj architecture

> Architecture diagram of the GitHub repository jj-vcs/jj, 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/jj-vcs/jj
- Repository: https://github.com/jj-vcs/jj

## Overview

Jujutsu is a command-line version control system whose user-facing model centers on commits, automatically snapshotted working copies, history rewriting, and reversible operations. The principal workflow is to invoke `jj` commands to inspect or modify a repository, with changes represented as commits and stored through a backend; Git is the current storage layer and provides interoperability. The graph preserves documented query, conflict, and operation-history capabilities. Source excerpts are partial, so several domain relationships rely on README-level documentation rather than inspected call sites.

Main entry points: [`lib/src/working_copy.rs`](https://github.com/jj-vcs/jj/blob/main/lib/src/working_copy.rs) (Working copy), [`lib/src/revset.rs`](https://github.com/jj-vcs/jj/blob/main/lib/src/revset.rs) (Revset evaluation), [`core/src/store.rs`](https://github.com/jj-vcs/jj/blob/main/core/src/store.rs) (Object store), [`git-backend/src/git_backend.rs`](https://github.com/jj-vcs/jj/blob/main/git-backend/src/git_backend.rs) (Git backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_entry["jj entry<br/>[main.rs]"]
  node_command_dispatch["Command dispatch<br/>[mod.rs]"]
  node_cli_runtime["CLI runtime<br/>[cli_util.rs]"]
  node_output["UI and formatting<br/>[ui.rs]"]
end

subgraph group_history["Version Control"]
  node_working_copy["Working copy<br/>[working_copy.rs]"]
  node_workspace["Workspace<br/>[workspace.rs]"]
  node_rewrite["History rewriting<br/>[rewrite.rs]"]
  node_evolution["Commit evolution<br/>[evolution.rs]"]
  node_operations["Operation history<br/>[operation.rs]"]
  node_commit["Commit model<br/>[commit.rs]"]
end

subgraph group_query["History and Queries"]
  node_revsets["Revset evaluation<br/>[revset.rs]"]
  node_dsl["Revset parsing<br/>[revset_parser.rs]"]
  node_index[("Commit index<br/>[composite.rs]")]
end

subgraph group_storage["Storage"]
  node_store["Object store<br/>[store.rs]"]
  node_backend_api["Backend interface<br/>[backend.rs]"]
  node_git_backend[("Git backend<br/>[git_backend.rs]")]
end

node_user(("Repository user"))
node_git_repo[("Git repository")]

node_user -->|"runs commands"| node_entry
node_entry -->|"dispatches"| node_command_dispatch
node_user -->|"edits files"| node_working_copy
node_working_copy -->|"snapshots changes"| node_commit
node_user -->|"rewrites history"| node_rewrite
node_rewrite -->|"rebases descendants"| node_evolution
node_user -->|"views or undoes"| node_operations
node_user -->|"selects commits"| node_revsets
node_dsl -->|"parses expressions"| node_revsets
node_revsets -->|"queries commits"| node_index
node_commit -->|"loads commit data"| node_store
node_store -->|"delegates storage"| node_backend_api
node_git_backend -->|"implements interface"| node_backend_api
node_git_backend -->|"stores Git objects"| node_git_repo
node_user -.->|"publishes changes"| node_git_repo
node_command_dispatch -.->|"uses runtime"| node_cli_runtime
node_cli_runtime -.->|"formats output"| node_output
node_workspace -.->|"manages checkout"| node_working_copy
node_operations -.->|"persists operations"| node_store

click node_entry "https://github.com/jj-vcs/jj/blob/main/cli/src/main.rs"
click node_command_dispatch "https://github.com/jj-vcs/jj/blob/main/cli/src/commands/mod.rs"
click node_cli_runtime "https://github.com/jj-vcs/jj/blob/main/cli/src/cli_util.rs"
click node_output "https://github.com/jj-vcs/jj/blob/main/cli/src/ui.rs"
click node_working_copy "https://github.com/jj-vcs/jj/blob/main/lib/src/working_copy.rs"
click node_workspace "https://github.com/jj-vcs/jj/blob/main/lib/src/workspace.rs"
click node_rewrite "https://github.com/jj-vcs/jj/blob/main/lib/src/rewrite.rs"
click node_evolution "https://github.com/jj-vcs/jj/blob/main/lib/src/evolution.rs"
click node_operations "https://github.com/jj-vcs/jj/blob/main/core/src/operation.rs"
click node_revsets "https://github.com/jj-vcs/jj/blob/main/lib/src/revset.rs"
click node_dsl "https://github.com/jj-vcs/jj/blob/main/dsl/src/revset_parser.rs"
click node_index "https://github.com/jj-vcs/jj/blob/main/default-index/src/composite.rs"
click node_commit "https://github.com/jj-vcs/jj/blob/main/core/src/commit.rs"
click node_store "https://github.com/jj-vcs/jj/blob/main/core/src/store.rs"
click node_backend_api "https://github.com/jj-vcs/jj/blob/main/core/src/backend.rs"
click node_git_backend "https://github.com/jj-vcs/jj/blob/main/git-backend/src/git_backend.rs"

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_entry,node_command_dispatch,node_cli_runtime,node_output,node_user toneBlue
class node_working_copy,node_workspace,node_rewrite,node_evolution,node_operations,node_commit,node_git_repo toneAmber
class node_revsets,node_dsl,node_index toneMint
class node_store,node_backend_api,node_git_backend toneRose
```

## Components

### CLI

- [jj entry](https://github.com/jj-vcs/jj/blob/main/cli/src/main.rs): `cli/src/main.rs`
- [Command dispatch](https://github.com/jj-vcs/jj/blob/main/cli/src/commands/mod.rs): `cli/src/commands/mod.rs`
- [CLI runtime](https://github.com/jj-vcs/jj/blob/main/cli/src/cli_util.rs): `cli/src/cli_util.rs`
- [UI and formatting](https://github.com/jj-vcs/jj/blob/main/cli/src/ui.rs): `cli/src/ui.rs`

### Version Control

- [Working copy](https://github.com/jj-vcs/jj/blob/main/lib/src/working_copy.rs): `lib/src/working_copy.rs`
- [Workspace](https://github.com/jj-vcs/jj/blob/main/lib/src/workspace.rs): `lib/src/workspace.rs`
- [History rewriting](https://github.com/jj-vcs/jj/blob/main/lib/src/rewrite.rs): `lib/src/rewrite.rs`
- [Commit evolution](https://github.com/jj-vcs/jj/blob/main/lib/src/evolution.rs): `lib/src/evolution.rs`
- [Operation history](https://github.com/jj-vcs/jj/blob/main/core/src/operation.rs): `core/src/operation.rs`
- [Commit model](https://github.com/jj-vcs/jj/blob/main/core/src/commit.rs): `core/src/commit.rs`

### History and Queries

- [Revset evaluation](https://github.com/jj-vcs/jj/blob/main/lib/src/revset.rs): `lib/src/revset.rs`
- [Revset parsing](https://github.com/jj-vcs/jj/blob/main/dsl/src/revset_parser.rs): `dsl/src/revset_parser.rs`
- [Commit index](https://github.com/jj-vcs/jj/blob/main/default-index/src/composite.rs): `default-index/src/composite.rs`

### Storage

- [Object store](https://github.com/jj-vcs/jj/blob/main/core/src/store.rs): `core/src/store.rs`
- [Backend interface](https://github.com/jj-vcs/jj/blob/main/core/src/backend.rs): `core/src/backend.rs`
- [Git backend](https://github.com/jj-vcs/jj/blob/main/git-backend/src/git_backend.rs): `git-backend/src/git_backend.rs`

### Other components

- **Repository user**
- **Git repository**

## Connections

- Repository user → jj entry: runs commands (evidence: `README.md`)
- jj entry → Command dispatch: dispatches
- Repository user → Working copy: edits files (evidence: `README.md`)
- Working copy → Commit model: snapshots changes (evidence: `README.md`)
- Repository user → History rewriting: rewrites history (evidence: `README.md`)
- History rewriting → Commit evolution: rebases descendants (evidence: `README.md`)
- Repository user → Operation history: views or undoes (evidence: `README.md`)
- Repository user → Revset evaluation: selects commits (evidence: `README.md`)
- Revset parsing → Revset evaluation: parses expressions (evidence: `dsl/src/revset_parser.rs`)
- Revset evaluation → Commit index: queries commits
- Commit model → Object store: loads commit data (evidence: `core/src/commit.rs`)
- Object store → Backend interface: delegates storage (evidence: `core/src/store.rs`)
- Git backend → Backend interface: implements interface (evidence: `git-backend/src/git_backend.rs`)
- Git backend → Git repository: stores Git objects (evidence: `README.md`)
- Repository user → Git repository: publishes changes (evidence: `README.md`)
- Command dispatch → CLI runtime: uses runtime (evidence: `cli/src/cli_util.rs`)
- CLI runtime → UI and formatting: formats output (evidence: `cli/src/cli_util.rs`)
- Workspace → Working copy: manages checkout
- Operation history → Object store: persists operations
