# gorkaerana/meddle architecture

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

- Interactive diagram: https://gitdiagram.com/gorkaerana/meddle
- Repository: https://github.com/gorkaerana/meddle

## Overview

##### Main Components

a) Parser Core (Blue Components)
- MDL Grammar Parser
- Lark grammar file (mdl_grammar.lark)
- Parser implementation (parser.py)
- Validation Engine
- Validation rules (validation.json)
- Validator implementation (validation.py)

b) Data Models (Green Components)
- Command Class
- Component Class
- Attribute Class
With their relationships and inheritance patterns

c) Utility Layer (Yellow Components)
- Scraping utilities (scripts/scrape_components.py, scripts/scrape_mdl_files.py)
- Test infrastructure

##### Flow and Relationships

**[MDL Input] → [Parser Core] → [Data Models] → [Validation Engine] → [Validated Output]**

Key elements to highlight:

##### Component Details

a) Parser Core:
- Grammar definition flow
- Parsing stages
- To validation rules

b) Data Models:
- Command structure
- Component hierarchy
- Attribute definitions
- Validation constraints

c) Testing Framework:
- Example MDL files
- Validation test cases
- Benchmark tests

##### Implementation Details

Technology stack:
- Python implementation
- Lark parser usage
- JSON validation rules

##### Connections

- Data flow direction
- Validation paths
- Error handling routes
- Test coverage paths

##### The handling of special cases and limitations

Remember to:
- Both the static structure and dynamic flow
- Validation rules and constraints
- Error handling paths

This will provide a comprehensive view of the MDL parser's architecture while maintaining clarity and technical accuracy.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        MDL[MDL Input Files]
    end

    subgraph "Parser Core"
        Grammar["MDL Grammar Parser"]:::core
        Parser["Parser Implementation"]:::core
        Grammar --> Parser
    end

    subgraph "Data Models"
        Command["Command Class"]:::model
        Component["Component Class"]:::model
        Attribute["Attribute Class"]:::model
        Component --> Attribute
        Command --> Component
    end

    subgraph "Validation Layer"
        VEngine["Validation Engine"]:::validation
        VRules["Validation Rules"]:::validation
        VEngine --> VRules
    end

    subgraph "Utility Layer"
        ScrapeComp["Component Scraper"]:::utility
        ScrapeMDL["MDL File Scraper"]:::utility
        TestInfra["Test Infrastructure"]:::utility
    end

    subgraph "Output"
        Valid["Validated Output"]
        Error["Validation Exceptions"]:::error
    end

    MDL --> Grammar
    Parser --> Command
    Command --> VEngine
    VEngine --> Valid
    VEngine --> Error

    TestInfra --> Grammar
    TestInfra --> Parser
    TestInfra --> VEngine

    ScrapeComp --> Component
    ScrapeMDL --> MDL

    %% Special Cases
    UnsupportedTypes["Unsupported Types<br/>(SdkCode, Expression)"]:::error
    Component --> UnsupportedTypes

    %% Styling
    classDef core fill:#a8d1f0,stroke:#333
    classDef model fill:#90EE90,stroke:#333
    classDef validation fill:#FF9999,stroke:#333
    classDef utility fill:#FFE5B4,stroke:#333
    classDef error fill:#FF6B6B,stroke:#333

    %% Click Events
    click Grammar "https://github.com/gorkaerana/meddle/blob/main/src/meddle/mdl_grammar.lark"
    click Parser "https://github.com/gorkaerana/meddle/blob/main/src/meddle/parser.py"
    click VEngine "https://github.com/gorkaerana/meddle/blob/main/src/meddle/validation.py"
    click VRules "https://github.com/gorkaerana/meddle/blob/main/src/meddle/validation.json"
    click ScrapeComp "https://github.com/gorkaerana/meddle/blob/main/scripts/scrape_components.py"
    click ScrapeMDL "https://github.com/gorkaerana/meddle/blob/main/scripts/scrape_mdl_files.py"
    click TestInfra "https://github.com/gorkaerana/meddle/blob/main/tests/test_mdl_grammar.py"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Data Models"]:::model
        L3["Validation"]:::validation
        L4["Utilities"]:::utility
        L5["Errors"]:::error
    end
```
