Backend Development Skill
Rules for the Rust "Engine" of EMMM2.
- Core Architecture (The 3-Layer Standard)
Follow Clean Architecture to keep logic testable and decoupled.
-
Presentation (Commands): src-tauri/src/commands/ . Thin wrapper. Deserializes input -> Calls Service -> Serializes Output. NO LOGIC HERE.
-
Domain (Services): src-tauri/src/services/ . Pure Business Logic. Agnostic of Tauri or UI.
-
Infrastructure (Repositories): src-tauri/src/database/ . SQLx queries and OS File I/O.
- API Design (Tauri Commands)
Treat Commands like REST Endpoints.
-
Input: Use DTO structs (Data Transfer Objects), not long argument lists.
-
Output: Always return Result<T, AppError> .
-
Async: All Commands must be async .
- Database Patterns (SQLite + SQLx)
-
Schema: managed via migrations/*.sql .
-
ID: Use UUID v4 (Text) for universal uniqueness.
-
Optimization: Use WAL mode and PRAGMA synchronous = NORMAL .
References
-
Service Pattern
-
Database & Schema
-
API Style Guide