# rap20092003/hyprdrive architecture

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

- Interactive diagram: https://gitdiagram.com/rap20092003/hyprdrive
- Repository: https://github.com/rap20092003/hyprdrive

## Overview

1. **Repository shape**
   - This is a Rust workspace with a small TypeScript/UI surface on top.
   - The architecture is centered on a **background daemon**; most other crates either feed it data, persist its state, or consume its API.

2. **Main runtime boundary: `apps/daemon`**
   - `hyprdrive-daemon` is the system of record and the primary orchestration layer.
   - It ties together filesystem scanning, event watching, object processing, hashing, deduplication, and disk-intelligence queries.
   - Tests in `apps/daemon/tests` indicate the daemon owns the important end-to-end flows.

3. **Filesystem ingestion path**
   - `crates/fs-indexer` is the platform abstraction for discovering files and monitoring changes.
   - It has OS-specific implementations for:
     - **Windows**: NTFS MFT, USN journal, helper pipe integration
     - **Linux**: io_uring scanning plus inotify-style listening
     - **macOS**: getattrlistbulk-style scanning and listener support
   - This crate is the boundary between raw OS filesystem APIs and the rest of the system.

4. **Change detection and event normalization**
   - The watcher layer in `apps/daemon/src/watcher.rs` and the `change_processor` in `crates/object-pipeline` turn low-level file events into stable domain updates.
   - The system emphasizes **event coalescing and debouncing**, so the pipeline works on normalized batches rather than every raw OS notification.

5. **Object pipeline: scan → hash → upsert**
   - `crates/object-pipeline` is the core ingestion pipeline.
   - It supports **deferred hashing**: files get synthetic identities first, then a `background_hasher` upgrades them to real content hashes later.
   - This design is important architecturally because it splits “fast first pass” indexing from “content-verified” state.

6. **Content addressing and duplicate logic**
   - File identity is BLAKE3-based and content-addressed, which makes duplicates and moves/renames stable across path changes.
   - `crates/dedup-engine` provides three duplicate strategies:
     - exact content hash
     - fuzzy filename matching
     - perceptual image matching
   - The dedup engine is a consumer of indexed metadata, not the primary source of truth.

7. **Persistence layer**
   - `core` owns the durable schema and domain model.
   - SQLite is the main metadata store, with migrations in `core/migrations` and DB access through `core/src/db`.
   - The readme and tree show a second embedded store, **redb**, used for fast caches such as inode cache and cursor store.
   - This creates a two-tier storage model: SQLite for canonical metadata, redb for low-latency lookup state.

8. **Domain model and query boundary**
   - `core/src/domain` defines the shared types for IDs, paths, filters, tags, sync concepts, undo, virtual folders, and sort/sort-like behavior.
   - These types are the contract between ingestion, persistence, search, and clients.
   - `core/src/db/queries.rs` suggests the SQL boundary is centralized rather than scattered across crates.

9. **Analysis and derived views**
   - `crates/disk-intelligence` computes volume summaries, treemaps, and wasted-space style analytics from indexed metadata.
   - This is a read-heavy subsystem layered on top of the stored file graph, not a separate ingestion pipeline.
   - It likely feeds UI/dashboard-style views rather than modifying core state.

10. **Client/API surface**
   - `crates/ipc-protocol`, `crates/sdk`, `crates/sdk-macros`, and the TypeScript packages (`packages/interface`, `packages/ts-client`, `packages/ui`) form the API boundary for non-daemon consumers.
   - `apps/cli` is the simplest client, while `apps/tauri` and `apps/web` are UI shells.
   - The repo is therefore daemon-first: clients talk to the daemon rather than owning storage or indexing logic themselves.

11. **Platform privilege helpers**
   - The `helpers/` binaries exist to access OS features that may require elevated privileges or special system integration.
   - Windows uses a service/pipe-based helper, macOS has a helper app, and Linux has a helper binary for privileged filesystem access.
   - These helpers sit outside the main daemon process boundary and encapsulate platform-specific permission constraints.

12. **What to draw as the primary data flow**
   - The most important flow is:
     **filesystem APIs / watchers → fs-indexer → object-pipeline → SQLite/redb → disk-intelligence + client APIs**
   - The parallel control flow is:
     **daemon orchestration → watcher/change processor/background hasher → persistence updates**
   - That separation between ingest/update and read/query is the key architectural split in the repo.

