# vilterp/datalog-ts architecture

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

- Interactive diagram: https://gitdiagram.com/vilterp/datalog-ts
- Repository: https://github.com/vilterp/datalog-ts

## Overview

##### Main Components

a) Core Engine Layer:
- Datalog interpreter (/core)
- Incremental evaluation engine (/core/incremental)
- Optimization subsystem (/core/opt)

b) Language Workbench Layer:
- This in the middle layer
- Parser library (/languageWorkbench/parserlib)
- Language implementations (DL, DL2, SQL, TreeDL, etc.)
- Common IDE services (/languageWorkbench/common)

c) Applications Layer:
- At the top layer
- Various applications (/apps):
- Execution visualizer
- Notebook interface
- Language workbench UI
- VSCode extension
- REPL

d) UI Common Components:
- As a vertical layer connecting to apps
- Explorer components
- Visualization components
- IDE components

##### Relationships and Data Flow

- Data flow from parser → core engine → UI
- IDE services interaction with language implementations
- Visualization pipeline from core to UI
- Extension points for language implementations

##### Component Details

Core Engine:
**[Datalog Interpreter]**
- ↓
**[Incremental Evaluation]**
- ↓
**[Optimization Engine]**

Language Processing:
**[Parser Library] → [Language Implementations]**
- ↓
**[Common IDE Services]**

Applications:
**[VSCode Extension] [Notebook] [Visualizer]**
- ↓            ↓           ↓
- [UI Common Components Layer]
- ↓
- [Core Services]

##### Additional Elements

- Version/state management flows
- Test/benchmark integration points
- Extension mechanisms

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef core fill:#a8d1f0,stroke:#333
    classDef lang fill:#90EE90,stroke:#333
    classDef ui fill:#DDA0DD,stroke:#333
    classDef app fill:#FFA07A,stroke:#333

    %% Applications Layer
    subgraph Apps
        VSCode["VSCode Extension"]:::app
        Notebook["Notebook Interface"]:::app
        Visualizer["Execution Visualizer"]:::app
        LangWorkbench["Language Workbench UI"]:::app
        REPL["REPL"]:::app
    end

    %% UI Common Layer
    subgraph UICommon
        Explorer["Explorer Components"]:::ui
        VisComp["Visualization Components"]:::ui
        IDEComp["IDE Components"]:::ui
    end

    %% Language Workbench Layer
    subgraph LanguageWorkbench
        Parser["Parser Library"]:::lang
        LangImpl["Language Implementations"]:::lang
        IDEServices["Common IDE Services"]:::lang
    end

    %% Core Engine Layer
    subgraph CoreEngine
        Datalog["Core Datalog Engine"]:::core
        Incremental["Incremental Evaluation"]:::core
        Optimizer["Optimization System"]:::core
    end

    %% Relationships
    VSCode --> IDEComp
    Notebook --> VisComp
    Visualizer --> VisComp
    LangWorkbench --> Explorer
    REPL --> Datalog

    IDEComp --> IDEServices
    VisComp --> Datalog
    Explorer --> LangImpl

    Parser --> LangImpl
    LangImpl --> IDEServices
    IDEServices --> Datalog

    Datalog --> Incremental
    Datalog --> Optimizer
    Optimizer --> Incremental

    %% Click Events
    click Datalog "https://github.com/vilterp/datalog-ts/tree/master//core"
    click Incremental "https://github.com/vilterp/datalog-ts/tree/master//core/incremental"
    click Optimizer "https://github.com/vilterp/datalog-ts/tree/master//core/opt"
    click Parser "https://github.com/vilterp/datalog-ts/tree/master//languageWorkbench/parserlib"
    click LangImpl "https://github.com/vilterp/datalog-ts/tree/master//languageWorkbench/languages"
    click IDEServices "https://github.com/vilterp/datalog-ts/tree/master//languageWorkbench/common"
    click Visualizer "https://github.com/vilterp/datalog-ts/tree/master//apps/executionVisualizer"
    click Notebook "https://github.com/vilterp/datalog-ts/tree/master//apps/notebook"
    click LangWorkbench "https://github.com/vilterp/datalog-ts/tree/master//apps/languageWorkbench"
    click VSCode "https://github.com/vilterp/datalog-ts/tree/master//apps/vscodeExtension"
    click REPL "https://github.com/vilterp/datalog-ts/tree/master//apps/cmd/repl"
    click Explorer "https://github.com/vilterp/datalog-ts/tree/master//uiCommon/explorer"
    click VisComp "https://github.com/vilterp/datalog-ts/tree/master//uiCommon/visualizations"
    click IDEComp "https://github.com/vilterp/datalog-ts/tree/master//uiCommon/ide"

    %% Legend
    subgraph Legend
        L1["Application Component"]:::app
        L2["UI Component"]:::ui
        L3["Language Component"]:::lang
        L4["Core Component"]:::core
    end
```
