# iamgio/quarkdown architecture

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

- Interactive diagram: https://gitdiagram.com/iamgio/quarkdown
- Repository: https://github.com/iamgio/quarkdown

## Overview

##### Main Components Identification

The system can be broken down into these major components:

a) Core Engine:
- Lexer/Parser (core/src/main/kotlin/eu/iamgio/quarkdown/lexer, parser)
- AST (core/src/main/kotlin/eu/iamgio/quarkdown/ast)
- Function System (core/src/main/kotlin/eu/iamgio/quarkdown/function)
- Rendering System (core/src/main/kotlin/eu/iamgio/quarkdown/rendering)

b) CLI Interface:
- Command Processing (cli/src/main/kotlin/eu/iamgio/quarkdown/cli)
- Execution Strategies (cli/src/main/kotlin/eu/iamgio/quarkdown/cli/exec/strategy)

c) Server Component:
- Web Server (server/src/main/kotlin/eu/iamgio/quarkdown/server)
- Browser Integration (server/src/main/kotlin/eu/iamgio/quarkdown/server/browser)

d) Standard Library:
- Built-in Functions (stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib)

**┌─────────────────────────────────────────────────────────────┐**
- User Interface Layer                     │
- ┌──────────┐    ┌──────────┐    ┌──────────────────────┐  │
- CLI    │    │   REPL   │    │    Web Interface     │  │
- ┬─────┘    └────┬─────┘    └──────────┬───────────┘  │
- ┼──────────────┼─────────────────────┼──────────────┘

**┌───────┼──────────────┼─────────────────────┼──────────────┐**
- Processing Layer                 │              │
- ┌────▼─────┐    ┌───▼────────┐    ┌─────▼────────┐     │
- Pipeline  │◄───┤ Compiler   │    │ Web Server   │     │
- ┬─────┘    └───────────┬┘    └──────────────┘     │

- ┌────▼──────────────────────▼─┐                        │
- Core Engine            │                        │
- ┌─────────┐  ┌─────────┐  │                        │
- Lexer  │──►  Parser │  │                        │
- ┘  └────┬────┘  │                        │

- ┌─────▼────┐   │                        │
- AST    │   │                        │
- ┬────┘   │                        │

- ┌───────▼──────┐ │     ┌──────────────┐  │
- Functions   │◄┼─────┤Standard Lib  │  │
- ┬──────┘ │     └──────────────┘  │

- ┌───────▼──────┐ │                        │
- Renderer    │ │                        │
- ┘ │                        │
- ┘                         │
- ┘

##### Key Relationships to Highlight

a) Input Flow:
- CLI/REPL → Pipeline → Core Engine
- Web Interface → Web Server → Pipeline

b) Processing Flow:
- Lexer → Parser → AST → Functions → Renderer
- Standard Library integration with Functions
- Pipeline orchestration of the entire process

##### Additional Elements

Important aspects:
- Document type support (slides, paged, plain)
- Media storage system
- Theme system
- File watching and live preview capabilities
- Function call system
- Error handling flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef processing fill:#2ecc71,stroke:#27ae60,color:white
    classDef core fill:#f1c40f,stroke:#f39c12,color:black
    classDef lib fill:#9b59b6,stroke:#8e44ad,color:white
    classDef error fill:#e74c3c,stroke:#c0392b,color:white

    %% User Interface Layer
    subgraph UI
        CLI["CLI Interface"]:::ui
        REPL["REPL"]:::ui
        WEB["Web Interface"]:::ui
    end

    %% Processing Layer
    subgraph Processing
        Pipeline["Pipeline System"]:::processing
        Compiler["Compiler"]:::processing
        WebServer["Web Server"]:::processing
    end

    %% Core Engine
    subgraph CoreEngine
        Lexer["Lexer"]:::core
        Parser["Parser"]:::core
        AST["AST"]:::core
        Functions["Function System"]:::core
        Renderer["Renderer"]:::core
    end

    %% Libraries and Support Systems
    StdLib["Standard Library"]:::lib
    MediaSystem["Media System"]:::core
    ThemeSystem["Theme System"]:::core
    DocSystem["Document System"]:::core
    ErrorHandler["Error Handler"]:::error

    %% Relationships
    CLI --> Pipeline
    REPL --> Pipeline
    WEB --> WebServer
    WebServer --> Pipeline
    Pipeline --> Compiler
    Compiler --> CoreEngine
    
    Lexer --> Parser
    Parser --> AST
    AST --> Functions
    Functions --> Renderer
    StdLib --> Functions
    
    Functions --> MediaSystem
    Functions --> ThemeSystem
    Functions --> DocSystem
    
    Pipeline --> ErrorHandler
    Functions --> ErrorHandler

    %% Click Events
    click CLI "https://github.com/iamgio/quarkdown/tree/main/cli/src/main/kotlin/eu/iamgio/quarkdown/cli/"
    click WebServer "https://github.com/iamgio/quarkdown/tree/main/server/src/main/kotlin/eu/iamgio/quarkdown/server/"
    click Pipeline "https://github.com/iamgio/quarkdown/tree/main/core/src/main/kotlin/eu/iamgio/quarkdown/pipeline/"
    click Lexer "https://github.com/iamgio/quarkdown/tree/main/core/src/main/kotlin/eu/iamgio/quarkdown/lexer/"
    click Parser "https://github.com/iamgio/quarkdown/tree/main/core/src/main/kotlin/eu/iamgio/quarkdown/parser/"
    click AST "https://github.com/iamgio/quarkdown/tree/main/core/src/main/kotlin/eu/iamgio/quarkdown/ast/"
    click Functions "https://github.com/iamgio/quarkdown/tree/main/core/src/main/kotlin/eu/iamgio/quarkdown/function/"
    click Renderer "https://github.com/iamgio/quarkdown/tree/main/core/src/main/kotlin/eu/iamgio/quarkdown/rendering/"
    click StdLib "https://github.com/iamgio/quarkdown/tree/main/stdlib/src/main/kotlin/eu/iamgio/quarkdown/stdlib/"
    click MediaSystem "https://github.com/iamgio/quarkdown/tree/main/core/src/main/kotlin/eu/iamgio/quarkdown/media/"
    click DocSystem "https://github.com/iamgio/quarkdown/tree/main/core/src/main/kotlin/eu/iamgio/quarkdown/document/"
    click ThemeSystem "https://github.com/iamgio/quarkdown/tree/main/core/src/main/resources/render/theme/"
    click ErrorHandler "https://github.com/iamgio/quarkdown/tree/main/core/src/main/kotlin/eu/iamgio/quarkdown/pipeline/error/"
```
