Repository navigation
Description
Per docs/research/architecture_audit.md §3.1 and §4.1 — the #1 top-10 action from that audit.
Problem
No application-service layer exists. Every Tauri command in crates/desktop/src/commands.rs (1158 LOC) re-orchestrates scan/search/tag workflows. Every future axum handler (Phase 6) and plugin (Phase 8) would re-duplicate the same orchestration. Estimated ~1050 LOC of scan duplication would hit at Phase 6 without the extraction.
Shape
One UseCase struct per user-visible workflow:
pub struct ScanUseCase {
files: Arc<dyn FileRepository>,
volumes: Arc<dyn VolumeRepository>,
hasher: Arc<dyn Hasher>,
events: Arc<EventBus>,
}
impl ScanUseCase {
pub fn new(...) -> Self { ... }
pub async fn execute(&self, cmd: ScanCommand) -> Result<ScanReport, ScanError> {
// orchestration
}
}- Concrete struct,
Arc<dyn Port>fields, oneasync fn execute, zero generic parameters. AppContainerwires use cases together;#[derive(Clone)]so axum'swith_stateand Tauri's.manage()accept it trivially.- EventBus lives in
core(events are domain concepts);DbEventHandlerindb;LogEventHandlerin a smalltelemetrymodule.
Audit's rationale: this is the pattern real mature Rust codebases converge on (zed's Entity<Project>, rust-analyzer's Analysis, crates.io's AppState) — NOT the hex-arch textbook shape.
Blocker status
Now unblocked: the FileRepository/VolumeRepository &mut self → &self refactor landed in commit 081c694 (task #72). Use cases can now share Arc<dyn FileRepository> across handlers.
Starting set
scan, search, tag, volume, metadata. Add import later.
Rejected alternatives
- Generic
struct ScanUseCase<F: FileRepository, V: VolumeRepository>— LLMs drift on where-clauses; adding a port cascades through call sites. - Enum-dispatch across use cases — maintenance sink at ~15 use cases.
- Skipping the UseCase struct for "simple" operations — consistency beats elegance when LLMs author.
Source
docs/research/architecture_audit.md §3.1, §3.2, §3.3, §4.1 (especially the ranked pattern-comparison table in §4.1).
Execution hint
Needs a proper /superpowers:brainstorming → writing-plans cycle — this is architectural, not a lint sweep. Block Phase 6 (issue #59) on this landing first.
Activity
utof commentedon Apr 19, 2026
Correction: The body's parenthetical "Phase 6 (issue #59)" is wrong — GH issue #59 is a different FTS refactor. "Phase 6" here refers to the internal task-tracker epic (Local HTTP API: axum + keychain + OpenAPI); there is no matching GH issue yet. This issue is a blocker/prep for that epic whenever it starts.