# ulyssessouza/envlang architecture

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

- Interactive diagram: https://gitdiagram.com/ulyssessouza/envlang
- Repository: https://github.com/ulyssessouza/envlang

## Overview

##### Main Components

a. Parser Components:
- These correspond to the two grammar files (EnvLangFile.g4 and EnvLangValue.g4)

b. Core Components:
- DAO (Data Access Layer) - represented as a hexagon
- Handlers Layer - represented as rectangles
- Main Engine (envlang.go) - represented as a central component

c. Integration Layer:
- Autoload functionality - represented as a small module connected to the main engine

##### Component Relationships

- Input Stream → File Parser
- File Parser → Handlers
- Handlers ↔ DAO
- Value Parser ↔ Handlers
- DAO ↔ Environment Variables (external)

##### Detailed Component Breakdown

a. Parser Layer (Top):
**[Generated Parser Components]**
- File Parser (gen/fileparser/*)
- Value Parser (gen/valueparser/*)

b. Handler Layer (Middle):
**[Handlers]**
- File Handler
- Value Handler

c. Data Access Layer (Bottom):
**[DAO Interface]**
- Default DAO Implementation

##### Technical Details

- ANTLR4 grammar integration
- Where custom DAO implementations can be plugged in

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Grammar
        FileG[EnvLangFile.g4]:::grammar
        ValueG[EnvLangValue.g4]:::grammar
    end

    subgraph "Parser Layer"
        FileP["File Parser"]:::parser
        ValueP["Value Parser"]:::parser
    end

    subgraph "Handler Layer"
        FileH["File Handler"]:::handler
        ValueH["Value Handler"]:::handler
    end

    subgraph "Core Layer"
        Engine["Main Engine"]:::core
        Auto["Autoload"]:::core
    end

    subgraph "Data Access Layer"
        DAOI["DAO Interface"]:::dao
        DAOD["Default DAO Implementation"]:::dao
    end

    subgraph "Integration Layer"
        Compat["Godotenv Compatibility"]:::integration
    end

    subgraph "Environment"
        EnvVars["Environment Variables"]:::external
    end

    %% Relationships
    FileG --> FileP
    ValueG --> ValueP
    FileP --> FileH
    ValueP --> ValueH
    FileH --> Engine
    ValueH --> Engine
    Engine --> DAOI
    DAOI --> DAOD
    DAOD --> EnvVars
    Compat --> Engine
    Auto --> Engine

    %% Click Events
    click FileG "https://github.com/ulyssessouza/envlang/blob/main/EnvLangFile.g4"
    click ValueG "https://github.com/ulyssessouza/envlang/blob/main/EnvLangValue.g4"
    click FileP "https://github.com/ulyssessouza/envlang/blob/main/gen/fileparser/envlangfile_parser.go"
    click ValueP "https://github.com/ulyssessouza/envlang/blob/main/gen/valueparser/envlangvalue_parser.go"
    click FileH "https://github.com/ulyssessouza/envlang/blob/main/handlers/filehandler.go"
    click ValueH "https://github.com/ulyssessouza/envlang/blob/main/handlers/valuehandler.go"
    click Engine "https://github.com/ulyssessouza/envlang/blob/main/envlang.go"
    click DAOI "https://github.com/ulyssessouza/envlang/blob/main/dao/dao.go"
    click DAOD "https://github.com/ulyssessouza/envlang/blob/main/dao/default_dao.go"
    click Compat "https://github.com/ulyssessouza/envlang/blob/main/compat/joho/godotenv/facade.go"
    click Auto "https://github.com/ulyssessouza/envlang/blob/main/autoload/init.go"

    %% Styles
    classDef grammar fill:#f9f,stroke:#333,stroke-width:2px
    classDef parser fill:#9cf,stroke:#333,stroke-width:2px
    classDef handler fill:#9f9,stroke:#333,stroke-width:2px
    classDef core fill:#fc9,stroke:#333,stroke-width:2px
    classDef dao fill:#ff9,stroke:#333,stroke-width:2px
    classDef integration fill:#ccc,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5
    classDef external fill:#eee,stroke:#333,stroke-width:1px
```