Main entry points: [`crates/object-pipeline/src/pipeline.rs`](https://github.com/rap20092003/hyprdrive/blob/master/crates/object-pipeline/src/pipeline.rs) (Object pipeline), [`core/src/db/mod.rs`](https://github.com/rap20092003/hyprdrive/blob/master/core/src/db/mod.rs) (SQL boundary), [`crates/fs-indexer/src/lib.rs`](https://github.com/rap20092003/hyprdrive/blob/master/crates/fs-indexer/src/lib.rs) (FS indexer), [`apps/daemon/src/main.rs`](https://github.com/rap20092003/hyprdrive/blob/master/apps/daemon/src/main.rs) (Daemon)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_daemon["Daemon<br/>orchestrator<br/>[main.rs]"]
  node_watcher["Watcher<br/>event loop<br/>[watcher.rs]"]
end

subgraph group_storage["Storage"]
  node_core_domain["Domain model<br/>shared types<br/>[mod.rs]"]
  node_core_db["SQL boundary<br/>sqlite access<br/>[mod.rs]"]
  node_migrations["Migrations<br/>schema<br/>[001_objects.sql]"]
  node_redb_cache[("Redb cache<br/>fast state<br/>[cursor_store.rs]")]
end

subgraph group_ingest["Ingestion"]
  node_pipeline["Object pipeline<br/>ingest pipeline<br/>[pipeline.rs]"]
  node_change_proc["Change proc<br/>event normalization"]
  node_bg_hasher["Hasher<br/>deferred hashing"]
  node_fs_indexer["FS indexer<br/>filesystem boundary<br/>[lib.rs]"]
  node_fs_linux["Linux FS<br/>platform adapter<br/>[mod.rs]"]
  node_fs_windows["Windows FS<br/>platform adapter<br/>[mod.rs]"]
  node_fs_macos["macOS FS<br/>platform adapter<br/>[mod.rs]"]
end

subgraph group_analysis["Analysis"]
  node_dedup{{"Dedup engine<br/>duplicate analysis<br/>[lib.rs]"}}
  node_disk_intel{{"Disk intel<br/>analytics<br/>[lib.rs]"}}
end

subgraph group_clients["Clients"]
  node_ipc["IPC protocol<br/>api contract<br/>[lib.rs]"]
  node_sdk["SDK<br/>client library<br/>[lib.rs]"]
  node_ts_clients["TS clients<br/>frontend libs<br/>[index.ts]"]
  node_cli["CLI<br/>[main.rs]"]
  node_tauri_web["UI shells<br/>desktop/web<br/>[main.tsx]"]
end

subgraph group_platform["Platform helpers"]
  node_helpers["Helpers<br/>privileged binaries<br/>[main.rs]"]
end

node_daemon -->|"owns"| node_watcher
node_daemon -->|"drives"| node_pipeline
node_watcher -->|"batches"| node_change_proc
node_change_proc -->|"feeds"| node_pipeline
node_pipeline -->|"defers"| node_bg_hasher
node_pipeline -->|"scans"| node_fs_indexer
node_fs_indexer -->|"implements"| node_fs_linux
node_fs_indexer -->|"implements"| node_fs_windows
node_fs_indexer -->|"implements"| node_fs_macos
node_fs_windows -->|"uses"| node_helpers
node_pipeline -->|"writes"| node_core_domain
node_pipeline -->|"persists"| node_core_db
node_core_db -->|"shaped by"| node_migrations
node_core_db -->|"augments"| node_redb_cache
node_dedup -->|"reads"| node_core_db
node_disk_intel -->|"reads"| node_core_db
node_ipc -->|"generates"| node_sdk
node_ipc -->|"shared with"| node_ts_clients
node_sdk -->|"calls"| node_daemon
node_ts_clients -->|"calls"| node_daemon
node_cli -->|"uses"| node_sdk
node_tauri_web -->|"builds on"| node_ts_clients

click node_daemon "https://github.com/rap20092003/hyprdrive/blob/master/apps/daemon/src/main.rs"
click node_watcher "https://github.com/rap20092003/hyprdrive/blob/master/apps/daemon/src/watcher.rs"
click node_pipeline "https://github.com/rap20092003/hyprdrive/blob/master/crates/object-pipeline/src/pipeline.rs"
click node_change_proc "https://github.com/rap20092003/hyprdrive/blob/master/crates/object-pipeline/src/change_processor.rs"
click node_bg_hasher "https://github.com/rap20092003/hyprdrive/blob/master/crates/object-pipeline/src/background_hasher.rs"
click node_fs_indexer "https://github.com/rap20092003/hyprdrive/blob/master/crates/fs-indexer/src/lib.rs"
click node_fs_linux "https://github.com/rap20092003/hyprdrive/blob/master/crates/fs-indexer/src/platform/linux/mod.rs"
click node_fs_windows "https://github.com/rap20092003/hyprdrive/blob/master/crates/fs-indexer/src/platform/windows/mod.rs"
click node_fs_macos "https://github.com/rap20092003/hyprdrive/blob/master/crates/fs-indexer/src/platform/macos/mod.rs"
click node_core_domain "https://github.com/rap20092003/hyprdrive/blob/master/core/src/domain/mod.rs"
click node_core_db "https://github.com/rap20092003/hyprdrive/blob/master/core/src/db/mod.rs"
click node_migrations "https://github.com/rap20092003/hyprdrive/blob/master/core/migrations/001_objects.sql"
click node_redb_cache "https://github.com/rap20092003/hyprdrive/blob/master/apps/daemon/src/cursor_store.rs"
click node_dedup "https://github.com/rap20092003/hyprdrive/blob/master/crates/dedup-engine/src/lib.rs"
click node_disk_intel "https://github.com/rap20092003/hyprdrive/blob/master/crates/disk-intelligence/src/lib.rs"
click node_ipc "https://github.com/rap20092003/hyprdrive/blob/master/crates/ipc-protocol/src/lib.rs"
click node_sdk "https://github.com/rap20092003/hyprdrive/blob/master/crates/sdk/src/lib.rs"
click node_ts_clients "https://github.com/rap20092003/hyprdrive/blob/master/packages/ts-client/src/index.ts"
click node_cli "https://github.com/rap20092003/hyprdrive/blob/master/apps/cli/src/main.rs"
click node_tauri_web "https://github.com/rap20092003/hyprdrive/blob/master/apps/tauri/src/main.tsx"
click node_helpers "https://github.com/rap20092003/hyprdrive/blob/master/helpers/hyprdrive-helper-windows/src/main.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_daemon,node_watcher toneBlue
class node_core_domain,node_core_db,node_migrations,node_redb_cache toneAmber
class node_pipeline,node_change_proc,node_bg_hasher,node_fs_indexer,node_fs_linux,node_fs_windows,node_fs_macos toneMint
class node_dedup,node_disk_intel toneRose
class node_ipc,node_sdk,node_ts_clients,node_cli,node_tauri_web toneIndigo
class node_helpers toneTeal
```

## Components

### Runtime

Daemon and client-facing execution paths

- [Daemon](https://github.com/rap20092003/hyprdrive/blob/master/apps/daemon/src/main.rs): orchestrator · Primary background process and system of record · `apps/daemon/src/main.rs`
- [Watcher](https://github.com/rap20092003/hyprdrive/blob/master/apps/daemon/src/watcher.rs): event loop · Normalizes and debounces filesystem change events · `apps/daemon/src/watcher.rs`

### Storage

Canonical metadata and fast caches

- [Domain model](https://github.com/rap20092003/hyprdrive/blob/master/core/src/domain/mod.rs): shared types · IDs, paths, filters, tags, sync, undo, and folders · `core/src/domain/mod.rs`
- [SQL boundary](https://github.com/rap20092003/hyprdrive/blob/master/core/src/db/mod.rs): sqlite access · Centralized database pool, queries, and types · `core/src/db/mod.rs`
- [Migrations](https://github.com/rap20092003/hyprdrive/blob/master/core/migrations/001_objects.sql): schema · SQLite schema evolution and canonical tables · `core/migrations/001_objects.sql`
- [Redb cache](https://github.com/rap20092003/hyprdrive/blob/master/apps/daemon/src/cursor_store.rs): fast state · Low-latency inode and cursor state cache · `apps/daemon/src/cursor_store.rs`

### Ingestion

Filesystem discovery, normalization, and indexing

- [Object pipeline](https://github.com/rap20092003/hyprdrive/blob/master/crates/object-pipeline/src/pipeline.rs): ingest pipeline · Scan, hash, and upsert flow for file objects · `crates/object-pipeline/src/pipeline.rs`
- [Change proc](https://github.com/rap20092003/hyprdrive/blob/master/crates/object-pipeline/src/change_processor.rs): event normalization · Converts raw events into stable batch updates · `crates/object-pipeline/src/change_processor.rs`
- [Hasher](https://github.com/rap20092003/hyprdrive/blob/master/crates/object-pipeline/src/background_hasher.rs): deferred hashing · Upgrades synthetic identities to content hashes · `crates/object-pipeline/src/background_hasher.rs`
- [FS indexer](https://github.com/rap20092003/hyprdrive/blob/master/crates/fs-indexer/src/lib.rs): filesystem boundary · Cross-platform discovery and change monitoring · `crates/fs-indexer/src/lib.rs`
- [Linux FS](https://github.com/rap20092003/hyprdrive/blob/master/crates/fs-indexer/src/platform/linux/mod.rs): platform adapter · Linux scanning and listener implementation · `crates/fs-indexer/src/platform/linux/mod.rs`
- [Windows FS](https://github.com/rap20092003/hyprdrive/blob/master/crates/fs-indexer/src/platform/windows/mod.rs): platform adapter · Windows MFT, USN, and pipe-based implementation · `crates/fs-indexer/src/platform/windows/mod.rs`
- [macOS FS](https://github.com/rap20092003/hyprdrive/blob/master/crates/fs-indexer/src/platform/macos/mod.rs): platform adapter · macOS scanning and listener implementation · `crates/fs-indexer/src/platform/macos/mod.rs`

### Analysis

Read-heavy derived views and duplicate logic

- [Dedup engine](https://github.com/rap20092003/hyprdrive/blob/master/crates/dedup-engine/src/lib.rs): duplicate analysis · Exact, fuzzy, and perceptual duplicate strategies · `crates/dedup-engine/src/lib.rs`
- [Disk intel](https://github.com/rap20092003/hyprdrive/blob/master/crates/disk-intelligence/src/lib.rs): analytics · Volume summaries, treemaps, and wasted-space views · `crates/disk-intelligence/src/lib.rs`

### Clients

API surfaces and user-facing entrypoints

- [IPC protocol](https://github.com/rap20092003/hyprdrive/blob/master/crates/ipc-protocol/src/lib.rs): api contract · Shared wire protocol for daemon clients · `crates/ipc-protocol/src/lib.rs`
- [SDK](https://github.com/rap20092003/hyprdrive/blob/master/crates/sdk/src/lib.rs): client library · Rust client library over the daemon protocol · `crates/sdk/src/lib.rs`
- [TS clients](https://github.com/rap20092003/hyprdrive/blob/master/packages/ts-client/src/index.ts): frontend libs · TypeScript interface and client packages · `packages/ts-client/src/index.ts`
- [CLI](https://github.com/rap20092003/hyprdrive/blob/master/apps/cli/src/main.rs): client app · Command-line consumer of the daemon API · `apps/cli/src/main.rs`
- [UI shells](https://github.com/rap20092003/hyprdrive/blob/master/apps/tauri/src/main.tsx): desktop/web · Tauri and web frontends built on shared UI packages · `apps/tauri/src/main.tsx`

### Platform helpers

Privilege-bound OS integration binaries

- [Helpers](https://github.com/rap20092003/hyprdrive/blob/master/helpers/hyprdrive-helper-windows/src/main.rs): privileged binaries · OS-specific helper binaries for elevated filesystem access · `helpers/hyprdrive-helper-windows/src/main.rs`

## Connections

- Daemon → Watcher: owns · Daemon coordinates filesystem event handling
- Daemon → Object pipeline: drives · Daemon orchestrates ingestion and updates
- Watcher → Change proc: batches · Raw events are coalesced into normalized updates
- Change proc → Object pipeline: feeds · Normalized changes enter the object pipeline
- Object pipeline → Hasher: defers · Fast first pass is followed by background hashing
- Object pipeline → FS indexer: scans · Pipeline depends on filesystem discovery and monitoring
- FS indexer → Linux FS: implements · Linux-specific filesystem adapter
- FS indexer → Windows FS: implements · Windows-specific filesystem adapter
- FS indexer → macOS FS: implements · macOS-specific filesystem adapter
- Windows FS → Helpers: uses · Windows integration relies on helper service and pipe access
- Object pipeline → Domain model: writes · Ingestion updates shared domain records
- Object pipeline → SQL boundary: persists · Canonical metadata is written through the SQL boundary
- SQL boundary → Migrations: shaped by · Schema is defined and evolved by migrations
- SQL boundary → Redb cache: augments · Fast cache state complements canonical SQLite data
- Dedup engine → SQL boundary: reads · Duplicate analysis consumes indexed metadata
- Disk intel → SQL boundary: reads · Analytics are computed from persisted file graph data
- IPC protocol → SDK: generates · Rust SDK consumes the shared protocol boundary
- IPC protocol → TS clients: shared with · TypeScript clients use the same API contract
- SDK → Daemon: calls · Rust clients talk to the daemon process
- TS clients → Daemon: calls · UI clients consume daemon APIs rather than owning storage
- CLI → SDK: uses · CLI is a lightweight SDK consumer
- UI shells → TS clients: builds on · Desktop and web shells sit on shared TypeScript UI packages
