# maddenp/nml architecture

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

- Interactive diagram: https://gitdiagram.com/maddenp/nml
- Repository: https://github.com/maddenp/nml

## Overview

##### Main Components

a. Input Processing Layer:
- File Input Handler (stdin/file)
- Command-line Arguments Parser
- Input Validation Component

b. Core Processing Layer:
- Namelist Parser (using Instaparse)
- Query Engine (for --get operations)
- Modification Engine (for --set operations)
- Format Converter (for different output formats)

c. Output Processing Layer:
- File Output Handler (stdout/file)
- Format Handlers (namelist/JSON/bash/ksh)

##### Component Relationships

- Input → Parser → Core Processing → Output
- Parallel paths for different operations (get/set)
- Format conversion as a separate branch in the output stage

##### Specific Implementation Details

- Grammar Processing (src/grammar directory)
- Core Logic (src/nml/core.clj)
- Version Management (src/version)
- Test Framework (test directory)

##### Architectural Patterns to Highlight

- Pipeline Pattern: Show the linear flow of data transformation
- Strategy Pattern: For different output formats
- Command Pattern: For handling different operations (get/set)

##### Technical Stack Elements

- Clojure Runtime
- Instaparse Parser
- GraalVM Native Image (optional compilation path)
- File System Interface

**[Input Sources] → [Command Parser] → [Input Validator]**
- ↓
**[Grammar Rules] → [Instaparse Parser] → [Core Engine] → [Format Converter] → [Output Handler]**
- ↓
- [Operation Handlers]
- Query Engine
- Modification Engine

##### Clojure → GraalVM → Native Binary

This will help developers understand both the runtime behavior and the build/deployment options.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        IS[Input Sources]:::input
        CP[Command Parser]:::input
        IV[Input Validator]:::validation
    end

    subgraph Core
        GR["Grammar Rules"]:::grammar
        IP[Instaparse Parser]:::core
        CE["Core Engine"]:::core
        OH[Operation Handlers]:::core
        QE["Query Engine"]:::core
        ME["Modification Engine"]:::core
    end

    subgraph Output
        FC[Format Converter]:::format
        OFH[Output Handler]:::output
    end

    subgraph Build
        CJ["Clojure Runtime"]:::build
        UJ["Uberjar"]:::build
        GV["GraalVM"]:::build
        NB["Native Binary"]:::build
    end

    subgraph Testing
        TF["Test Framework"]:::test
        TC["Test Cases"]:::test
    end

    IS --> CP
    CP --> IV
    IV --> IP
    GR --> IP
    IP --> CE
    CE --> OH
    OH --> QE
    OH --> ME
    QE --> FC
    ME --> FC
    FC --> OFH

    CJ --> UJ
    CJ --> GV
    GV --> NB

    CE -.-> TF
    TF --> TC

    classDef input fill:#a8d1f0
    classDef core fill:#90EE90
    classDef output fill:#a8d1f0
    classDef format fill:#FFE5B4
    classDef validation fill:#FFB6C1
    classDef build fill:#DDA0DD
    classDef test fill:#F0E68C
    classDef grammar fill:#98FB98

    click CE "https://github.com/maddenp/nml/blob/master/src/nml/core.clj"
    click GR "https://github.com/maddenp/nml/tree/master/src/grammar/"
    click TF "https://github.com/maddenp/nml/tree/master/test/"
    click TC "https://github.com/maddenp/nml/blob/master/test/nml_test.f90"
    click CJ "https://github.com/maddenp/nml/blob/master/deps.edn"
    click UJ "https://github.com/maddenp/nml/blob/master/build.clj"
    click GV "https://github.com/maddenp/nml/tree/master/.github/scripts/"
    click NB "https://github.com/maddenp/nml/blob/master/.github/workflows/ci.yml"
```
