# dan2552/hedgehog architecture

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

- Interactive diagram: https://gitdiagram.com/dan2552/hedgehog
- Repository: https://github.com/dan2552/hedgehog

## Overview

##### Main Components

a. Core Shell Components:
- Input Processing System
- Command Execution System
- Environment Management
- Built-in Commands
- Terminal Interface

b. Integration Components:
- Ruby Interpreter Integration
- Bash Integration
- Configuration System

**┌─ User Interface Layer ─────────────────────┐**
- Terminal Interface                       │
- Line Editor                             │
- Input Processing                        │
- ┬───────────────────────┘
- ↓
**┌─ Command Processing Layer ──────────────────┐**
- ┌─ Command Router ─┐    ┌─ Execution ─┐    │
- Command Parser │ → │ - Ruby       │    │
- DSL Handler    │    │ - Binary     │    │
- ┘    │ - Alias      │    │
- Builtin     │    │
- ┘    │
- ┬───────────────────────┘
- ↓
**┌─ System Integration Layer ─────────────────┐**
- Environment Management                   │
- Path Management                         │
- Binary Finder                           │
- ┬───────────────────────┘
- ↓
**┌─ External Systems Layer ──────────────────┐**
- Ruby Interpreter                        │
- Bash                                    │
- File System                             │
- ┘

##### Key Relationships to Highlight

a. Input Flow:
- How user input flows from the Terminal Interface through the Line Editor
- Demonstrate the command parsing and routing process

b. Execution Flow:
- How commands are routed to different executors (Ruby, Bash, Builtin)
- Interaction with the environment management system

c. Configuration Integration:
- How .hedgehog configuration file integrates with the system
- Demonstrate the DSL's role in extending functionality

##### Implementation Details

- Input handling system (app/hedgehog/input/*)
- Command execution system (app/hedgehog/execution/*)
- Environment management (app/hedgehog/environment/*)
- Binary path finding (app/hedgehog/binary_in_path_finder/*)

##### Additional Notes

- Notes about the configuration file's role
- Error handling paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#9999ff,stroke:#333,stroke-width:2px
    classDef input fill:#b399ff,stroke:#333,stroke-width:2px
    classDef process fill:#99ccff,stroke:#333,stroke-width:2px
    classDef execution fill:#99ff99,stroke:#333,stroke-width:2px
    classDef system fill:#ffcc99,stroke:#333,stroke-width:2px
    classDef external fill:#cccccc,stroke:#333,stroke-width:2px
    classDef builtin fill:#ff99cc,stroke:#333,stroke-width:2px

    %% User Interface Layer
    subgraph UI
        Terminal["Terminal Interface"]
        LineEditor["Line Editor"]
        InputProc["Input Processing"]
        History["History Management"]
        CharProc["Character Processing"]
        InputLoop["Input Loop"]
    end

    %% Command Processing Layer
    subgraph CommandProc
        CmdParser["Command Parser"]
        DSLHandler["DSL Handler"]
        Settings["Configuration System"]
        State["State Management"]
    end

    %% Execution Layer
    subgraph Execution
        ExecRunner["Execution Runner"]
        RubyExec["Ruby Executor"]
        BinaryExec["Binary Executor"]
        AliasHandler["Alias Handler"]
        Process["Process Management"]
    end

    %% System Integration Layer
    subgraph SystemInt
        EnvMgmt["Environment Management"]
        BinaryFinder["Binary Finder"]
        PathMgmt["Path Management"]
    end

    %% Built-in Commands
    subgraph Builtins
        CD["CD Command"]
        Exit["Exit Command"]
        Export["Export Command"]
        LS["LS Command"]
        Which["Which Command"]
    end

    %% External Systems
    subgraph External
        Ruby["Ruby Interpreter"]
        Bash["Bash"]
        FileSystem["File System"]
    end

    %% Relationships
    Terminal --> LineEditor
    LineEditor --> InputProc
    InputProc --> History
    InputProc --> CharProc
    InputProc --> InputLoop
    
    InputProc --> CmdParser
    CmdParser --> DSLHandler
    CmdParser --> ExecRunner
    
    ExecRunner --> RubyExec
    ExecRunner --> BinaryExec
    ExecRunner --> AliasHandler
    ExecRunner --> Process
    
    RubyExec --> Ruby
    BinaryExec --> Bash
    
    DSLHandler --> Settings
    Settings --> State
    
    BinaryExec --> BinaryFinder
    BinaryFinder --> EnvMgmt
    EnvMgmt --> PathMgmt
    
    ExecRunner --> Builtins
    
    %% Click Events
    click Terminal "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/terminal.rb"
    click LineEditor "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/input/line_editor.rb"
    click InputProc "https://github.com/Dan2552/Hedgehog/tree/master/app/hedgehog/input"
    click History "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/input/history.rb"
    click CharProc "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/input/characters.rb"
    click InputLoop "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/input/loop.rb"
    click CmdParser "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/command.rb"
    click DSLHandler "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/dsl.rb"
    click Settings "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/settings.rb"
    click ExecRunner "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/execution/runner.rb"
    click RubyExec "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/execution/ruby.rb"
    click BinaryExec "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/execution/binary.rb"
    click AliasHandler "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/execution/alias.rb"
    click Process "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/process.rb"
    click EnvMgmt "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/environment/path.rb"
    click BinaryFinder "https://github.com/Dan2552/Hedgehog/tree/master/app/hedgehog/binary_in_path_finder"
    click CD "https://github.com/Dan2552/Hedgehog/blob/master/app/builtins/cd.rb"
    click Exit "https://github.com/Dan2552/Hedgehog/blob/master/app/builtins/exit.rb"
    click Export "https://github.com/Dan2552/Hedgehog/blob/master/app/builtins/export.rb"
    click LS "https://github.com/Dan2552/Hedgehog/blob/master/app/builtins/ls.rb"
    click Which "https://github.com/Dan2552/Hedgehog/blob/master/app/builtins/which.rb"
    click State "https://github.com/Dan2552/Hedgehog/blob/master/app/hedgehog/state.rb"

    %% Style Applications
    class Terminal,LineEditor ui
    class InputProc,History,CharProc,InputLoop input
    class CmdParser,DSLHandler,Settings,State process
    class ExecRunner,RubyExec,BinaryExec,AliasHandler,Process execution
    class EnvMgmt,BinaryFinder,PathMgmt system
    class Ruby,Bash,FileSystem external
    class CD,Exit,Export,LS,Which builtin
```
