# guinetik/amh2w architecture

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

- Interactive diagram: https://gitdiagram.com/guinetik/amh2w
- Repository: https://github.com/guinetik/amh2w

## Overview

##### Main Components
a. PowerShell Host (User)
b. AMH2W Module Loader (AMH2W.psm1)
c. Core Subsystem (core/*.ps1)
- Parser (`core/namespace.ps1`, `core/command.ps1`)
- Pipeline & Result Types (`core/pipeline.ps1`, `core/result.ps1`)
- Console & Logging (`core/console.ps1`, `core/log.ps1`)
- System Abstractions (`core/system.ps1`)
d. Command Namespace Directories
- `all/` (base commands: math, time, weather)
- `all/my/` (user‐focused: clock, uptime, shell, browser, files)
- `all/my/homies/` (utilities: download, install, convert, crypto, hate)
- `hate/` subnamespace (JSON, Windows management, zipping, path, ftp)
- `crypto/`, `convert/`, `install/`, `luv/`, etc.
e. External Dependencies
- Windows APIs (.NET assemblies, SecureString, CIM/WMI)
- Third‐party tools (ImageMagick, FFmpeg, BITS, 7-Zip/WinRAR)
f. Tests & Docs
- `test/` (unit & regression tests)
- `docs/` (architecture & usage docs)

##### Relationships & Data Flow
- User issues `all my homies hate json tree <url>` in a PowerShell console →
→ AMH2W.psm1 intercepts & bootstraps the command grammar →
→ Namespace Parser locates the .ps1 file under `all/my/homies/hate/json/tree.ps1` →
→ Core Pipeline executes the function, passing input →
→ Function may call
– Core Result / Logging subsystems
– External APIs (Invoke‐WebRequest, .NET JSON parser)
→ Returns a `Result` object →
→ Console subsystem renders output or error.

##### Architectural Patterns & Principles
– Modular Directory‐based Namespace (each folder = namespace level)
– “Commands as Grammar” – path → function mapping
– Result‐based Error Handling (Ok/Err)
– Pipeline Composition (commands as pipeline stages)
– Minimal external dependencies, delegating heavy work to native tools
– Clear separation: Core runtime vs. user‐contributed commands

##### Technologies & Frameworks
– PowerShell scripting (.psm1, .ps1)
– .NET 4.x APIs (System.Drawing, System.Management, SecureString)
– External CLIs: ImageMagick, FFmpeg, BITS, 7-Zip/WinRAR
– JSON, HTTP client (Invoke‐WebRequest/BITS)
– Windows subsystem calls (WMI, CIM, PowerShell modules)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface
    User["PowerShell Host (User)"]:::user
    Loader["AMH2W Module Loader"]:::core

    %% Core Subsystem
    subgraph "Core Subsystem"
        direction TB
        CoreDir["core/"]:::core
        subgraph "Parser"
            direction TB
            NamespacePS["namespace.ps1"]:::core
            CommandPS["command.ps1"]:::core
        end
        subgraph "Pipeline & Result Types"
            direction TB
            PipelinePS["pipeline.ps1"]:::core
            ResultPS["result.ps1"]:::core
        end
        subgraph "Console & Logging"
            direction TB
            ConsolePS["console.ps1"]:::core
            LogPS["log.ps1"]:::core
        end
        SystemPS["system.ps1"]:::core
    end

    %% Command Namespaces
    subgraph "Command Namespaces"
        direction TB
        subgraph "Base Commands"
            AllDir["all/"]:::cmd
        end
        subgraph "User-Focused Commands"
            MyDir["all/my/"]:::cmd
        end
        subgraph "Homies Utilities"
            HomiesDir["all/my/homies/"]:::cmd
        end
    end

    %% External Dependencies
    External["External Dependencies\n(.NET, CLIs, Windows APIs)"]:::ext

    %% Tests & Documentation
    subgraph "Tests & Docs"
        direction TB
        Tests["test/"]:::misc
        Docs["docs/"]:::misc
    end

    %% Data Flow
    User -->|"issues command"| Loader
    Loader -->|"bootstraps grammar"| NamespacePS
    NamespacePS -->|"locates .ps1"| AllDir
    NamespacePS --> AllDir
    NamespacePS --> MyDir
    NamespacePS --> HomiesDir
    HomiesDir -->|"selects command"| PipelinePS
    MyDir --> PipelinePS
    AllDir --> PipelinePS
    PipelinePS -->|"executes pipeline"| ResultPS
    ResultPS --> ConsolePS
    ResultPS --> LogPS
    PipelinePS --> SystemPS
    PipelinePS -->|"invokes"| External
    ConsolePS -->|"renders output"| User

    %% Click Events
    click Loader "https://github.com/guinetik/amh2w/blob/master/AMH2W.psm1"
    click CoreDir "https://github.com/guinetik/amh2w/tree/master/core/"
    click NamespacePS "https://github.com/guinetik/amh2w/blob/master/core/namespace.ps1"
    click CommandPS "https://github.com/guinetik/amh2w/blob/master/core/command.ps1"
    click PipelinePS "https://github.com/guinetik/amh2w/blob/master/core/pipeline.ps1"
    click ResultPS "https://github.com/guinetik/amh2w/blob/master/core/result.ps1"
    click ConsolePS "https://github.com/guinetik/amh2w/blob/master/core/console.ps1"
    click LogPS "https://github.com/guinetik/amh2w/blob/master/core/log.ps1"
    click SystemPS "https://github.com/guinetik/amh2w/blob/master/core/system.ps1"
    click AllDir "https://github.com/guinetik/amh2w/tree/master/all/"
    click MyDir "https://github.com/guinetik/amh2w/tree/master/all/my/"
    click HomiesDir "https://github.com/guinetik/amh2w/tree/master/all/my/homies/"
    click Tests "https://github.com/guinetik/amh2w/tree/master/test/"
    click Docs "https://github.com/guinetik/amh2w/tree/master/docs/"

    %% Styles
    classDef user fill:#ADD8E6,stroke:#0000FF
    classDef core fill:#98FB98,stroke:#008000
    classDef cmd fill:#FFA500,stroke:#FF8C00
    classDef ext fill:#DDA0DD,stroke:#800080
    classDef misc fill:#D3D3D3,stroke:#696969
```
