Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Services Layer

Services live in src/services/ and encapsulate domain workflows. Each service is a pure Rust module — no UI dependencies, no Tauri dependencies, no async runtime baked in unless the workflow demands it. Services are the unit of integration testing in tests/.

Service responsibilities

ServiceRole
scannerWalks the library, dispatches per-photo work. Async, cancellable.
metadata_processorEXIF + GPS + file-hash extraction per photo.
exif_extractorPulls and normalises EXIF tags.
thumbnailThree-tier thumbnail generation, lazy + cached.
image_ioDecodes JPEG/PNG/WebP/HEIC + RAW preview extraction.
raw_previewExtracts embedded JPEG previews from TIFF-based RAWs.
geocodingResolves GPS → city/country via local GeoNames DB.
face_processorDetection + embedding + clustering orchestration.
searchTranslates SearchQuery → SQL → result rows.
insightsAggregates per-day / per-month / per-person counts.
memories“On this day” / fallback / seasonal generators + ranker.
album_suggestionsTrip and event detection from geographic + temporal clusters.
burst_detectorTime-window-based grouping with similarity gate.
duplicate_detectorSHA-256 exact + DCT-pHash perceptual dedup.
photo_stacksConservative timeline stack generation from duplicate/burst results, including best-photo scoring.
trashSoft-delete, restore, permanent-delete, auto-delete.
tile_cacheLRU-managed cache for OpenStreetMap tiles.
update_checkerOpt-in version check against the GitHub releases API.
self_replaceAtomic binary swap for AppImage / portable Windows.
library_healthAsset-pack presence, DB integrity, model availability.
path_utilCross-platform path normalisation.
reindexerDetects moves, deletions, and changed files.
camera_namesNormalises EXIF make/model into human-readable names.
image_utilsMisc image-processing helpers (rotation, resize).
map_mathCluster math for the map view.
drive_detectorIdentifies the indexed drive’s filesystem ID.
install_methodDetects how Smriti was installed (apt, brew, msi, …).
document_detectorHeuristic detection of scanned-document photos.
ocr_processor(Reserved) OCR pipeline scaffolding.

Boundary discipline

  • Services accept primitive types or &rusqlite::Connection, not Tauri AppState. This keeps them testable without launching a runtime.
  • Tauri command handlers in src-tauri/src/commands/ are thin wrappers: deserialize args, call the service, serialize the result. Anything over ~15 lines in a handler is a sign the logic should move down to a service.
  • Engine services never call back into Tauri. The frontend invokes commands; commands invoke services.

Testing

Each service has a #[cfg(test)] mod tests block alongside it for unit tests, plus integration tests in tests/workflow_*.rs that exercise multi-service workflows (scan → metadata → thumbnail → faces, trash lifecycle, etc.). See Testing.