# danielrolls/shellify architecture

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

- Interactive diagram: https://gitdiagram.com/danielrolls/shellify
- Repository: https://github.com/danielrolls/shellify

## Overview

##### Main Components

a) Core Components:
- Command Line Interface (Main.hs)
- Template Generation Engine
- Nix File Generator
- Configuration Parser

b) External Dependencies:
- Nix Package Manager
- Nixpkgs Repository
- User's Shell Environment

**┌─ User Interface Layer ─────────────────────┐**

- Command Line Interface (Main.hs)         │
- Argument Parsing (Options.hs)          │

- Business Logic Layer ────────────────────┤

- Template Generation                      │
- FlakeTemplate.hs                     │
- ShellifyTemplate.hs                  │
- TemplateGeneration.hs                │

- Constants & Configuration               │
- Constants.hs                         │

- Output Generation Layer ─────────────────┤

- File Generation                         │
- shell.nix                           │
- flake.nix                           │

- ┘

- ↕ Interaction

**┌─ External Systems ──────────────────────────┐**

- Nix Package Manager                       │
- Nixpkgs Repository                     │

- ┘

##### Key Elements to Highlight

a) Input Flow:
- Command line arguments → Options parsing → Template generation
- Package specifications → Nix configuration generation

b) Output Flow:
- Template rendering → File generation (shell.nix/flake.nix)
- Integration with existing Nix ecosystem

##### Implementation Details

- Haskell-based architecture
- Pure functional approach
- File-based output system
- Template-based generation

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef logic fill:#2ecc71,stroke:#27ae60,color:white
    classDef output fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef test fill:#e74c3c,stroke:#c0392b,color:white

    %% User Interface Layer
    subgraph UI
        CLI["Command Line Interface"]
        ArgParser["Argument Parser"]
    end

    %% Business Logic Layer
    subgraph Logic
        TempGen["Template Generation Engine"]
        FlakeTemp["Flake Template Handler"]
        ShellTemp["Shell Template Handler"]
        Constants["Constants & Configuration"]
        CoreLogic["Core Business Logic"]
    end

    %% Output Generation Layer
    subgraph Output
        ShellNix["shell.nix"]
        FlakeNix["flake.nix"]
    end

    %% Testing Layer
    subgraph Testing
        TestSpec["Test Specifications"]
        TestHelp["Test Helpers"]
        TestOut["Output Examples"]
        CICD["CI/CD Pipeline"]
    end

    %% External Systems
    subgraph External
        NixPM["Nix Package Manager"]
        NixPkgs["Nixpkgs Repository"]
    end

    %% Relationships
    CLI --> ArgParser
    ArgParser --> CoreLogic
    CoreLogic --> TempGen
    TempGen --> FlakeTemp
    TempGen --> ShellTemp
    Constants --> TempGen
    FlakeTemp --> FlakeNix
    ShellTemp --> ShellNix
    FlakeNix --> NixPM
    ShellNix --> NixPM
    NixPM --> NixPkgs
    TestSpec --> TestHelp
    TestHelp --> TestOut
    CICD --> TestSpec

    %% Click Events
    click CLI "https://github.com/danielrolls/shellify/blob/master/app/Main.hs"
    click ArgParser "https://github.com/danielrolls/shellify/blob/master/src/Options.hs"
    click TempGen "https://github.com/danielrolls/shellify/blob/master/src/TemplateGeneration.hs"
    click FlakeTemp "https://github.com/danielrolls/shellify/blob/master/src/FlakeTemplate.hs"
    click ShellTemp "https://github.com/danielrolls/shellify/blob/master/src/ShellifyTemplate.hs"
    click Constants "https://github.com/danielrolls/shellify/blob/master/src/Constants.hs"
    click CoreLogic "https://github.com/danielrolls/shellify/blob/master/src/Shellify.hs"
    click TestSpec "https://github.com/danielrolls/shellify/blob/master/test/Spec.hs"
    click TestHelp "https://github.com/danielrolls/shellify/blob/master/test/TestHelpers.hs"
    click TestOut "https://github.com/danielrolls/shellify/tree/master/test/outputs"
    click CICD "https://github.com/danielrolls/shellify/blob/master/.github/workflows/cabaltest.yml"

    %% Legend
    subgraph Legend
        UI_L["User Interface"]:::ui
        Logic_L["Business Logic"]:::logic
        Output_L["Output Generation"]:::output
        External_L["External Systems"]:::external
        Test_L["Testing Components"]:::test
    end
```
