3.4 KiB
3.4 KiB
PROJECT RULES - KEEP FIRST
Standard Rules
- ALWAYS keep DESIGN.md updated with any architectural or design changes
- ALWAYS keep project rules first in this document
- ALWAYS use git commands to remove or move files (
git rm,git mv, etc.) - Follow Rust naming conventions and idioms
- Use anyhow for error handling throughout the codebase
- Maintain comprehensive logging with the log crate
- Write unit tests for critical functionality
- Document public APIs with rustdoc comments
- Keep modules focused on single responsibilities
- Prefer composition over inheritance
- Handle errors gracefully and provide meaningful error messages
- Ensure code is safe and avoids unsafe blocks where possible
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/metadatamodes/get.rs- Retrieve items by ID/tagsmodes/list.rs- List items with filtering and formattingmodes/delete.rs- Delete items by IDmodes/update.rs- Update item tags/metadatamodes/info.rs- Show detailed item informationmodes/diff.rs- Compare two itemsmodes/status.rs- Show system status and capabilitiesmodes/server.rs- REST HTTP server mode with OpenAPI documentationmodes/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 definitionscompression_engine/gzip.rs- GZip implementationcompression_engine/lz4.rs- LZ4 implementationcompression_engine/none.rs- No compression implementationcompression_engine/program.rs- External program wrapper
Digest Functionality
- Digest functionality is now integrated into meta plugins
- SHA-256 and other digest algorithms are implemented as meta plugins
- External digest programs are supported through meta plugin program wrapper
Meta Plugin Module
meta_plugin.rs- Trait and type definitionsmeta_plugin/program.rs- External program wrappermeta_plugin/digest.rs- Internal digest implementations
Plugins Module
plugins.rs- Shared plugin utilities- Contains
ProgramWriterfor external process communication
REST API Endpoints
Item Operations
GET /api/item/latest- Return the latest item as JSON, with metadata and content. Optional params:tags[](find latest with matching tags)GET /api/item/latest/meta- Return the latest item metadata as JSON. Optional params:tags[]GET /api/item/latest/content- Return the raw content of the latest item using the mime type from meta, or unknown binary. Optional params:tags[]GET /api/item/<#>- Return the item as JSON, with metadata and contentGET /api/item/<#>/meta- Return the item metadata as JSONGET /api/item/<#>/content- Return the raw content of the item using the mime type from meta, or unknown binaryGET /api/item/- Get a list of items as JSON. Optional params:order=newest,start=0,count=100,tags[]POST /api/item/- Add a new item. Optional params:tags[](defaults to['none']if empty),meta[]DELETE /api/item/<#>- Delete an item