# thorstenhater/nmlcc architecture

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

- Interactive diagram: https://gitdiagram.com/thorstenhater/nmlcc
- Repository: https://github.com/thorstenhater/nmlcc

## Overview

##### Main Components

a) Input Processing Layer:
- NML2/LEMS File Parser
- Schema Validator
- Unit Converter

b) Core Compilation Layer:
- Component Type Processor
- Expression Analyzer
- Variable Manager
- Network Processor

c) Export Layer:
- NMODL Generator
- ACC (Arbor Cable Cell) Generator
- Bundle Generator

d) Supporting Components:
- Error Handler
- Schema Manager
- File I/O Handler

##### Specific Implementation Details

**[Input Layer]**
- NML2/LEMS Files
- Schema Definitions
- Configuration Options

**[Core Processing]**
- Component Type Processing
- Ion Channel Processing
- Synapse Processing
- Concentration Model Processing
- Expression Analysis
- Network Processing

**[Export Layer]**
- NMODL Export
- Mechanism Generation
- ACC Export
- Cable Cell Description
- Bundle Export
- Combined NMODL/ACC
- Morphology Export
- Python Script Generation

##### Integration Points

External system interactions:
- Arbor Simulator Interface
- File System Interface
- Python Script Generation

##### Additional Notes

Annotations for:
- Performance optimization points
- Version compatibility notes
- Unit conversion points
- Error handling paths

##### The flexible export system supporting multiple output formats

Keep the abstraction level focused on the architectural components while maintaining enough detail to show the unique features of the compiler, such as its optimization capabilities and multiple export formats.

- Special symbols used for optimization points
- Component type indicators

## Diagram (Mermaid)

```mermaid
graph TB
    classDef input fill:#a8d1f0,stroke:#333
    classDef core fill:#b7e3c0,stroke:#333
    classDef export fill:#ffd4a8,stroke:#333
    classDef support fill:#e0e0e0,stroke:#333
    classDef external fill:#f0f0f0,stroke:#dashed
    
    subgraph Input
        NML["NML2/LEMS Files"]:::input
        Schema["Schema Definitions"]:::input
        Config["Configuration Options"]:::input
        Parser["NML2/LEMS Parser"]:::input
        SchemaVal["Schema Validator"]:::input
        UnitConv["Unit Converter"]:::input
    end

    subgraph Core
        CompType["Component Type Processor"]:::core
        ExprAnal["Expression Analyzer"]:::core
        VarMgr["Variable Manager"]:::core
        NetProc["Network Processor"]:::core
        
        subgraph CompProcessing["Component Processing"]
            IonChan["Ion Channel Processing"]:::core
            SynProc["Synapse Processing"]:::core
            ConcModel["Concentration Model Processing"]:::core
        end
    end

    subgraph Export
        NMODL["NMODL Generator"]:::export
        ACC["ACC Generator"]:::export
        Bundle["Bundle Generator"]:::export
        
        subgraph BundleOutputs["Bundle Outputs"]
            Combined["Combined NMODL/ACC"]:::export
            Morph["Morphology Export"]:::export
            PyGen["Python Script Generation"]:::export
        end
    end

    ErrorHandler["Error Handler"]:::support
    
    %% Relationships
    NML --> Parser
    Schema --> SchemaVal
    Config --> Parser
    
    Parser --> SchemaVal
    SchemaVal --> CompType
    Parser --> UnitConv
    UnitConv --> CompType
    
    CompType --> IonChan
    CompType --> SynProc
    CompType --> ConcModel
    
    IonChan & SynProc & ConcModel --> ExprAnal
    ExprAnal --> VarMgr
    VarMgr --> NetProc
    
    NetProc --> NMODL
    NetProc --> ACC
    NMODL & ACC --> Bundle
    
    Bundle --> Combined
    Bundle --> Morph
    Bundle --> PyGen
    
    ErrorHandler -.-> Parser
    ErrorHandler -.-> CompType
    ErrorHandler -.-> NetProc
    ErrorHandler -.-> Bundle

    %% Click events
    click Parser "https://github.com/thorstenhater/nmlcc/blob/main/src/lems/file.rs"
    click SchemaVal "https://github.com/thorstenhater/nmlcc/blob/main/src/schema.rs"
    click CompType "https://github.com/thorstenhater/nmlcc/blob/main/src/component_type.rs"
    click ExprAnal "https://github.com/thorstenhater/nmlcc/blob/main/src/expr.rs"
    click VarMgr "https://github.com/thorstenhater/nmlcc/blob/main/src/variable.rs"
    click NetProc "https://github.com/thorstenhater/nmlcc/blob/main/src/network.rs"
    click NMODL "https://github.com/thorstenhater/nmlcc/blob/main/src/nmodl.rs"
    click ACC "https://github.com/thorstenhater/nmlcc/blob/main/src/acc.rs"
    click Bundle "https://github.com/thorstenhater/nmlcc/blob/main/src/bundle.rs"
    click ErrorHandler "https://github.com/thorstenhater/nmlcc/blob/main/src/error.rs"
    
    %% Legend
    subgraph Legend
        Input1["Input Layer"]:::input
        Core1["Core Processing"]:::core
        Export1["Export Layer"]:::export
        Support1["Support Components"]:::support
    end
```
