# neilmacmullen/textrude architecture

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

- Interactive diagram: https://gitdiagram.com/neilmacmullen/textrude
- Repository: https://github.com/neilmacmullen/textrude

## Overview

##### Main Components
- Core Engine Layer – This is represented by the “Engine” directory, which houses the processing logic. It includes submodules for:
- Application processing (e.g., ApplicationEngine.cs, TemplateManager.cs, ScriptLoader.cs)
- Extensions (e.g., DebugMethods, TextrudeMethods, TimeRange recognizer logic)
- Model deserialization and representation (using specialized deserializers for CSV, JSON, YAML)
- Template processing and pre-processing
- CLI Tools – The “Textrude” directory contains the command implementations (e.g., CmdDo, CmdRender, CmdRenderFromFile, etc.), which interact with the engine for command-line operations.
- Interactive UI – The “TextrudeInteractive” project (a WPF-based application) provides a visual interface for rapid prototyping and interactive template development.
- Shared Components – The “SharedApplication” directory provides common utilities like command-line builders, file handling, and other shared functionality across the CLI and UI tools.
- Query and Script Library – Additional projects (“Query” and “ScriptLibrary”) handle specialized processing or provide script libraries to extend Textrude’s capabilities.
- Build & Testing Infrastructure – The “build” directory outlines tasks for building, packaging, and testing. The “Tests” folder houses the comprehensive unit tests that validate the system’s behavior.

##### Relationships and Interactions
- Data Input – External data files (CSV, JSON, YAML, plain text) are the inputs. These enter the system via file system operations (evident from classes like ConsoleFileSystem, WebFileSystem, HybridFileSystem) and are handed off to the engine.
- Core Processing – The Engine reads the model, utilizes the model deserializers, applies Scriban templates (using Scriban library integration), and produces output text/code.
- Output Generation – Output from the core engine is directed back to file systems or standard output – with dependency checking and template re-use included as features.
- External Libraries – It is important to visually indicate integration with external dependencies such as Scriban (templating), CsvHelper, YamlDotNet, Json.Net, and Humanizer as “service blocks” used by the Engine.

##### Architectural Patterns and Design Principles
- Layered Architecture – Separate the system into layers: UI/CLI layer, core engine layer (with submodules for model parsing, processing, templating), and supporting services (file operations and shared utilities).
- Modularity – Indicate how the Engine is designed to be extended (see the Extensions folder) and how there is a separation between concerns (e.g., model deserialization is clearly separated, and the template processing module is standalone).
- Reuse and Dependency Injection – Although not explicitly detailed, the utilitarian structure (like ModelDeserializerFactory, TemplateManager, etc.) suggests a design where decoupling and reusability are prioritized.

- Within the Core Engine layer, partition it into submodules that reflect the directories – Application, Extensions, Model, and TemplateProcessing.
- That both the CLI and UI projects interact with the Core Engine and the SharedApplication library.
- Optionally, note the testing and build process as supporting elements that ensure quality and deployment—they might be represented off to the side but clearly linked to the core components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Sources
    subgraph "External Data Sources"
        DF("Data Files (CSV, JSON, YAML, Text)"):::external
        FS1("ConsoleFileSystem"):::fs
        FS2("WebFileSystem"):::fs
        FS3("HybridFileSystem"):::fs
    end

    %% User Interface Layer
    subgraph "User Interface Layer"
        CLI("Textrude CLI"):::ui
        UI("TextrudeInteractive UI"):::ui
    end

    %% Core Engine Layer
    subgraph "Core Engine Layer"
        CE1("Engine/Application - Core Processing"):::engine
        CE2("Engine/Extensions"):::engine
        CE3("Engine/Model"):::engine
        CE4("Engine/TemplateProcessing"):::engine
    end

    %% Supporting Components
    subgraph "Supporting Components"
        SC1("SharedApplication"):::support
        SC2("Query"):::support
        SC3("ScriptLibrary"):::support
        SC4("build"):::support
        SC5("Tests"):::support
    end

    %% External Libraries
    subgraph "External Libraries"
        EL1("Scriban"):::external
        EL2("CsvHelper"):::external
        EL3("YamlDotNet"):::external
        EL4("Json.Net"):::external
        EL5("Humanizer"):::external
    end

    %% Data Files flow to FileSystems
    DF --> FS1
    DF --> FS2
    DF --> FS3

    %% FileSystems feed into the Core Engine
    FS1 --> CE1
    FS2 --> CE1
    FS3 --> CE1

    %% User Interfaces invoke Core Engine
    CLI --> CE1
    UI --> CE1

    %% Internal interactions within Core Engine
    CE1 --> CE2
    CE1 --> CE3
    CE1 --> CE4

    %% Core Engine uses shared utilities and libraries
    CE1 --> SC1
    CE1 --> SC2
    CE1 --> SC3
    CE1 --> EL1
    CE1 --> EL2
    CE1 --> EL3
    CE1 --> EL4
    CE1 --> EL5

    %% Build and Testing support for Core Engine
    SC4 --> CE1
    SC5 --> CE1

    %% Class definitions for styling
    classDef ui fill:#cce5ff,stroke:#0066cc,stroke-width:2px;
    classDef engine fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef support fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef fs fill:#E6E6FA,stroke:#8A2BE2,stroke-width:2px;

    %% Click Events for Component Mapping
    click CE1 "https://github.com/neilmacmullen/textrude/tree/main/Engine/Application"
    click CE2 "https://github.com/neilmacmullen/textrude/tree/main/Engine/Extensions"
    click CE3 "https://github.com/neilmacmullen/textrude/tree/main/Engine/Model"
    click CE4 "https://github.com/neilmacmullen/textrude/tree/main/Engine/TemplateProcessing"
    click CLI "https://github.com/neilmacmullen/textrude/tree/main/Textrude"
    click UI "https://github.com/neilmacmullen/textrude/tree/main/TextrudeInteractive"
    click SC1 "https://github.com/neilmacmullen/textrude/tree/main/SharedApplication"
    click SC2 "https://github.com/neilmacmullen/textrude/tree/main/Query"
    click SC3 "https://github.com/neilmacmullen/textrude/tree/main/ScriptLibrary"
    click SC4 "https://github.com/neilmacmullen/textrude/tree/main/build"
    click SC5 "https://github.com/neilmacmullen/textrude/tree/main/Tests"
```
