# ajstarks/decksh architecture

> Architecture diagram of the GitHub repository ajstarks/decksh, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ajstarks/decksh
- Repository: https://github.com/ajstarks/decksh

## Overview

##### Main Components

a. Core Components:
- DSL Parser/Processor
- Command Line Interface
- Code Generation Engine
- Rendering Pipeline

b. Supporting Components:
- Standard Library (built-in functions)
- File System Interface
- External Tools Integration

**[User Input]**

- ▼
**[Command Line Interface (cmd/decksh)]**

- ▼
**[DSL Parser/Processor]**
- [Variable Management]
- [Function Definitions]
- [Control Structures]

- ▼
**[Code Generation Engine]**
- [Markup Generator]
- [Graphics Primitives]
- [Text Processing]

- ▼
**[Output Pipeline]**
- [XML Generation]
- [Rendering Clients]

##### Component Details

a. Input Layer:
- File input (.dsh files)
- Command-line arguments
- Interactive input

b. Processing Layer:
- Parser component (parse.go)
- Variable handling (assign.go)
- Loop processing (loop.go)
- Conditional logic (cond.go)

c. Generation Layer:
- Markup generation
- Graphics primitives
- Text processing
- Image handling

d. Output Layer:
- XML output
- Integration with rendering tools (pdfdeck)

##### Relationships and Data Flow

- Bidirectional relationships where applicable

##### Implementation Details to Highlight

- File handling capabilities
- Built-in functions and operations
- Support for various graphic primitives
- Text processing features
- Integration with external tools

##### Key Technical Aspects

- Transformation pipeline from DSL to deck markup
- Coordinate system (0-100 percentage-based)
- Support for various data types (text, graphics, images)
- Integration points with rendering tools

##### Additional Elements

- Version information
- Supported file formats
- Error handling flow

##### Notes for Implementation

- Sufficient technical detail while maintaining clarity
- Both the architecture and the processing flow
- Extensibility points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        UserInput[User Input]
        DSHFiles[".dsh Files"]
        CLI["Command Line Interface"]:::cli
    end

    subgraph Core
        Parser["DSL Parser/Processor"]:::parser
        subgraph ParserComponents
            VarMgmt["Variable Management"]
            FuncDef["Function Definitions"]
            CtrlStruct["Control Structures"]
        end

        CodeGen["Code Generation Engine"]:::codegen
        subgraph GenerationComponents
            MarkupGen["Markup Generator"]
            Graphics["Graphics Primitives"]
            TextProc["Text Processing"]
        end
    end

    subgraph Output
        OutputPipe["Output Pipeline"]
        XMLGen["XML Generation"]
        RenderClient["Rendering Clients"]
    end

    subgraph Support
        StdLib["Standard Library"]
        FSInterface["File System Interface"]:::fsinterface
        ExtTools["External Tools"]
        Editors["Editor Integration"]:::editors
        Formatter["Code Formatter"]:::formatter
        Docs["Documentation"]:::docs
    end

    %% Relationships
    UserInput --> CLI
    DSHFiles --> CLI
    CLI --> Parser
    Parser --> CodeGen
    CodeGen --> OutputPipe
    OutputPipe --> XMLGen
    XMLGen --> RenderClient

    Parser --- StdLib
    Parser --- FSInterface
    CodeGen --- FSInterface
    ExtTools --- RenderClient
    Parser --- ParserComponents
    CodeGen --- GenerationComponents

    %% Click Events
    click CLI "https://github.com/ajstarks/decksh/tree/master/cmd/decksh/"
    click Parser "https://github.com/ajstarks/decksh/blob/master/parse.go"
    click CodeGen "https://github.com/ajstarks/decksh/blob/master/generate.go"
    click FSInterface "https://github.com/ajstarks/decksh/tree/master/cmd/decksh/code/"
    click Editors "https://github.com/ajstarks/decksh/tree/master/vscode/"
    click Formatter "https://github.com/ajstarks/decksh/tree/master/cmd/dshfmt/"
    click Docs "https://github.com/ajstarks/decksh/tree/master/doc/"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef parser fill:#90EE90,stroke:#333
    classDef codegen fill:#98FB98,stroke:#333
    classDef cli fill:#ADD8E6,stroke:#333
    classDef fsinterface fill:#FFA07A,stroke:#333
    classDef editors fill:#DDA0DD,stroke:#333
    classDef formatter fill:#F0E68C,stroke:#333
    classDef docs fill:#E6E6FA,stroke:#333

    %% Legend
    subgraph Legend
        L1[Input/Output]:::cli
        L2[Core Processing]:::parser
        L3[Supporting Components]:::fsinterface
        L4[Integration Tools]:::editors
    end
```
