# rydnr/dry-wit architecture

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

- Interactive diagram: https://gitdiagram.com/rydnr/dry-wit
- Repository: https://github.com/rydnr/dry-wit

## Overview

##### Main Components

a. Core Framework Layer
- Core Runtime Environment
- Module Loading System
- Script Execution Pipeline

b. Module System
- Standard Modules (src/modules/*.dw)
- Extension Modules (src/modules/ext/*.dw)
- Theme System (themes/*.dwt)

c. Testing Framework
- Test Runner
- Individual Test Suites

d. Integration Layer
- Nix Integration
- System Dependencies

**┌─────────────────────────────────────────────┐**
- Client Script                  │
- ┬─────────────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- dry-wit Runtime                 │
- ┤
- Module System  │  Core Functions │ Themes  │
- ┬───────────────┬────────────┬─────┘
- ↓               ↓            ↓
**┌─────────────────┐ ┌──────────┐ ┌──────────┐**
- Standard Modules│ │   Ext    │ │  Theme   │
- Modules   │ │ Handlers │
- ┘ └──────────┘ └──────────┘

##### Key Relationships

a. Script Execution Flow:
- How a client script interfaces with dry-wit
- Module loading sequence
- Demonstrate error handling flow

b. Module Dependencies:
- Relationships between standard and extension modules
- Core module dependencies

c. Integration Points:
- Nix integration
- System dependency management
- External tool interactions

##### Implementation Details to Note

- Distinction between .dw module files and their implementation
- Role of the dry-wit executable
- Configuration paths and file locations
- Document system requirements (Bash 4+, required tools)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CS[Client Script]
    end

    subgraph Runtime
        DW["Core Runtime"]:::core
        click DW "https://github.com/rydnr/dry-wit/tree/main/src/dry-wit"
    end

    subgraph "Core Layer"
        ML["Module Loader"]:::core
        click ML "https://github.com/rydnr/dry-wit/blob/main/src/modules/dw-plumbing.dw"
        CF["Core Functions"]:::core
        click CF "https://github.com/rydnr/dry-wit/blob/main/src/modules/stdlib.dw"
        EH["Error Handler"]:::core
        click EH "https://github.com/rydnr/dry-wit/blob/main/src/modules/error.dw"
        LG["Logging System"]:::core
        click LG "https://github.com/rydnr/dry-wit/blob/main/src/modules/logging.dw"
        EV["Environment Variables"]:::core
        click EV "https://github.com/rydnr/dry-wit/blob/main/src/modules/envvar.dw"
        CLI["CLI Interface"]:::core
        click CLI "https://github.com/rydnr/dry-wit/blob/main/src/modules/cli.dw"
        DBG["Debug System"]:::core
        click DBG "https://github.com/rydnr/dry-wit/blob/main/src/modules/debug.dw"
        CHK["System Checker"]:::core
        click CHK "https://github.com/rydnr/dry-wit/blob/main/src/modules/check.dw"
        COL["Color Support"]:::core
        click COL "https://github.com/rydnr/dry-wit/blob/main/src/modules/color.dw"
        CMD["Command Execution"]:::core
        click CMD "https://github.com/rydnr/dry-wit/blob/main/src/modules/command.d"
    end

    subgraph "Module System"
        SM["Standard Modules"]:::module
        click SM "https://github.com/rydnr/dry-wit/tree/main/src/modules/"
        EM["Extension Modules"]:::module
        click EM "https://github.com/rydnr/dry-wit/tree/main/src/modules/ext/"
    end

    subgraph "Theme System"
        TS["Theme Handler"]:::theme
        click TS "https://github.com/rydnr/dry-wit/tree/main/themes/"
        DT["Default Theme"]:::theme
        click DT "https://github.com/rydnr/dry-wit/blob/main/themes/default.dwt"
    end

    subgraph "Testing Framework"
        TR["Test Runner"]:::test
        click TR "https://github.com/rydnr/dry-wit/blob/main/test/test-all.sh"
        TS["Test Suites"]:::test
        click TS "https://github.com/rydnr/dry-wit/tree/main/test/"
    end

    subgraph "Integration"
        NI["Nix Integration"]:::integration
        click NI "https://github.com/rydnr/dry-wit/blob/main/nix/flake.nix"
        ETI["External Tools"]:::integration
        click ETI "https://github.com/rydnr/dry-wit/tree/main/src/modules/ext/"
        DOC["Documentation"]:::docs
        click DOC "https://github.com/rydnr/dry-wit/tree/main/docs/"
    end

    CS --> DW
    DW --> ML
    ML --> CF
    ML --> EH
    ML --> LG
    ML --> EV
    ML --> CLI
    ML --> DBG
    ML --> CHK
    ML --> COL
    ML --> CMD
    
    ML --> SM
    ML --> EM
    ML --> TS
    
    TS --> DT
    
    DW --> TR
    TR --> TS
    
    DW --> NI
    DW --> ETI

    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef module fill:#57a773,stroke:#57a773,color:#fff
    classDef theme fill:#f7a072,stroke:#f7a072,color:#fff
    classDef test fill:#b4aeb4,stroke:#b4aeb4,color:#fff
    classDef integration fill:#f4845f,stroke:#f4845f,color:#fff
    classDef docs fill:#666,stroke:#666,color:#fff

    %% Legend
    classDef legend fill:#f5f5f5,stroke:#666
    subgraph Legend
        L1[Core Components]:::core
        L2[Modules]:::module
        L3[Themes]:::theme
        L4[Testing]:::test
        L5[Integration]:::integration
        L6[Documentation]:::docs
    end
```
