# cod-e-codes/astvcs architecture

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

- Interactive diagram: https://gitdiagram.com/cod-e-codes/astvcs
- Repository: https://github.com/cod-e-codes/astvcs

## Overview

1. **System shape**
   astvcs is a local-first Rust CLI for versioning a working tree of source files. The repository model lives under `.astvcs/` and is built around content-addressed state, a commit timeline, branches, tags, and remotes. It is not Git-compatible; Git import is one-way only.

2. **Entry points**
   `src/main.rs` is the CLI binary, while `src/lib.rs` exposes the reusable core. The command surface is organized around familiar VCS actions such as init, status, add, commit, diff, merge, branch, fetch, clone, reset, revert, rebase, cherry-pick, stash, blame, and bisect.

3. **Command interpretation layer**
   The `src/intent/` module is the top-level orchestration boundary between CLI commands and repository operations. It likely turns parsed command-line input into higher-level actions against the store, diff, merge, and network subsystems.

4. **Repository/store subsystem**
   `src/store/` is the main persistence and repository-state layer. It covers repository initialization, history, manifest, blobs, staging, working-tree interaction, locks, hooks, identity, tags, stash, shallow history, reachability, integrity checks, garbage collection/repacking, and Git import. This is where on-disk state under `.astvcs/` is managed.

5. **Content model and persistence**
   Inside the store, blobs and manifests are the basic storage units. Supporting modules such as `format`, `pack`, `atomic`, `lock`, `scan_cache`, and `working` indicate a content-addressed storage format with atomic updates, advisory locking, and cached filesystem scans to keep repository operations safe and efficient.

6. **Graph and history model**
   `src/graph/` models the commit DAG and its edges/nodes/mutations. This is the layer that history-oriented features such as log, blame, reachability, bisect, rebase, and cherry-pick build on. It is the structural representation of repository history separate from file content.

7. **Frontend/file classification**
   `src/frontend/` decides how a path is represented before diffing or storage. Tree-sitter support is central: if a file type is parseable, astvcs treats it as an AST-backed structural blob; otherwise it falls back to UTF-8 text (`textblob.rs`) or raw bytes (`binaryblob.rs`). Symlinks are handled separately, and language detection lives here too.

8. **Structural diff pipeline**
   `src/diff/` implements the comparison engine. It includes AST diffing, text diffing, LCS/alignment, path rename detection, and a viewer export path. The diff system is not only for user-facing `diff`; it also feeds merge and conflict detection by determining how nodes and lines correspond across versions.

9. **Merge subsystem**
   `src/merge/` and store-side merge helpers handle three-way merging of structural edits. The key architectural boundary is that non-overlapping AST edits can be auto-applied, while overlapping edits become structural conflicts that are resolved per path rather than by writing conflict markers into files.

10. **Network and remote sync**
   `src/network/` provides remote interaction over local paths, HTTP/HTTPS, and SSH. The presence of `serve`, `remote_serve`, `transport`, `api`, `sync`, and `ssh` suggests a split between transport abstraction, server-side serving, and client-side fetch/clone/push-like synchronization, with optional bearer auth and TLS support in the serving path.

11. **Working tree, staging, and user-visible workflow**
   The workflow is local and stateful: working-tree changes are scanned, staged via `add`, committed into the store, and compared via `diff --staged` or normal `diff`. The staging/index layer sits between filesystem state and repository history, so operations like reset, status, and commit are mediated through it.

12. **Operational safety**
   The store includes explicit integrity, reachability, and locking modules, indicating that concurrent access and repository health are first-class concerns. This supports safe reads during serving while writes serialize, and enables maintenance commands such as `fsck`, `gc`, and `repack`.

13. **Developer-facing artifacts**
   `examples/` contains runnable fixture repositories that demonstrate identity, import-git, lifecycle, merge, network, shallow history, same-file handling, serving, and workflow scenarios. The `.cursor/skills/` content and `tests/` folder show that the repo is organized for both automated validation and guided contributor workflows.

