How rap20092003/hyprdrive works
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: pipeline.rs Object pipeline · mod.rs SQL boundary · lib.rs FS indexer · main.rs Daemon
Components 21
Runtime
Daemon and client-facing execution paths
Storage
Canonical metadata and fast caches
- Domain model · IDs, paths, filters, tags, sync, undo, and folders
core/src/domain/mod.rs - SQL boundary · Centralized database pool, queries, and types
core/src/db/mod.rs - Migrations · SQLite schema evolution and canonical tables
core/migrations/001_objects.sql - Redb cache · Low-latency inode and cursor state cache
apps/daemon/src/cursor_store.rs
Ingestion
Filesystem discovery, normalization, and indexing
- Object pipeline · Scan, hash, and upsert flow for file objects
crates/object-pipeline/src/pipeline.rs - Change proc · Converts raw events into stable batch updates
crates/object-pipeline/src/change_processor.rs - Hasher · Upgrades synthetic identities to content hashes
crates/object-pipeline/src/background_hasher.rs - FS indexer · Cross-platform discovery and change monitoring
crates/fs-indexer/src/lib.rs - Linux FS · Linux scanning and listener implementation
crates/fs-indexer/src/platform/linux/mod.rs - Windows FS · Windows MFT, USN, and pipe-based implementation
crates/fs-indexer/src/platform/windows/mod.rs - macOS FS · macOS scanning and listener implementation
crates/fs-indexer/src/platform/macos/mod.rs
Analysis
Read-heavy derived views and duplicate logic
- Dedup engine · Exact, fuzzy, and perceptual duplicate strategies
crates/dedup-engine/src/lib.rs - Disk intel · Volume summaries, treemaps, and wasted-space views
crates/disk-intelligence/src/lib.rs
Clients
API surfaces and user-facing entrypoints
- IPC protocol · Shared wire protocol for daemon clients
crates/ipc-protocol/src/lib.rs - SDK · Rust client library over the daemon protocol
crates/sdk/src/lib.rs - TS clients · TypeScript interface and client packages
packages/ts-client/src/index.ts - CLI · Command-line consumer of the daemon API
apps/cli/src/main.rs - UI shells · Tauri and web frontends built on shared UI packages
apps/tauri/src/main.tsx
Platform helpers
Privilege-bound OS integration binaries
- Helpers · OS-specific helper binaries for elevated filesystem access
helpers/hyprdrive-helper-windows/src/main.rs
Connections 22
- 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