# Rust core Active contributors: Douwe de Vries, vriesd ## Purpose The Rust core owns QA Scribe's domain model, SQLite schema, service layer, attachment files, AI prompt/response handling, and generation persistence. It is implemented in `crates/qa-scribe-core` and imported by both the Tauri app and smoke harness. ## Directory layout ```text crates/qa-scribe-core/src/ ai/ attachments/ domain/ generation/ services/ storage/ lib.rs ``` ## Key abstractions | Name | File | Description | | --- | --- | --- | | `SessionService` | `crates/qa-scribe-core/src/services/session_service.rs` | Main service facade over `Database`. | | `Database` | `crates/qa-scribe-core/src/storage/mod.rs` | SQLite connection, schema setup, and migration/version checks. | | `QaScribeError` | `crates/qa-scribe-core/src/error.rs` | Core error type used by services and Tauri commands. | | Domain DTOs | `crates/qa-scribe-core/src/domain/mod.rs` | Re-exports Session, Entry, Draft, Finding, Attachment, AI Run, and settings types. | | `prepare_ai_action_generation` | `crates/qa-scribe-core/src/generation/workflow.rs` | Creates generation context and running AI Run before provider execution. | | `finish_ai_action_generation` | `crates/qa-scribe-core/src/generation/workflow.rs` | Persists generated Draft, Finding, or note update after provider output. | ## How it works ```mermaid graph TD Commands[Tauri commands] --> Service[SessionService] Service --> Database[Database] Database --> SQLite[(SQLite)] Service --> Attachments[attachments module] Service --> Generation[generation workflow] Generation --> AiRun[AI Run rows] Generation --> Drafts[Draft/Finding/Entry writes] ``` The service layer validates drafts and patches, enforces ownership inside a Session, and performs multi-row operations in transactions when needed. `crates/qa-scribe-core/src/storage/mod.rs` defines schema version 7 and the tables used by Sessions, Entries, Attachments, Findings, Evidence links, Generation contexts, AI Runs, Drafts, and App settings. ## Integration points `src-tauri/src/settings.rs` wraps `SessionService` in app state. `crates/qa-scribe-app/src/main.rs` imports the same core for smoke testing. `frontend/src/bindings.ts` receives many core domain types through Specta registration in `src-tauri/src/specta_bindings.rs`. ## Entry points for modification Start in `crates/qa-scribe-core/src/domain` for data shape changes, `crates/qa-scribe-core/src/services/session_service` for business rules, and `crates/qa-scribe-core/src/storage/mod.rs` for persistence changes.