14. **Architecture boundary summary**
   The key diagram boundary is: CLI/intent at the top, repository/store and graph in the middle, frontend and diff/merge as content-processing engines, and network as an outer synchronization layer. Everything ultimately converges on the local `.astvcs/` repository state rather than an external service or Git-compatible backend.

Main entry points: [`src/store/mod.rs`](https://github.com/cod-e-codes/astvcs/blob/main/src/store/mod.rs) (store), [`src/intent/mod.rs`](https://github.com/cod-e-codes/astvcs/blob/main/src/intent/mod.rs) (intent), [`src/frontend/mod.rs`](https://github.com/cod-e-codes/astvcs/blob/main/src/frontend/mod.rs) (frontend), [`src/network/mod.rs`](https://github.com/cod-e-codes/astvcs/blob/main/src/network/mod.rs) (network)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI surface"]
  node_src_main["main<br/>cli binary<br/>[main.rs]"]
  node_intent["intent<br/>command orchestration<br/>[mod.rs]"]
end

subgraph group_core["Repository core"]
  node_src_lib["lib<br/>[lib.rs]"]
  node_store[("store<br/>repository state<br/>[mod.rs]")]
  node_repo["repo<br/>[repo.rs]"]
  node_history["history<br/>commit timeline<br/>[history.rs]"]
  node_staging["staging<br/>index layer<br/>[staging.rs]"]
  node_working["working tree<br/>filesystem view<br/>[working.rs]"]
  node_blobs[("blobs<br/>content store<br/>[blobs.rs]")]
  node_manifest["manifest<br/>tree state<br/>[manifest.rs]"]
  node_graph{{"graph<br/>commit DAG<br/>[mod.rs]"}}
end

subgraph group_processing["Content processing"]
  node_frontend["frontend<br/>file classification<br/>[mod.rs]"]
  node_treesitter["tree-sitter<br/>AST parser bridge<br/>[treesitter.rs]"]
  node_textblob["text blob<br/>utf8 content<br/>[textblob.rs]"]
  node_binaryblob["binary blob<br/>raw bytes<br/>[binaryblob.rs]"]
  node_diff["diff<br/>comparison engine<br/>[mod.rs]"]
  node_merge["merge<br/>[mod.rs]"]
end

subgraph group_sync["Sync layer"]
  node_network["network<br/>remote sync<br/>[mod.rs]"]
  node_sync_mod["sync<br/>[sync.rs]"]
  node_serve["serve<br/>[serve.rs]"]
  node_transport["transport<br/>protocol layer<br/>[transport.rs]"]
end

node_src_main -->|"dispatches"| node_intent
node_intent -->|"operates on"| node_store
node_intent -->|"requests"| node_diff
node_intent -->|"requests"| node_merge
node_intent -->|"requests"| node_network
node_src_lib -->|"exports"| node_store
node_src_lib -->|"exports"| node_graph
node_store -->|"includes"| node_repo
node_store -->|"includes"| node_history
node_store -->|"includes"| node_staging
node_store -->|"includes"| node_working
node_store -->|"includes"| node_blobs
node_store -->|"includes"| node_manifest
node_store -->|"uses"| node_graph
node_working -->|"classifies via"| node_frontend
node_frontend -->|"uses"| node_treesitter
node_frontend -->|"falls back to"| node_textblob
node_frontend -->|"falls back to"| node_binaryblob
node_diff -->|"compares history"| node_graph
node_diff -->|"compares content"| node_frontend
node_merge -->|"aligns with"| node_diff
node_merge -->|"writes to"| node_store
node_network -->|"abstracts through"| node_transport
node_network -->|"includes"| node_sync_mod
node_network -->|"includes"| node_serve
node_sync_mod -->|"syncs"| node_store
node_serve -->|"serves"| node_store

click node_src_main "https://github.com/cod-e-codes/astvcs/blob/main/src/main.rs"
click node_src_lib "https://github.com/cod-e-codes/astvcs/blob/main/src/lib.rs"
click node_intent "https://github.com/cod-e-codes/astvcs/blob/main/src/intent/mod.rs"
click node_store "https://github.com/cod-e-codes/astvcs/blob/main/src/store/mod.rs"
click node_repo "https://github.com/cod-e-codes/astvcs/blob/main/src/store/repo.rs"
click node_history "https://github.com/cod-e-codes/astvcs/blob/main/src/store/history.rs"
click node_staging "https://github.com/cod-e-codes/astvcs/blob/main/src/store/staging.rs"
click node_working "https://github.com/cod-e-codes/astvcs/blob/main/src/store/working.rs"
click node_blobs "https://github.com/cod-e-codes/astvcs/blob/main/src/store/blobs.rs"
click node_manifest "https://github.com/cod-e-codes/astvcs/blob/main/src/store/manifest.rs"
click node_graph "https://github.com/cod-e-codes/astvcs/blob/main/src/graph/mod.rs"
click node_frontend "https://github.com/cod-e-codes/astvcs/blob/main/src/frontend/mod.rs"
click node_treesitter "https://github.com/cod-e-codes/astvcs/blob/main/src/frontend/treesitter.rs"
click node_textblob "https://github.com/cod-e-codes/astvcs/blob/main/src/frontend/textblob.rs"
click node_binaryblob "https://github.com/cod-e-codes/astvcs/blob/main/src/frontend/binaryblob.rs"
click node_diff "https://github.com/cod-e-codes/astvcs/blob/main/src/diff/mod.rs"
click node_merge "https://github.com/cod-e-codes/astvcs/blob/main/src/merge/mod.rs"
click node_network "https://github.com/cod-e-codes/astvcs/blob/main/src/network/mod.rs"
click node_sync_mod "https://github.com/cod-e-codes/astvcs/blob/main/src/network/sync.rs"
click node_serve "https://github.com/cod-e-codes/astvcs/blob/main/src/network/serve.rs"
click node_transport "https://github.com/cod-e-codes/astvcs/blob/main/src/network/transport.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_src_main,node_intent toneBlue
class node_src_lib,node_store,node_repo,node_history,node_staging,node_working,node_blobs,node_manifest,node_graph toneAmber
class node_frontend,node_treesitter,node_textblob,node_binaryblob,node_diff,node_merge toneMint
class node_network,node_sync_mod,node_serve,node_transport toneRose
```

## Components

### CLI surface

Command entrypoints and command-to-action orchestration

- [main](https://github.com/cod-e-codes/astvcs/blob/main/src/main.rs): cli binary · CLI executable entrypoint · `src/main.rs`
- [intent](https://github.com/cod-e-codes/astvcs/blob/main/src/intent/mod.rs): command orchestration · Maps CLI commands to repository actions · `src/intent/mod.rs`

### Repository core

Persistence, history, and working-tree state under .astvcs

- [lib](https://github.com/cod-e-codes/astvcs/blob/main/src/lib.rs): core library · Reusable crate entrypoint for the repository engine · `src/lib.rs`
- [store](https://github.com/cod-e-codes/astvcs/blob/main/src/store/mod.rs): repository state · Main persistence layer for .astvcs state · `src/store/mod.rs`
- [repo](https://github.com/cod-e-codes/astvcs/blob/main/src/store/repo.rs): repo lifecycle · Repository initialization and top-level operations · `src/store/repo.rs`
- [history](https://github.com/cod-e-codes/astvcs/blob/main/src/store/history.rs): commit timeline · Commit history and revision-oriented operations · `src/store/history.rs`
- [staging](https://github.com/cod-e-codes/astvcs/blob/main/src/store/staging.rs): index layer · Tracks staged changes between working tree and history · `src/store/staging.rs`
- [working tree](https://github.com/cod-e-codes/astvcs/blob/main/src/store/working.rs): filesystem view · Working-tree scanning and file state tracking · `src/store/working.rs`
- [blobs](https://github.com/cod-e-codes/astvcs/blob/main/src/store/blobs.rs): content store · Blob storage and content-addressed file data · `src/store/blobs.rs`
- [manifest](https://github.com/cod-e-codes/astvcs/blob/main/src/store/manifest.rs): tree state · Manifest and tracked path snapshots · `src/store/manifest.rs`
- [graph](https://github.com/cod-e-codes/astvcs/blob/main/src/graph/mod.rs): commit DAG · Repository graph of nodes, edges, and mutations · `src/graph/mod.rs`

### Content processing

File classification, structural diffing, and merge resolution

- [frontend](https://github.com/cod-e-codes/astvcs/blob/main/src/frontend/mod.rs): file classification · Chooses structural, text, binary, or symlink representation · `src/frontend/mod.rs`
- [tree-sitter](https://github.com/cod-e-codes/astvcs/blob/main/src/frontend/treesitter.rs): AST parser bridge · Structural parsing support for parseable file types · `src/frontend/treesitter.rs`
- [text blob](https://github.com/cod-e-codes/astvcs/blob/main/src/frontend/textblob.rs): utf8 content · Fallback representation for text files · `src/frontend/textblob.rs`
- [binary blob](https://github.com/cod-e-codes/astvcs/blob/main/src/frontend/binaryblob.rs): raw bytes · Fallback representation for non-text files · `src/frontend/binaryblob.rs`
- [diff](https://github.com/cod-e-codes/astvcs/blob/main/src/diff/mod.rs): comparison engine · Structural and text comparison pipeline · `src/diff/mod.rs`
- [merge](https://github.com/cod-e-codes/astvcs/blob/main/src/merge/mod.rs): three-way merge · Resolves non-overlapping structural edits and conflicts · `src/merge/mod.rs`

### Sync layer

Remote transport, serving, and synchronization

- [network](https://github.com/cod-e-codes/astvcs/blob/main/src/network/mod.rs): remote sync · Remote transport, serving, and synchronization · `src/network/mod.rs`
- [sync](https://github.com/cod-e-codes/astvcs/blob/main/src/network/sync.rs): repository sync · Client-side repository synchronization flows · `src/network/sync.rs`
- [serve](https://github.com/cod-e-codes/astvcs/blob/main/src/network/serve.rs): remote server · Server-side repository serving entrypoint · `src/network/serve.rs`
- [transport](https://github.com/cod-e-codes/astvcs/blob/main/src/network/transport.rs): protocol layer · Abstraction over local, HTTP, HTTPS, and SSH transport · `src/network/transport.rs`

## Connections

- main → intent: dispatches · CLI hands parsed commands to orchestration
- intent → store: operates on · High-level commands act on repository state
- intent → diff: requests · User-facing diff and compare commands
- intent → merge: requests · Merge and conflict-oriented commands
- intent → network: requests · Fetch/clone/serve synchronization commands
- lib → store: exports · Library exposes the repository core
- lib → graph: exports · Library exposes history graph structures
- store → repo: includes · Repository lifecycle and top-level state
- store → history: includes · Commit timeline and revision queries
- store → staging: includes · Staging and index state
- store → working tree: includes · Working-tree interaction and scans
- store → blobs: includes · Content-addressed blob storage
- store → manifest: includes · Tracked tree and snapshot state
- store → graph: uses · History-backed operations depend on the DAG model
- working tree → frontend: classifies via · Files are classified before storage or diffing
- frontend → tree-sitter: uses · Parseable files become structural blobs
- frontend → text blob: falls back to · UTF-8 files use text representation
- frontend → binary blob: falls back to · Unparseable non-text files use raw bytes
- diff → graph: compares history · Structural history and rename logic rely on commit graph context
- diff → frontend: compares content · Diff operates on file representations from the frontend
- merge → diff: aligns with · Merge uses diff correspondence for three-way resolution
- merge → store: writes to · Resolved results are persisted back into repository state
- network → transport: abstracts through · Network operations route through transport implementations
- network → sync: includes · Client-side sync flows
- network → serve: includes · Server-side serving flows
- sync → store: syncs · Remote sync reads and updates repository state
- serve → store: serves · Repository data is exposed from local store state
