# kklibo/hashdeep-compare architecture

> Architecture diagram of the GitHub repository kklibo/hashdeep-compare, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kklibo/hashdeep-compare
- Repository: https://github.com/kklibo/hashdeep-compare

## Overview

##### Main Components Overview

a) Core Components (Center):
- Command Parser (command.rs)
- Log Entry Processor (log_entry.rs)
- Log Operations Handler (log_ops.rs)
- Partitioner Module (partitioner/)

b) Subcommand Modules (Branching from Core):
- Hash Command
- Sort Command
- Root Command
- Part Command

##### Data Flow Representation
- Input flow: File system → Log Files → Command Parser
- Processing flow: Command Parser → Specific Command Handler
- Output flow: Command Handler → File System

##### Component Details

Command Parser:
**┌─────────────────┐**
- Command Parser  │
- Parse Args    │
- Validate Input│
- Route Command │
- ┘

Log Processing:
**┌─────────────────┐**
- Log Processing  │
- Parse Headers │
- Validate Lines│
- Extract Data  │
- ┘

Partitioner (Most Complex Component):
**┌─────────────────────────┐**
- Partitioner        │
- ┌───────────────────┐   │
- Match Groups    │   │
- ┘   │
- ┌───────────────────┐   │
- Match Pairs    │   │
- ┘   │
- ┘

##### Specific Implementation Details
- Partitioner's matching rules hierarchy
- File validation points
- Warning generation points
- Parallel processing capabilities (if any)

##### Interface Points
- File System Interface (for reading/writing logs)
- Hashdeep Tool Interface (for hash command)
- User Interface (command line)

##### Error Handling Paths
- Invalid input detection
- File access errors
- Format validation failures
- Warning generation

##### The clear separation of concerns between parsing, processing, and output generation

Use a hierarchical layout with:
- Top level: Command interface and parsing
- Middle level: Core processing logic
- Bottom level: File system operations and output generation

- Component boundary types
- Warning/error indicators

This design captures both the high-level architecture and the detailed processing flow while maintaining clarity about the system's primary purpose of comparing Hashdeep log files.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI["Command Line Interface"]
        UserInput[/"User Input"\]
        CmdParser["Command Parser"]:::parser
        Help["Help System"]:::help
    end

    subgraph Commands["Command Handlers"]
        HashCmd["Hash Command"]:::cmd
        SortCmd["Sort Command"]:::cmd
        RootCmd["Root Command"]:::cmd
        PartCmd["Part Command"]:::cmd
    end

    subgraph Core["Core Processing"]
        LogEntry["Log Entry Processor"]:::core
        LogOps["Log Operations Handler"]:::core
        Common["Common Utilities"]:::util
    end

    subgraph Partitioner["Partitioner Module"]
        MatchGroups["Match Groups"]:::part
        MatchPairs["Match Pairs"]:::part
    end

    subgraph IO["File System Interface"]
        InputFiles[/"Input Log Files"\]
        OutputFiles[/"Output Files"\]
    end

    %% Connections
    UserInput --> CmdParser
    CmdParser --> Help
    CmdParser --> |Route Command| Commands
    InputFiles --> Commands
    
    Commands --> LogEntry
    Commands --> LogOps
    Commands --> Common
    
    PartCmd --> Partitioner
    MatchGroups --> MatchPairs
    
    LogEntry --> OutputFiles
    LogOps --> OutputFiles
    Partitioner --> OutputFiles

    %% Click Events
    click CmdParser "https://github.com/kklibo/hashdeep-compare/blob/master/src/command.rs"
    click LogEntry "https://github.com/kklibo/hashdeep-compare/blob/master/src/log_entry.rs"
    click LogOps "https://github.com/kklibo/hashdeep-compare/blob/master/src/log_ops.rs"
    click Partitioner "https://github.com/kklibo/hashdeep-compare/blob/master/src/partitioner/mod.rs"
    click MatchGroups "https://github.com/kklibo/hashdeep-compare/blob/master/src/partitioner/match_group.rs"
    click MatchPairs "https://github.com/kklibo/hashdeep-compare/blob/master/src/partitioner/match_pair.rs"
    click HashCmd "https://github.com/kklibo/hashdeep-compare/blob/master/src/main_impl.rs"
    click SortCmd "https://github.com/kklibo/hashdeep-compare/blob/master/src/sort.rs"
    click RootCmd "https://github.com/kklibo/hashdeep-compare/blob/master/src/root.rs"
    click PartCmd "https://github.com/kklibo/hashdeep-compare/blob/master/src/partition.rs"
    click Common "https://github.com/kklibo/hashdeep-compare/blob/master/src/common.rs"
    click Help "https://github.com/kklibo/hashdeep-compare/blob/master/src/help.rs"

    %% Styles
    classDef parser fill:#9cf,stroke:#333
    classDef cmd fill:#f9f,stroke:#333
    classDef core fill:#9f9,stroke:#333
    classDef part fill:#ff9,stroke:#333
    classDef util fill:#ccc,stroke:#333
    classDef help fill:#fc9,stroke:#333

    %% Legend
    subgraph Legend
        L1["Command Components"]:::cmd
        L2["Core Components"]:::core
        L3["Parser Components"]:::parser
        L4["Partitioner Components"]:::part
        L5["Utility Components"]:::util
        L6["Help System"]:::help
    end
```
