How bykof/hoard_chunker works
Main Components
• Command Line Interface (CLI) Layer: Represented by src/main.rs. This is the entry point where commands (backup, restore, help, etc.) are parsed.
• Core Library: Represented by src/lib.rs that potentially wires up the internal modules and configures the primary functions of the application.
• Backup Module: Under src/backup, this module encapsulates the domain-specific logic.
• Models: Found under src/backup/models. These files define the data structures such as backup_config, backup_metadata, file and chunk representations, and symbolic links.
• Services: Found under src/backup/services. These files implement the operational behaviors, e.g., backup_service, restore_service, file_chunker, chunk_reader_writer, and chunk_storage. They manage how data is segmented, stored, and later reassembled.
Relationships and Interactions
• The CLI layer receives commands and options which trigger calls to the backup module.
• The backup module divides the responsibilities into two primary flows:
a. Backup Flow: Reads from the input directory, splits a file into chunks via file_chunker, uses backup_service to coordinate the process, and interacts with chunk_reader_writer and chunk_storage for persisting the chunks.
b. Restore Flow: Reads chunks from a specified directory, then trigger restore_service to reconstruct the original file.
• Communication between models and services: Models represent the structured data (configuration, metadata, file chunks) that services consume and update during backup or restore operations.
Architectural Patterns and Design Principles
• Modular Design: The directory structure promotes separation of concerns (models vs. services). This makes testing, maintenance, and adding features easier.
• Command Pattern: The application accepts commands (backup, restore) via the CLI and routes them to appropriate service layers.
• Layered Architecture: With a clear separation between the interfaces (CLI), business logic (services), and data representations (models).
Relevant Technologies and Libraries
• Rust Language and Cargo Build System: Emphasize that this is a Rust application using Cargo (Cargo.toml, Cargo.lock).
• Integration Tests: The tests directory outlines integration tests (tests/integration_test.rs), which support the reliability of the backup and restore flows.