Coding Conventions
Error Handling
| Layer | Approach |
|---|---|
| Domain | thiserror for custom error types |
| Services | anyhow::Result with .context() chaining |
| Infrastructure | Map driver errors to domain errors |
| CLI | Display user-friendly messages |
Rules:
- No
unwrap()in production code expect()requires a clear explanation message- Errors should be caught at the boundary closest to where they can be meaningfully handled
Async
- All I/O is async
#[tokio::main]entry point- Services take
&mut selffor mutable repository access
Naming
| Element | Convention | Example |
|---|---|---|
| Variables / functions | snake_case | wheel_count |
| Types / structs | PascalCase | WheelProduct |
| DB columns in entities | Preserve abbreviations | pNO, pStatus, pwDia |
| Service structs | {Domain}Service<R: {Domain}Repository> | WheelService<R: WheelRepository> |
| Repo implementations | SqlServer{Domain}Repo | SqlServerWheelRepo |
Serialization
serdederive on all entities#[serde(rename = "...")]for DB column / CSV mapping- Custom serializers for booleans, decimals, and dates
CLI Output
owo-colorsfor terminal coloringdialoguerfor interactive promptscomfy-tablefor table formattingindicatiffor progress bars
Module Organization
- One concept per file
mod.rsexports the public interface- Keep functions under 50 lines; extract sub-functions when exceeding