# jbaber/edhex architecture

> Architecture diagram of the GitHub repository jbaber/edhex, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jbaber/edhex
- Repository: https://github.com/jbaber/edhex

## Overview

##### Project Type Analysis
- This is a command-line utility tool
- It's a hex editor inspired by the 'ed' text editor
- Written in Rust (evident from Cargo.toml presence)
- Single-purpose application with file I/O capabilities

##### Key Components

a. Core Components:
- Command Parser Module
- Hex Editor Engine
- File I/O Handler
- User Interface Layer
- Preferences Manager

b. Data Flow Components:
- Input Stream (stdin/command arguments)
- Output Stream (stdout)
- File System Interface
- Configuration File Handler

- ┌─ User Interface Layer ─┐
- Command Line Interface
- STDOUT Formatting

- ┌─ Application Layer ────┐
- Command Parser
- Hex Editor Logic
- Byte Operations

- ┌─ Data Layer ──────────┐
- File I/O
- Preferences Storage

##### Component Relationships

- Command flow from CLI → Command Parser → Hex Editor Logic
- File operations from Hex Editor Logic → File I/O
- Configuration flow from Preferences Manager → All components
- Output formatting from Hex Editor Logic → STDOUT

**Input → Command Validation → Byte Processing → Output Formatting → Display**

**XDG Config → Preferences Loading → Runtime Settings → Editor Behavior**

##### Technical Details

- Binary entry point (src/bin/edhex.rs)
- Library interface (src/lib.rs)
- Preference file location ($XDG_CONFIG_HOME)
- Command processing pipeline

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#a8d1f0,stroke:#2c3e50
    classDef core fill:#98e0a3,stroke:#2c3e50
    classDef data fill:#f9e79f,stroke:#2c3e50
    classDef external fill:#d5d8dc,stroke:#2c3e50
    classDef config fill:#f1948a,stroke:#2c3e50

    %% User Interface Layer
    subgraph UI
        CLI["Command Line Interface"]
        STDOUT["STDOUT Formatting"]
    end

    %% Application Layer
    subgraph Core
        CP["Command Parser"]
        HEL["Hex Editor Logic"]
        BO["Byte Operations"]
    end

    %% Data Layer
    subgraph Data
        FIO["File I/O Handler"]
        PS["Preferences Storage"]
    end

    %% External Systems
    XDG["XDG Config System"]
    FS["File System"]

    %% Relationships
    CLI --> CP
    CP --> HEL
    HEL --> BO
    BO --> FIO
    HEL --> STDOUT
    FIO --> FS
    XDG --> PS
    PS -.-> HEL
    PS -.-> CP
    FIO --> STDOUT

    %% Click Events
    click CLI "https://github.com/jbaber/edhex/blob/master/src/bin/edhex.rs"
    click HEL "https://github.com/jbaber/edhex/blob/master/src/lib.rs"
    click PS "https://github.com/jbaber/edhex/blob/master/Cargo.toml"

    %% Style Applications
    class CLI,STDOUT ui
    class CP,HEL,BO core
    class FIO,PS data
    class XDG,FS external

    %% Legend
    subgraph Legend
        UI_L["User Interface"]:::ui
        CORE_L["Core Processing"]:::core
        DATA_L["Data Storage/IO"]:::data
        EXT_L["External Systems"]:::external
    end
```
