# jcoglan/jit architecture

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

- Interactive diagram: https://gitdiagram.com/jcoglan/jit
- Repository: https://github.com/jcoglan/jit

## Overview

This is a Ruby implementation of a Git-like version-control tool. Its central workflow is manipulating a working tree and staging area, recording changes as repository objects and commits, then inspecting or transferring repository history. The graph preserves the documented-by-tree command families—branching, history, merging, and remotes—alongside storage and diff internals. Source excerpts confirm the repository’s state components, status and merge behavior, object storage, and remote protocol client; wiring among unsampled command handlers is intentionally limited.

Main entry points: [`lib/command.rb`](https://github.com/jcoglan/jit/blob/master/lib/command.rb) (Command entry), [`lib/repository.rb`](https://github.com/jcoglan/jit/blob/master/lib/repository.rb) (Repository API), [`lib/repository/migration.rb`](https://github.com/jcoglan/jit/blob/master/lib/repository/migration.rb) (Tree migration), [`lib/merge/resolve.rb`](https://github.com/jcoglan/jit/blob/master/lib/merge/resolve.rb) (Merge resolution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commands["User commands"]
  node_command_entry["Command entry<br/>[command.rb]"]
  node_add["Stage changes<br/>[add.rb]"]
  node_commit["Create commit<br/>[commit.rb]"]
  node_status_cmd["Status command<br/>[status.rb]"]
  node_checkout["Checkout<br/>[checkout.rb]"]
  node_merge_cmd["Merge command<br/>[merge.rb]"]
  node_diff_cmd["Diff command<br/>[diff.rb]"]
  node_history_cmds["History commands<br/>[log.rb]"]
end

subgraph group_repository["Repository state"]
  node_repository_api["Repository API<br/>[repository.rb]"]
  node_index[("Staging index<br/>[index.rb]")]
  node_workspace["Working tree<br/>[workspace.rb]"]
  node_refs[("Refs and branches<br/>[refs.rb]")]
  node_config[("Configuration<br/>[stack.rb]")]
  node_status["Status analysis<br/>[status.rb]"]
  node_migration["Tree migration<br/>[migration.rb]"]
end

subgraph group_objects["Objects and changes"]
  node_database[("Object database<br/>[database.rb]")]
  node_pack["Pack storage<br/>[pack.rb]"]
  node_diff["Diff engine<br/>[diff.rb]"]
  node_merge_resolve["Merge resolution<br/>[resolve.rb]"]
end

subgraph group_collaboration["History and remotes"]
  node_remote_commands["Fetch and push<br/>[fetch.rb]"]
  node_remote_client["Remote client<br/>[remote_client.rb]"]
  node_protocol["Remote protocol<br/>[protocol.rb]"]
  node_remotes["Remote config<br/>[remotes.rb]"]
end

node_user(("CLI user"))
node_external_remote(("Remote repository"))

node_user -->|"invokes"| node_command_entry
node_command_entry -->|"dispatches"| node_add
node_command_entry -->|"dispatches"| node_commit
node_command_entry -->|"dispatches"| node_status_cmd
node_command_entry -->|"dispatches"| node_checkout
node_command_entry -->|"dispatches"| node_merge_cmd
node_command_entry -->|"dispatches"| node_diff_cmd
node_command_entry -->|"dispatches"| node_history_cmds
node_command_entry -->|"dispatches"| node_remote_commands
node_repository_api -->|"creates"| node_database
node_repository_api -->|"creates"| node_index
node_repository_api -->|"creates"| node_refs
node_repository_api -->|"creates"| node_workspace
node_repository_api -->|"creates"| node_config
node_repository_api -->|"creates"| node_remotes
node_status_cmd -->|"loads and writes"| node_index
node_status_cmd -->|"requests status"| node_status
node_status_cmd -->|"reads branch"| node_refs
node_repository_api -->|"constructs"| node_status
node_repository_api -->|"constructs"| node_migration
node_migration -->|"applies changes"| node_workspace
node_migration -->|"updates"| node_index
node_migration -->|"loads blobs"| node_database
node_merge_resolve -->|"diffs and stores"| node_database
node_merge_resolve -->|"applies clean changes"| node_migration
node_merge_resolve -->|"records conflicts"| node_index
node_merge_resolve -->|"writes files"| node_workspace
node_database -->|"uses storage backends"| node_pack
node_remote_commands -->|"uses client"| node_remote_client
node_remote_commands -->|"reads remote settings"| node_remotes
node_remote_client -->|"creates connection"| node_protocol
node_remote_client -->|"starts agent"| node_external_remote
node_diff_cmd -->|"uses diff engine"| node_diff

click node_command_entry "https://github.com/jcoglan/jit/blob/master/lib/command.rb"
click node_add "https://github.com/jcoglan/jit/blob/master/lib/command/add.rb"
click node_commit "https://github.com/jcoglan/jit/blob/master/lib/command/commit.rb"
click node_status_cmd "https://github.com/jcoglan/jit/blob/master/lib/command/status.rb"
click node_checkout "https://github.com/jcoglan/jit/blob/master/lib/command/checkout.rb"
click node_merge_cmd "https://github.com/jcoglan/jit/blob/master/lib/command/merge.rb"
click node_diff_cmd "https://github.com/jcoglan/jit/blob/master/lib/command/diff.rb"
click node_history_cmds "https://github.com/jcoglan/jit/blob/master/lib/command/log.rb"
click node_repository_api "https://github.com/jcoglan/jit/blob/master/lib/repository.rb"
click node_index "https://github.com/jcoglan/jit/blob/master/lib/index.rb"
click node_workspace "https://github.com/jcoglan/jit/blob/master/lib/workspace.rb"
click node_refs "https://github.com/jcoglan/jit/blob/master/lib/refs.rb"
click node_config "https://github.com/jcoglan/jit/blob/master/lib/config/stack.rb"
click node_status "https://github.com/jcoglan/jit/blob/master/lib/repository/status.rb"
click node_migration "https://github.com/jcoglan/jit/blob/master/lib/repository/migration.rb"
click node_database "https://github.com/jcoglan/jit/blob/master/lib/database.rb"
click node_pack "https://github.com/jcoglan/jit/blob/master/lib/pack.rb"
click node_diff "https://github.com/jcoglan/jit/blob/master/lib/diff.rb"
click node_merge_resolve "https://github.com/jcoglan/jit/blob/master/lib/merge/resolve.rb"
click node_remote_commands "https://github.com/jcoglan/jit/blob/master/lib/command/fetch.rb"
click node_remote_client "https://github.com/jcoglan/jit/blob/master/lib/command/shared/remote_client.rb"
click node_protocol "https://github.com/jcoglan/jit/blob/master/lib/remotes/protocol.rb"
click node_remotes "https://github.com/jcoglan/jit/blob/master/lib/remotes.rb"

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_command_entry,node_add,node_commit,node_status_cmd,node_checkout,node_merge_cmd,node_diff_cmd,node_history_cmds,node_user toneBlue
class node_repository_api,node_index,node_workspace,node_refs,node_config,node_status,node_migration toneAmber
class node_database,node_pack,node_diff,node_merge_resolve toneMint
class node_remote_commands,node_remote_client,node_protocol,node_remotes toneRose
class node_external_remote toneIndigo
```

## Components

### User commands

- [Command entry](https://github.com/jcoglan/jit/blob/master/lib/command.rb): `lib/command.rb`
- [Stage changes](https://github.com/jcoglan/jit/blob/master/lib/command/add.rb): `lib/command/add.rb`
- [Create commit](https://github.com/jcoglan/jit/blob/master/lib/command/commit.rb): `lib/command/commit.rb`
- [Status command](https://github.com/jcoglan/jit/blob/master/lib/command/status.rb): `lib/command/status.rb`
- [Checkout](https://github.com/jcoglan/jit/blob/master/lib/command/checkout.rb): `lib/command/checkout.rb`
- [Merge command](https://github.com/jcoglan/jit/blob/master/lib/command/merge.rb): `lib/command/merge.rb`
- [Diff command](https://github.com/jcoglan/jit/blob/master/lib/command/diff.rb): `lib/command/diff.rb`
- [History commands](https://github.com/jcoglan/jit/blob/master/lib/command/log.rb): `lib/command/log.rb`

### Repository state

- [Repository API](https://github.com/jcoglan/jit/blob/master/lib/repository.rb): `lib/repository.rb`
- [Staging index](https://github.com/jcoglan/jit/blob/master/lib/index.rb): `lib/index.rb`
- [Working tree](https://github.com/jcoglan/jit/blob/master/lib/workspace.rb): `lib/workspace.rb`
- [Refs and branches](https://github.com/jcoglan/jit/blob/master/lib/refs.rb): `lib/refs.rb`
- [Configuration](https://github.com/jcoglan/jit/blob/master/lib/config/stack.rb): `lib/config/stack.rb`
- [Status analysis](https://github.com/jcoglan/jit/blob/master/lib/repository/status.rb): `lib/repository/status.rb`
- [Tree migration](https://github.com/jcoglan/jit/blob/master/lib/repository/migration.rb): `lib/repository/migration.rb`

### Objects and changes

- [Object database](https://github.com/jcoglan/jit/blob/master/lib/database.rb): `lib/database.rb`
- [Pack storage](https://github.com/jcoglan/jit/blob/master/lib/pack.rb): `lib/pack.rb`
- [Diff engine](https://github.com/jcoglan/jit/blob/master/lib/diff.rb): `lib/diff.rb`
- [Merge resolution](https://github.com/jcoglan/jit/blob/master/lib/merge/resolve.rb): `lib/merge/resolve.rb`

### History and remotes

- [Fetch and push](https://github.com/jcoglan/jit/blob/master/lib/command/fetch.rb): `lib/command/fetch.rb`
- [Remote client](https://github.com/jcoglan/jit/blob/master/lib/command/shared/remote_client.rb): `lib/command/shared/remote_client.rb`
- [Remote protocol](https://github.com/jcoglan/jit/blob/master/lib/remotes/protocol.rb): `lib/remotes/protocol.rb`
- [Remote config](https://github.com/jcoglan/jit/blob/master/lib/remotes.rb): `lib/remotes.rb`

### Other components

- **CLI user**
- **Remote repository**

## Connections

- CLI user → Command entry: invokes
- Command entry → Stage changes: dispatches
- Command entry → Create commit: dispatches
- Command entry → Status command: dispatches
- Command entry → Checkout: dispatches
- Command entry → Merge command: dispatches
- Command entry → Diff command: dispatches
- Command entry → History commands: dispatches
- Command entry → Fetch and push: dispatches
- Repository API → Object database: creates
- Repository API → Staging index: creates
- Repository API → Refs and branches: creates
- Repository API → Working tree: creates
- Repository API → Configuration: creates
- Repository API → Remote config: creates
- Status command → Staging index: loads and writes
- Status command → Status analysis: requests status
- Status command → Refs and branches: reads branch
- Repository API → Status analysis: constructs
- Repository API → Tree migration: constructs
- Tree migration → Working tree: applies changes
- Tree migration → Staging index: updates
- Tree migration → Object database: loads blobs
- Merge resolution → Object database: diffs and stores
- Merge resolution → Tree migration: applies clean changes
- Merge resolution → Staging index: records conflicts
- Merge resolution → Working tree: writes files
- Object database → Pack storage: uses storage backends
- Fetch and push → Remote client: uses client
- Fetch and push → Remote config: reads remote settings
- Remote client → Remote protocol: creates connection
- Remote client → Remote repository: starts agent
- Diff command → Diff engine: uses diff engine
