# vadim-schultz/vault architecture

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

- Interactive diagram: https://gitdiagram.com/vadim-schultz/vault
- Repository: https://github.com/vadim-schultz/vault

## Overview

Vault is a background file-versioning product: users initialize a worktree, after which a daemon watches configured files and records changes in Git-backed history with a SQLite metadata index. Users can inspect status, list or compare history, restore older versions, and maintain or rebuild the vault. The graph combines documented user capabilities with source-index relationships; several command and app implementations were not sampled, so those links are omitted or marked unverified rather than inferred as definite calls.

Main entry points: [`src/app/snapshot.rs`](https://github.com/vadim-schultz/vault/blob/main/src/app/snapshot.rs) (Record snapshot), [`src/cli/commands`](https://github.com/vadim-schultz/vault/tree/main/src/cli/commands) (History commands), [`src/storage/git/mod.rs`](https://github.com/vadim-schultz/vault/blob/main/src/storage/git/mod.rs) (Git object history), [`src/storage/sqlite/mod.rs`](https://github.com/vadim-schultz/vault/blob/main/src/storage/sqlite/mod.rs) (SQLite metadata)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interface"]
  node_cli["CLI commands<br/>[mod.rs]"]
  node_init["Initialize vault<br/>[init.rs]"]
  node_history_cli["History commands"]
end

subgraph group_capture["Change capture"]
  node_watcher["Filesystem watcher<br/>[mod.rs]"]
  node_router["Event router<br/>[router.rs]"]
  node_worker["Snapshot worker<br/>[worker.rs]"]
  node_walk["Worktree walker<br/>[walk.rs]"]
  node_ignore["Ignore matching<br/>[ignore.rs]"]
  node_config["Vault configuration<br/>[mod.rs]"]
end

subgraph group_work["Background processing"]
  node_daemon["Vault daemon<br/>[mod.rs]"]
  node_queue["Background queue<br/>[mod.rs]"]
  node_handlers["Task handlers<br/>[handlers.rs]"]
end

subgraph group_history["History operations"]
  node_snapshot_app["Record snapshot<br/>[snapshot.rs]"]
  node_history_app["Show and restore<br/>[show.rs]"]
  node_diff_app["Diff history<br/>[diff.rs]"]
  node_status_app["Vault status<br/>[mod.rs]"]
  node_reindex_app["Rebuild index<br/>[reindex.rs]"]
  node_domain["History domain"]
end

subgraph group_persistence["Persistence"]
  node_git[("Git object history<br/>[mod.rs]")]
  node_meta[("SQLite metadata<br/>[mod.rs]")]
  node_housekeeping["Git housekeeping<br/>[mod.rs]"]
  node_registry["Vault registry<br/>[registry.rs]"]
  node_adapters["System adapters"]
  node_paths["Vault paths<br/>[paths.rs]"]
end

node_user(("Vault user"))

node_user -->|"runs commands"| node_cli
node_cli -.->|"initializes"| node_init
node_cli -->|"invokes"| node_history_cli
node_history_cli -.->|"dispatches to"| node_history_app
node_history_cli -.->|"dispatches to"| node_diff_app
node_history_cli -.->|"dispatches to"| node_status_app
node_history_cli -.->|"dispatches to"| node_reindex_app
node_daemon -->|"runs"| node_watcher
node_watcher -->|"routes events"| node_router
node_watcher -->|"spawns"| node_worker
node_worker -->|"uses"| node_router
node_worker -->|"records changes"| node_snapshot_app
node_router -->|"filters paths"| node_ignore
node_router -->|"checks vaults"| node_registry
node_walk -->|"filters entries"| node_ignore
node_walk -->|"uses settings"| node_config
node_daemon -->|"starts runner"| node_queue
node_daemon -->|"loads vaults"| node_registry
node_queue -->|"runs tasks"| node_handlers
node_handlers -->|"reconciles files"| node_snapshot_app
node_handlers -->|"walks worktree"| node_walk
node_handlers -->|"runs maintenance"| node_housekeeping
node_snapshot_app -->|"collects baseline"| node_walk
node_snapshot_app -->|"writes history"| node_git
node_snapshot_app -.->|"indexes snapshots"| node_meta
node_snapshot_app -->|"uses records"| node_domain
node_history_app -.->|"reads versions"| node_git
node_history_app -.->|"queries timestamps"| node_meta
node_diff_app -.->|"compares trees"| node_git
node_status_app -->|"reads status"| node_housekeeping
node_status_app -.->|"reads index"| node_meta
node_reindex_app -.->|"rebuilds from history"| node_git
node_reindex_app -->|"rebuilds index"| node_meta
node_housekeeping -->|"repacks objects"| node_git
node_adapters -.->|"implements index"| node_meta
node_adapters -.->|"implements registry"| node_registry
node_paths -->|"resolves layout"| node_domain
node_daemon -->|"resolves daemon files"| node_paths

click node_cli "https://github.com/vadim-schultz/vault/blob/main/src/cli/mod.rs"
click node_init "https://github.com/vadim-schultz/vault/blob/main/src/app/init.rs"
click node_history_cli "https://github.com/vadim-schultz/vault/tree/main/src/cli/commands"
click node_daemon "https://github.com/vadim-schultz/vault/blob/main/src/daemon/mod.rs"
click node_watcher "https://github.com/vadim-schultz/vault/blob/main/src/watcher/mod.rs"
click node_router "https://github.com/vadim-schultz/vault/blob/main/src/watcher/router.rs"
click node_worker "https://github.com/vadim-schultz/vault/blob/main/src/watcher/worker.rs"
click node_walk "https://github.com/vadim-schultz/vault/blob/main/src/walk.rs"
click node_ignore "https://github.com/vadim-schultz/vault/blob/main/src/ignore.rs"
click node_config "https://github.com/vadim-schultz/vault/blob/main/src/config/mod.rs"
click node_queue "https://github.com/vadim-schultz/vault/blob/main/src/queue/mod.rs"
click node_handlers "https://github.com/vadim-schultz/vault/blob/main/src/queue/handlers.rs"
click node_snapshot_app "https://github.com/vadim-schultz/vault/blob/main/src/app/snapshot.rs"
click node_history_app "https://github.com/vadim-schultz/vault/blob/main/src/app/show.rs"
click node_diff_app "https://github.com/vadim-schultz/vault/blob/main/src/app/diff.rs"
click node_status_app "https://github.com/vadim-schultz/vault/blob/main/src/app/status/mod.rs"
click node_reindex_app "https://github.com/vadim-schultz/vault/blob/main/src/app/reindex.rs"
click node_domain "https://github.com/vadim-schultz/vault/tree/main/src/domain"
click node_git "https://github.com/vadim-schultz/vault/blob/main/src/storage/git/mod.rs"
click node_meta "https://github.com/vadim-schultz/vault/blob/main/src/storage/sqlite/mod.rs"
click node_housekeeping "https://github.com/vadim-schultz/vault/blob/main/src/storage/housekeeping/mod.rs"
click node_registry "https://github.com/vadim-schultz/vault/blob/main/src/registry.rs"
click node_adapters "https://github.com/vadim-schultz/vault/tree/main/src/adapters"
click node_paths "https://github.com/vadim-schultz/vault/blob/main/src/paths.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_cli,node_init,node_history_cli,node_user toneBlue
class node_watcher,node_router,node_worker,node_walk,node_ignore,node_config toneAmber
class node_daemon,node_queue,node_handlers toneMint
class node_snapshot_app,node_history_app,node_diff_app,node_status_app,node_reindex_app,node_domain toneRose
class node_git,node_meta,node_housekeeping,node_registry,node_adapters,node_paths toneIndigo
```

## Components

### User interface

- [CLI commands](https://github.com/vadim-schultz/vault/blob/main/src/cli/mod.rs): `src/cli/mod.rs`
- [Initialize vault](https://github.com/vadim-schultz/vault/blob/main/src/app/init.rs): `src/app/init.rs`
- [History commands](https://github.com/vadim-schultz/vault/tree/main/src/cli/commands): `src/cli/commands`

### Change capture

- [Filesystem watcher](https://github.com/vadim-schultz/vault/blob/main/src/watcher/mod.rs): `src/watcher/mod.rs`
- [Event router](https://github.com/vadim-schultz/vault/blob/main/src/watcher/router.rs): `src/watcher/router.rs`
- [Snapshot worker](https://github.com/vadim-schultz/vault/blob/main/src/watcher/worker.rs): `src/watcher/worker.rs`
- [Worktree walker](https://github.com/vadim-schultz/vault/blob/main/src/walk.rs): `src/walk.rs`
- [Ignore matching](https://github.com/vadim-schultz/vault/blob/main/src/ignore.rs): `src/ignore.rs`
- [Vault configuration](https://github.com/vadim-schultz/vault/blob/main/src/config/mod.rs): `src/config/mod.rs`

### Background processing

- [Vault daemon](https://github.com/vadim-schultz/vault/blob/main/src/daemon/mod.rs): `src/daemon/mod.rs`
- [Background queue](https://github.com/vadim-schultz/vault/blob/main/src/queue/mod.rs): `src/queue/mod.rs`
- [Task handlers](https://github.com/vadim-schultz/vault/blob/main/src/queue/handlers.rs): `src/queue/handlers.rs`

### History operations

- [Record snapshot](https://github.com/vadim-schultz/vault/blob/main/src/app/snapshot.rs): `src/app/snapshot.rs`
- [Show and restore](https://github.com/vadim-schultz/vault/blob/main/src/app/show.rs): `src/app/show.rs`
- [Diff history](https://github.com/vadim-schultz/vault/blob/main/src/app/diff.rs): `src/app/diff.rs`
- [Vault status](https://github.com/vadim-schultz/vault/blob/main/src/app/status/mod.rs): `src/app/status/mod.rs`
- [Rebuild index](https://github.com/vadim-schultz/vault/blob/main/src/app/reindex.rs): `src/app/reindex.rs`
- [History domain](https://github.com/vadim-schultz/vault/tree/main/src/domain): `src/domain`

### Persistence

- [Git object history](https://github.com/vadim-schultz/vault/blob/main/src/storage/git/mod.rs): `src/storage/git/mod.rs`
- [SQLite metadata](https://github.com/vadim-schultz/vault/blob/main/src/storage/sqlite/mod.rs): `src/storage/sqlite/mod.rs`
- [Git housekeeping](https://github.com/vadim-schultz/vault/blob/main/src/storage/housekeeping/mod.rs): `src/storage/housekeeping/mod.rs`
- [Vault registry](https://github.com/vadim-schultz/vault/blob/main/src/registry.rs): `src/registry.rs`
- [System adapters](https://github.com/vadim-schultz/vault/tree/main/src/adapters): `src/adapters`
- [Vault paths](https://github.com/vadim-schultz/vault/blob/main/src/paths.rs): `src/paths.rs`

### Other components

- **Vault user**

## Connections

- Vault user → CLI commands: runs commands (evidence: `README.md`)
- CLI commands → Initialize vault: initializes
- CLI commands → History commands: invokes (evidence: `src/cli/mod.rs`)
- History commands → Show and restore: dispatches to
- History commands → Diff history: dispatches to
- History commands → Vault status: dispatches to
- History commands → Rebuild index: dispatches to
- Vault daemon → Filesystem watcher: runs (evidence: `src/daemon/mod.rs`)
- Filesystem watcher → Event router: routes events (evidence: `src/watcher/mod.rs`)
- Filesystem watcher → Snapshot worker: spawns (evidence: `src/watcher/mod.rs`)
- Snapshot worker → Event router: uses (evidence: `src/watcher/worker.rs`)
- Snapshot worker → Record snapshot: records changes (evidence: `src/watcher/worker.rs`)
- Event router → Ignore matching: filters paths (evidence: `src/watcher/router.rs`)
- Event router → Vault registry: checks vaults (evidence: `src/watcher/router.rs`)
- Worktree walker → Ignore matching: filters entries (evidence: `src/walk.rs`)
- Worktree walker → Vault configuration: uses settings (evidence: `src/walk.rs`)
- Vault daemon → Background queue: starts runner (evidence: `src/daemon/mod.rs`)
- Vault daemon → Vault registry: loads vaults (evidence: `src/daemon/mod.rs`)
- Background queue → Task handlers: runs tasks (evidence: `src/queue/mod.rs`)
- Task handlers → Record snapshot: reconciles files (evidence: `src/queue/handlers.rs`)
- Task handlers → Worktree walker: walks worktree (evidence: `src/queue/handlers.rs`)
- Task handlers → Git housekeeping: runs maintenance (evidence: `src/queue/handlers.rs`)
- Record snapshot → Worktree walker: collects baseline (evidence: `src/app/snapshot.rs`)
- Record snapshot → Git object history: writes history (evidence: `src/app/snapshot.rs`)
- Record snapshot → SQLite metadata: indexes snapshots
- Record snapshot → History domain: uses records (evidence: `src/app/snapshot.rs`)
- Show and restore → Git object history: reads versions
- Show and restore → SQLite metadata: queries timestamps
- Diff history → Git object history: compares trees
- Vault status → Git housekeeping: reads status (evidence: `src/app/status/mod.rs`)
- Vault status → SQLite metadata: reads index (evidence: `src/app/status/mod.rs`)
- Rebuild index → Git object history: rebuilds from history
- Rebuild index → SQLite metadata: rebuilds index (evidence: `src/app/reindex.rs`)
- Git housekeeping → Git object history: repacks objects (evidence: `src/storage/housekeeping/mod.rs`)
- System adapters → SQLite metadata: implements index
- System adapters → Vault registry: implements registry
- Vault paths → History domain: resolves layout (evidence: `src/paths.rs`)
- Vault daemon → Vault paths: resolves daemon files (evidence: `src/daemon/mod.rs`)
