# leeonky/dal-java architecture

> Architecture diagram of the GitHub repository leeonky/dal-java, 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/leeonky/dal-java
- Repository: https://github.com/leeonky/dal-java

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Engine Components:
- Compiler Module
- Runtime Module
- AST (Abstract Syntax Tree) Module
- Expression Evaluator

b) Extension System:
- Property Accessors
- Formatters
- Schema System
- Custom Operators

##### Architectural Layers

**┌─────────────────────────────────────────────┐**
- Public API Layer               │
- (DAL, DALFactory, Assertions classes)    │
- ┤
- Expression Processing            │
- (Compiler, AST Nodes, Operators)        │
- ┤
- Runtime Engine                 │
- (Evaluation, Data Access, Type Handling)   │
- ┤
- Extension System                 │
- (Formatters, Schemas, Property Accessors)   │
- ┘

##### Key Relationships to Highlight

a) Data Flow:
- Input text → Compiler → AST → Runtime Evaluation → Result/Assertion
- Schema definitions → Runtime Verification
- Property Access → Data Resolution

b) Extension Points:
- Custom Property Accessors
- User-defined Literals
- Schema Registration
- Custom Formatters

##### Specific Implementation Details

**DAL (Main Entry Point)**
- ↓
**DALFactory**
- ↓
**Compiler ←→ AST Nodes**
- ↓
**Runtime Context**
- ↓
**Property Accessors → Data Resolution**
- ↓
**Assertions/Results**

##### Important Features to Highlight

- Schema System: Show how Schema classes integrate with runtime verification
- Expression Evaluation: Illustrate operator precedence handling
- Table Processing: Show the table parsing and verification flow
- Collection Handling: Demonstrate collection access and verification

##### Design Patterns Used

- Factory Pattern (DALFactory)
- Visitor Pattern (AST processing)
- Builder Pattern (RuntimeContextBuilder)
- Strategy Pattern (Property Accessors)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef api fill:#FFE873,stroke:#333
    classDef compiler fill:#7CB9E8,stroke:#333
    classDef runtime fill:#98FB98,stroke:#333
    classDef extension fill:#F08080,stroke:#333
    classDef error fill:#FF6B6B,stroke:#333
    classDef ast fill:#B19CD9,stroke:#333

    %% Public API Layer
    subgraph API
        DAL["DAL"]
        DALFactory["DALFactory"]
        Assertions["Assertions"]
    end

    %% Compiler Layer
    subgraph CompilerLayer
        Compiler["Compiler"]
        Operators["Operators"]
        Tokens["Tokens"]
    end

    %% AST Layer
    subgraph ASTLayer
        ASTNodes["AST Nodes"]
        DALOperator["DAL Operator"]
    end

    %% Runtime Layer
    subgraph RuntimeLayer
        RuntimeContext["Runtime Context"]
        RuntimeData["Runtime Data"]
        Calculator["Calculator"]
        Operation["Operation"]
    end

    %% Extension Layer
    subgraph ExtensionSystem
        PropertyAccessor["Property Accessor"]
        Formatters["Formatters"]
        SchemaSystem["Schema System"]
        CustomOperators["Custom Operators"]
    end

    %% Error Handling
    subgraph ErrorHandling
        DalException["DAL Exception"]
        ErrorHook["Error Hook"]
    end

    %% Type System
    subgraph TypeSystem
        Types["Types"]
        TypeFormat["Type Format"]
    end

    %% Relationships
    DAL --> DALFactory
    DALFactory --> Compiler
    Compiler --> ASTNodes
    ASTNodes --> DALOperator
    DALOperator --> Operation
    Operation --> Calculator
    Calculator --> RuntimeData
    RuntimeContext --> PropertyAccessor
    RuntimeContext --> Formatters
    RuntimeContext --> SchemaSystem
    RuntimeContext --> CustomOperators
    RuntimeData --> DalException
    DalException --> ErrorHook
    SchemaSystem --> Types
    Formatters --> TypeFormat

    %% Click events
    click DAL "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/DAL.java"
    click DALFactory "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/DALFactory.java"
    click Assertions "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/Assertions.java"
    click Compiler "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/compiler/Compiler.java"
    click Operators "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/compiler/Operators.java"
    click Tokens "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/compiler/Tokens.java"
    click ASTNodes "https://github.com/leeonky/DAL-java/tree/master/src/main/java/com/github/leeonky/dal/ast/node"
    click DALOperator "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/ast/opt/DALOperator.java"
    click RuntimeContext "https://github.com/leeonky/DAL-java/tree/master/src/main/java/com/github/leeonky/dal/runtime"
    click RuntimeData "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/runtime/RuntimeData.java"
    click PropertyAccessor "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/runtime/PropertyAccessor.java"
    click Formatters "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/format/Formatters.java"
    click SchemaSystem "https://github.com/leeonky/DAL-java/tree/master/src/main/java/com/github/leeonky/dal/runtime/schema"
    click CustomOperators "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/extensions/Operators.java"
    click Calculator "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/runtime/Calculator.java"
    click Operation "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/runtime/Operation.java"
    click DalException "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/runtime/DalException.java"
    click ErrorHook "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/runtime/ErrorHook.java"
    click Types "https://github.com/leeonky/DAL-java/tree/master/src/main/java/com/github/leeonky/dal/type"
    click TypeFormat "https://github.com/leeonky/DAL-java/blob/master/src/main/java/com/github/leeonky/dal/format/Type.java"

    %% Apply classes
    class DAL,DALFactory,Assertions api
    class Compiler,Operators,Tokens compiler
    class ASTNodes,DALOperator ast
    class RuntimeContext,RuntimeData,Calculator,Operation runtime
    class PropertyAccessor,Formatters,SchemaSystem,CustomOperators extension
    class DalException,ErrorHook error
```
