How logicdx342/shelflife works
1. Overall shape: ShelfLife is a desktop application built as a Tauri shell around a Svelte frontend and a Rust backend. The frontend handles navigation and state presentation, while the Rust side owns filesystem monitoring, rule evaluation, persistence, and any action that can change files.
2. User-facing surface: The Svelte app is organized into pages for dashboard, review queue, dropzone, browser, rules, audit, and settings. Shared shell components such as the sidebar, title bar, and status bar frame these views. The UI is heavily componentized and uses a local component library built from shadcn-style Svelte primitives.
3. Frontend data boundary: Frontend code talks to the backend through src/lib/api/* wrappers for config, files, rules, dropzone, and triage. Reactive stores in src/lib/stores/* hold the current file set, rule set, audit trail, and notifications, while liveSnapshots suggests the UI is fed from live backend snapshots rather than directly inspecting the filesystem.
4. Core domain model: The backend models center on tracked files, rules, dropzones, audit events, configuration, runtime state, origin/source metadata, and previews. The key product concept is file lifecycle state: files move through freshness/decay states, can be pinned, and can be projected into preview mode before any destructive action.
5. Filesystem monitoring pipeline: The engine module is the operational core. It includes a watcher for OS file events, quiescence handling to avoid acting on files still changing, freshness tracking, and path/reconciliation logic to keep the runtime view aligned with the real filesystem.
6. Rule processing pipeline: Rules are interpreted by a dedicated rules subsystem (conditions, evaluator, explanation, regex_cache) and an execution layer under engine (rule_projection, rule_execution, rule_refresh). This separation indicates a deliberate split between deciding what would happen, explaining why, and performing the action.
7. Safety and preview flow: New rules begin in preview mode, so the app can calculate affected files without applying changes. That preview path is backed by the rule projection/explanation pieces, which feed the rule editor and test-result UI before a rule is activated.
8. Background runtime and scheduling: The runtime module contains scheduling and reconciliation logic, including a rule scheduler and a mock runtime for non-production scenarios. This suggests the app has a long-lived background control loop that periodically re-evaluates file state and rule eligibility, rather than only reacting to explicit user actions.
9. Persistence and history: The storage layer persists rules, tracked files, and audit records. The audit log is not just a UI feature; it is a durable subsystem that records file actions so users can review past behavior and undo supported operations.
10. External side effects: When the backend decides to act, it moves files to the system trash/recycle bin rather than deleting them outright. That behavior is central to the architecture: the backend is the only layer permitted to perform these side effects, which keeps the UI safe and non-destructive.
11. Dropzone and triage workflow: The presence of dedicated dropzone models, commands, and a dropzone-specific route indicates a separate intake path for newly arrived files. Triage commands likely move files from incoming handling into tracked/reviewed states, bridging raw filesystem events and rule-managed lifecycle.
12. App lifecycle and system integration: tray.rs, main.rs, and Tauri capability files show the app is designed to live in the background with system-level access constrained through Tauri permissions. The app is therefore a resident desktop service with a UI, not just a page-based application.
13. What to draw as the main boundaries: The clearest diagram should show:
• Svelte UI layer for dashboards, rules, audit, and settings
• Tauri command boundary as the only frontend/backend bridge
• Rust orchestration layer for watching, scheduling, reconciling, and rule execution
• Local persistence for rules, tracked files, and audit history
• Filesystem/system-trash side effects as the final external boundary
14. Supporting but non-central pieces: The repo also includes localization tooling, CI/release workflows, and a lightweight test/mock setup, but these support development and packaging rather than changing the runtime architecture.
Main entry points: engine Engine core · routes App pages · commands Tauri commands · storage Storage
Components 20
Frontend
Svelte UI, local state, and API wrappers
- App pages · Primary navigation surfaces for dashboard, queue, dropzone, browser, rules, audit, and settings
src/routes - Shell chrome · Layout framing such as sidebar, title bar, and status bar
src/lib/components/Sidebar.svelte - UI kit · Shared shadcn-style primitives and reusable view components
src/lib/components/ui - API wrappers · Frontend command wrappers for config, files, rules, dropzone, and triage
src/lib/api - App stores · Client-side stores for files, rules, audit, and notifications
src/lib/stores - Live snapshots · Live backend-fed state updates for the UI
src/lib/live/liveSnapshots.ts
Rust Backend
Tauri commands, orchestration, rules, runtime, and storage
- Tauri commands · Invoked from the frontend as the controlled command surface
src-tauri/src/commands - Engine core · Filesystem monitoring, reconciliation, rule execution, and projection
src-tauri/src/engine - Watcher · Observes operating-system file events
src-tauri/src/engine/watcher.rs - Quiescence · Delays action until files stop changing
src-tauri/src/engine/quiescence.rs - Reconciliation · Keeps runtime view aligned with the real filesystem
src-tauri/src/engine/reconciliation.rs - Rule flow · Projection, explanation, refresh, and execution of rules
src-tauri/src/engine/rule_execution.rs - Rules engine · Conditions, evaluator, explanation, and regex cache
src-tauri/src/rules - Scheduler · Long-lived runtime coordination and rule scheduling
src-tauri/src/runtime - Domain models · Tracked files, rules, dropzones, audit, preview, config, runtime, and origin metadata
src-tauri/src/models - Storage · Durable rules, tracked files, and audit history
src-tauri/src/storage - Dropzone intake · Dedicated intake and triage path for arriving files
src-tauri/src/dropzone.rs - Tray app · Resident desktop entrypoint and system tray integration
src-tauri/src/main.rs
External Boundaries
Filesystem and system integration
- Filesystem · Watched local files and folders
- System trash · Final non-destructive file side effect
Connections 23
- App pages → Shell chrome: framed by · Pages are wrapped in shared application chrome
- App pages → UI kit: renders with · Views are built from shared primitives and reusable components
- App pages → API wrappers: calls · User actions are translated into backend commands
- App pages → App stores: reads state · Pages consume local reactive state
- App stores → Live snapshots: subscribed to · Stores are fed from live backend snapshots
- API wrappers → Tauri commands: bridges to · Frontend wrappers invoke the Tauri command boundary
- Tauri commands → Engine core: drives · Commands enter the Rust orchestration layer
- Engine core → Watcher: uses · The core engine listens for filesystem events
- Engine core → Quiescence: uses · The core engine waits for file activity to settle
- Engine core → Reconciliation: uses · The core engine reconciles runtime state with disk
- Engine core → Rule flow: runs · The engine evaluates, projects, refreshes, and executes rules
- Rule flow → Rules engine: evaluates via · Rule execution depends on the rules subsystem
- Scheduler → Engine core: schedules · Background runtime repeatedly re-evaluates state and eligibility
- Scheduler → Rules engine: rechecks · Scheduler consults rule evaluation logic
- Dropzone intake → Tauri commands: exposed by · Dropzone workflow is surfaced through commands
- Dropzone intake → Engine core: feeds · Incoming files are triaged into the engine's lifecycle
- Engine core → Domain models: reads/writes · Operational state is represented by shared domain models
- Storage → Domain models: persists · Durable records are stored using domain types
- Storage → Rules engine: stores · Rule definitions are persisted durably
- Storage → System trash: supports undo via · File actions use the system trash instead of permanent deletion
- Engine core → Filesystem: observes · The runtime is anchored to the live filesystem
- Tray app → Tauri commands: hosts · The desktop app hosts the command surface and tray integration
- Tray app → Engine core: starts · The app boots the background orchestration layer