diff --git a/DESIGN.md b/DESIGN.md index e69de29..838c60b 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -0,0 +1,60 @@ +# PROJECT RULES - KEEP FIRST + +## Code - Modules + +### Main Module +- `main.rs` - Entry point, CLI argument parsing, mode dispatching +- Interacts with all mode modules based on user input +- Handles database connection setup and data directory management + +### Mode Modules +- `modes/save.rs` - Save new items with tags/metadata +- `modes/get.rs` - Retrieve items by ID/tags +- `modes/list.rs` - List items with filtering and formatting +- `modes/delete.rs` - Delete items by ID +- `modes/update.rs` - Update item tags/metadata +- `modes/info.rs` - Show detailed item information +- `modes/diff.rs` - Compare two items +- `modes/status.rs` - Show system status and capabilities +- `modes/common.rs` - Shared utilities for all modes + +### Database Module +- `db.rs` - SQLite database operations +- Handles items, tags, and metadata storage +- Provides query functions for all modes +- Manages database migrations + +### Compression Engine Module +- `compression_engine.rs` - Trait and type definitions +- `compression_engine/gzip.rs` - GZip implementation +- `compression_engine/lz4.rs` - LZ4 implementation +- `compression_engine/none.rs` - No compression implementation +- `compression_engine/program.rs` - External program wrapper + +### Digest Engine Module +- `digest_engine.rs` - Trait and type definitions +- `digest_engine/sha2.rs` - SHA-256 implementation +- `digest_engine/none.rs` - No digest implementation +- `digest_engine/program.rs` - External program wrapper + +### Meta Plugin Module +- `meta_plugin.rs` - Trait and type definitions +- `meta_plugin/program.rs` - External program wrapper +- `meta_plugin/digest.rs` - Internal digest implementations + +### Plugins Module +- `plugins.rs` - Shared plugin utilities +- Contains `ProgramWriter` for external process communication + +## Standard Rules + +1. ALWAYS keep DESIGN.md updated with any architectural or design changes +2. Follow Rust naming conventions and idioms +3. Use anyhow for error handling throughout the codebase +4. Maintain comprehensive logging with the log crate +5. Write unit tests for critical functionality +6. Document public APIs with rustdoc comments +7. Keep modules focused on single responsibilities +8. Prefer composition over inheritance +9. Handle errors gracefully and provide meaningful error messages +10. Ensure code is safe and avoids unsafe blocks where possible