# vairan37/snatch architecture

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

- Interactive diagram: https://gitdiagram.com/vairan37/snatch
- Repository: https://github.com/vairan37/snatch

## Overview

Snatch is a Git snapshot manager for AI-assisted development: users capture lightweight snapshots, inspect diffs, restore or delete them, and squash a session into a regular commit. The desktop UI fronts a Rust CLI sidecar, which operates on Git repositories and stores snapshots under hidden refs. The README also describes project selection, AI-assisted pre-prompt saves, Git history, settings, and an integrated terminal. UI-to-CLI and sampled command relationships are supported by excerpts; some unsampled command internals and Tauri wiring are not shown.

Main entry points: [`snatch-ui/src/App.tsx`](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/App.tsx) (App Shell), [`src/main.rs`](https://github.com/vairan37/snatch/blob/main/src/main.rs) (CLI Dispatcher), [`src/git/refs.rs`](https://github.com/vairan37/snatch/blob/main/src/git/refs.rs) (Snapshot Refs), [`snatch-ui/src/components/SnapshotsModule.tsx`](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/SnapshotsModule.tsx) (Snapshots Panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop UI"]
  node_app["App Shell<br/>[App.tsx]"]
  node_welcome["Project Picker<br/>[WelcomeScreen.tsx]"]
  node_snapshots["Snapshots Panel"]
  node_diffview["Diff Viewer<br/>[DiffViewer.tsx]"]
  node_savebar["Save Bar<br/>[SaveBar.tsx]"]
  node_squashmodal["Squash Dialog<br/>[SquashModal.tsx]"]
  node_gitgraph["Git Graph<br/>[GitGraph.tsx]"]
  node_settingsui["Settings UI<br/>[SettingsModule.tsx]"]
  node_chat["AI Chat<br/>[ChatModule.tsx]"]
  node_terminal["Integrated Terminal<br/>[Terminal.tsx]"]
end

subgraph group_bridge["CLI Bridge"]
  node_snatchapi["Sidecar Client<br/>[snatch.ts]"]
  node_dispatcher["CLI Dispatcher<br/>[main.rs]"]
end

subgraph group_engine["Snapshot Engine"]
  node_init["Repository Init<br/>[init.rs]"]
  node_save["Snapshot Capture<br/>[save.rs]"]
  node_list["Snapshot Listing<br/>[list.rs]"]
  node_diff["Snapshot Diff<br/>[diff.rs]"]
  node_restore["Snapshot Restore<br/>[restore.rs]"]
  node_drop["Snapshot Deletion<br/>[drop.rs]"]
  node_squash["Session Squash<br/>[squash.rs]"]
  node_refs["Snapshot Refs<br/>[refs.rs]"]
  node_snapshotmodel["Snapshot Metadata<br/>[snapshot.rs]"]
  node_config["CLI Config<br/>[config.rs]"]
end

subgraph group_project["Project Services"]
  node_settings[("App Settings<br/>[settings.ts]")]
  node_gitclient["Git Commands<br/>[git.ts]"]
  node_aiclient["AI Providers<br/>[ai.ts]"]
end

node_user(("Developer"))
node_git[("Git Repository")]
node_providers["AI Services"]

node_user -->|"uses"| node_app
node_app -->|"shows"| node_welcome
node_app -->|"shows"| node_snapshots
node_app -->|"shows"| node_gitgraph
node_app -->|"shows"| node_settingsui
node_app -->|"shows"| node_chat
node_app -->|"shows"| node_terminal
node_app -->|"loads"| node_settings
node_app -->|"calls"| node_snatchapi
node_app -->|"calls"| node_gitclient
node_snapshots -->|"calls"| node_snatchapi
node_snapshots -->|"renders"| node_diffview
node_snapshots -->|"renders"| node_savebar
node_snapshots -->|"renders"| node_squashmodal
node_snatchapi -->|"executes sidecar"| node_dispatcher
node_dispatcher -->|"dispatches"| node_init
node_dispatcher -->|"dispatches"| node_save
node_dispatcher -->|"dispatches"| node_list
node_dispatcher -->|"dispatches"| node_diff
node_dispatcher -->|"dispatches"| node_drop
node_dispatcher -->|"dispatches"| node_restore
node_dispatcher -->|"dispatches"| node_squash
node_save -->|"updates refs"| node_refs
node_save -->|"creates metadata"| node_snapshotmodel
node_list -->|"lists refs"| node_refs
node_list -->|"reads metadata"| node_snapshotmodel
node_diff -->|"resolves snapshot"| node_refs
node_restore -->|"resolves snapshot"| node_refs
node_drop -->|"deletes ref"| node_refs
node_squash -->|"lists and deletes"| node_refs
node_squash -->|"reads metadata"| node_snapshotmodel
node_dispatcher -->|"loads"| node_config
node_list -->|"formats output"| node_config
node_refs -.->|"manages hidden refs"| node_git
node_gitclient -->|"runs commands"| node_git
node_settingsui -->|"reads settings"| node_settings
node_chat -->|"saves snapshots"| node_snatchapi
node_chat -->|"requests AI"| node_aiclient
node_aiclient -.->|"calls providers"| node_providers

click node_app "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/App.tsx"
click node_welcome "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/WelcomeScreen.tsx"
click node_snapshots "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/SnapshotsModule.tsx"
click node_diffview "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/DiffViewer.tsx"
click node_savebar "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/SaveBar.tsx"
click node_squashmodal "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/SquashModal.tsx"
click node_gitgraph "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/GitGraph.tsx"
click node_settingsui "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/SettingsModule.tsx"
click node_chat "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/ChatModule.tsx"
click node_terminal "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/Terminal.tsx"
click node_snatchapi "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/lib/snatch.ts"
click node_dispatcher "https://github.com/vairan37/snatch/blob/main/src/main.rs"
click node_init "https://github.com/vairan37/snatch/blob/main/src/commands/init.rs"
click node_save "https://github.com/vairan37/snatch/blob/main/src/commands/save.rs"
click node_list "https://github.com/vairan37/snatch/blob/main/src/commands/list.rs"
click node_diff "https://github.com/vairan37/snatch/blob/main/src/commands/diff.rs"
click node_restore "https://github.com/vairan37/snatch/blob/main/src/commands/restore.rs"
click node_drop "https://github.com/vairan37/snatch/blob/main/src/commands/drop.rs"
click node_squash "https://github.com/vairan37/snatch/blob/main/src/commands/squash.rs"
click node_refs "https://github.com/vairan37/snatch/blob/main/src/git/refs.rs"
click node_snapshotmodel "https://github.com/vairan37/snatch/blob/main/src/git/snapshot.rs"
click node_config "https://github.com/vairan37/snatch/blob/main/src/config.rs"
click node_settings "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/lib/settings.ts"
click node_gitclient "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/lib/git.ts"
click node_aiclient "https://github.com/vairan37/snatch/blob/main/snatch-ui/src/lib/ai.ts"

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_app,node_welcome,node_snapshots,node_diffview,node_savebar,node_squashmodal,node_gitgraph,node_settingsui,node_chat,node_terminal toneBlue
class node_snatchapi,node_dispatcher,node_git toneAmber
class node_init,node_save,node_list,node_diff,node_restore,node_drop,node_squash,node_refs,node_snapshotmodel,node_config toneMint
class node_settings,node_gitclient,node_aiclient toneRose
class node_user,node_providers toneIndigo
```

## Components

### Desktop UI

- [App Shell](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/App.tsx): `snatch-ui/src/App.tsx`
- [Project Picker](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/WelcomeScreen.tsx): `snatch-ui/src/components/WelcomeScreen.tsx`
- [Snapshots Panel](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/SnapshotsModule.tsx): `snatch-ui/src/components/SnapshotsModule.tsx`
- [Diff Viewer](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/DiffViewer.tsx): `snatch-ui/src/components/DiffViewer.tsx`
- [Save Bar](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/SaveBar.tsx): `snatch-ui/src/components/SaveBar.tsx`
- [Squash Dialog](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/SquashModal.tsx): `snatch-ui/src/components/SquashModal.tsx`
- [Git Graph](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/GitGraph.tsx): `snatch-ui/src/components/GitGraph.tsx`
- [Settings UI](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/SettingsModule.tsx): `snatch-ui/src/components/SettingsModule.tsx`
- [AI Chat](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/ChatModule.tsx): `snatch-ui/src/components/ChatModule.tsx`
- [Integrated Terminal](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/components/Terminal.tsx): `snatch-ui/src/components/Terminal.tsx`

### CLI Bridge

- [Sidecar Client](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/lib/snatch.ts): `snatch-ui/src/lib/snatch.ts`
- [CLI Dispatcher](https://github.com/vairan37/snatch/blob/main/src/main.rs): `src/main.rs`

### Snapshot Engine

- [Repository Init](https://github.com/vairan37/snatch/blob/main/src/commands/init.rs): `src/commands/init.rs`
- [Snapshot Capture](https://github.com/vairan37/snatch/blob/main/src/commands/save.rs): `src/commands/save.rs`
- [Snapshot Listing](https://github.com/vairan37/snatch/blob/main/src/commands/list.rs): `src/commands/list.rs`
- [Snapshot Diff](https://github.com/vairan37/snatch/blob/main/src/commands/diff.rs): `src/commands/diff.rs`
- [Snapshot Restore](https://github.com/vairan37/snatch/blob/main/src/commands/restore.rs): `src/commands/restore.rs`
- [Snapshot Deletion](https://github.com/vairan37/snatch/blob/main/src/commands/drop.rs): `src/commands/drop.rs`
- [Session Squash](https://github.com/vairan37/snatch/blob/main/src/commands/squash.rs): `src/commands/squash.rs`
- [Snapshot Refs](https://github.com/vairan37/snatch/blob/main/src/git/refs.rs): `src/git/refs.rs`
- [Snapshot Metadata](https://github.com/vairan37/snatch/blob/main/src/git/snapshot.rs): `src/git/snapshot.rs`
- [CLI Config](https://github.com/vairan37/snatch/blob/main/src/config.rs): `src/config.rs`

### Project Services

- [App Settings](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/lib/settings.ts): `snatch-ui/src/lib/settings.ts`
- [Git Commands](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/lib/git.ts): `snatch-ui/src/lib/git.ts`
- [AI Providers](https://github.com/vairan37/snatch/blob/main/snatch-ui/src/lib/ai.ts): `snatch-ui/src/lib/ai.ts`

### Other components

- **Developer**
- **Git Repository**
- **AI Services**

## Connections

- Developer → App Shell: uses (evidence: `README.md`)
- App Shell → Project Picker: shows (evidence: `snatch-ui/src/App.tsx`)
- App Shell → Snapshots Panel: shows (evidence: `snatch-ui/src/App.tsx`)
- App Shell → Git Graph: shows (evidence: `snatch-ui/src/App.tsx`)
- App Shell → Settings UI: shows (evidence: `snatch-ui/src/App.tsx`)
- App Shell → AI Chat: shows (evidence: `snatch-ui/src/App.tsx`)
- App Shell → Integrated Terminal: shows (evidence: `snatch-ui/src/App.tsx`)
- App Shell → App Settings: loads (evidence: `snatch-ui/src/App.tsx`)
- App Shell → Sidecar Client: calls (evidence: `snatch-ui/src/App.tsx`)
- App Shell → Git Commands: calls (evidence: `snatch-ui/src/App.tsx`)
- Snapshots Panel → Sidecar Client: calls (evidence: `snatch-ui/src/components/SnapshotsModule.tsx`)
- Snapshots Panel → Diff Viewer: renders (evidence: `snatch-ui/src/components/SnapshotsModule.tsx`)
- Snapshots Panel → Save Bar: renders (evidence: `snatch-ui/src/components/SnapshotsModule.tsx`)
- Snapshots Panel → Squash Dialog: renders (evidence: `snatch-ui/src/components/SnapshotsModule.tsx`)
- Sidecar Client → CLI Dispatcher: executes sidecar (evidence: `snatch-ui/src/lib/snatch.ts`)
- CLI Dispatcher → Repository Init: dispatches (evidence: `src/main.rs`)
- CLI Dispatcher → Snapshot Capture: dispatches (evidence: `src/main.rs`)
- CLI Dispatcher → Snapshot Listing: dispatches (evidence: `src/main.rs`)
- CLI Dispatcher → Snapshot Diff: dispatches (evidence: `src/main.rs`)
- CLI Dispatcher → Snapshot Deletion: dispatches (evidence: `src/main.rs`)
- CLI Dispatcher → Snapshot Restore: dispatches (evidence: `src/main.rs`)
- CLI Dispatcher → Session Squash: dispatches (evidence: `src/main.rs`)
- Snapshot Capture → Snapshot Refs: updates refs (evidence: `src/commands/save.rs`)
- Snapshot Capture → Snapshot Metadata: creates metadata (evidence: `src/commands/save.rs`)
- Snapshot Listing → Snapshot Refs: lists refs (evidence: `src/commands/list.rs`)
- Snapshot Listing → Snapshot Metadata: reads metadata (evidence: `src/commands/list.rs`)
- Snapshot Diff → Snapshot Refs: resolves snapshot (evidence: `src/commands/diff.rs`)
- Snapshot Restore → Snapshot Refs: resolves snapshot (evidence: `src/commands/restore.rs`)
- Snapshot Deletion → Snapshot Refs: deletes ref (evidence: `src/commands/drop.rs`)
- Session Squash → Snapshot Refs: lists and deletes (evidence: `src/commands/squash.rs`)
- Session Squash → Snapshot Metadata: reads metadata (evidence: `src/commands/squash.rs`)
- CLI Dispatcher → CLI Config: loads (evidence: `src/main.rs`)
- Snapshot Listing → CLI Config: formats output (evidence: `src/commands/list.rs`)
- Snapshot Refs → Git Repository: manages hidden refs (evidence: `README.md`)
- Git Commands → Git Repository: runs commands (evidence: `snatch-ui/src/lib/git.ts`)
- Settings UI → App Settings: reads settings (evidence: `snatch-ui/src/components/SettingsModule.tsx`)
- AI Chat → Sidecar Client: saves snapshots (evidence: `snatch-ui/src/components/ChatModule.tsx`)
- AI Chat → AI Providers: requests AI (evidence: `snatch-ui/src/components/ChatModule.tsx`)
- AI Providers → AI Services: calls providers
