# spanag/eden architecture

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

## Overview

##### Main Components

a. Core Components:
- NeuroML Parser/Processor (based on eden/NeuroML.cpp and eden/NeuroML.h)
- LEMS Expression Engine (eden/neuroml/LEMS_Expr.*)
- Code Generator (implied by README's mention of runtime code generation)
- Parallel Execution Engine (supports both OpenMP and optional MPI)
- Memory Management System (eden/MMMallocator.h)

b. External Interfaces:
- Command Line Interface
- Python Package Interface (testing/python_package)
- File I/O System (for model inputs and simulation outputs)

**[Input Layer]**
- NeuroML Files / LEMS Files
- ↓
**[Processing Layer]**
- NeuroML Parser → LEMS Expression Engine
- ↓
**[Generation Layer]**
- Code Generator
- ↓
**[Execution Layer]**
- Parallel Execution Engine (OpenMP/MPI)
- ↓
**[Output Layer]**
- Simulation Results

##### Important Elements to Highlight

- Input/Output components (rectangles)
- Processing modules (rounded rectangles)
- Execution components (hexagons)

b. Parallel processing capabilities:
- A parallel execution pool representation
- MPI communication paths if applicable
- OpenMP thread distribution

##### Integration Points

- Both CLI and Python API entry points
- Third-party dependencies (pugixml, cJSON)
- Compiler integration point (crucial runtime dependency)

##### Specific Implementation Details

- NeuroML Parser and LEMS Expression Engine
- Code Generator and Compiler
- Execution Engine and Memory Manager

##### Technical Notes

- Runtime code generation and compilation workflow
- Parallel execution capabilities (both OpenMP and MPI)
- Memory management strategy
- File I/O patterns for model input and result output

##### Implementation-Specific Details

Specialized components:
- Custom memory allocator (MMMallocator)
- LEMS core components integration
- Platform-specific compilation paths
- Python package wrapper structure

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        NML[NeuroML Files]
        LEMS[LEMS Files]
    end

    subgraph Processing
        Parser["NeuroML Parser/Processor"]:::core
        LEMSEngine["LEMS Expression Engine"]:::core
        LEMSCore["LEMS Core Components"]:::core
    end

    subgraph Generation
        CodeGen["Code Generator"]:::core
        Compiler["Compiler Integration"]
    end

    subgraph Execution
        ExecEngine["Parallel Execution Engine"]:::core
        MemMgr["Memory Management System"]:::core
        ParallelPool{"Parallel Processing Pool"}
        MPI{"MPI Communication"}
        OpenMP{"OpenMP Threads"}
    end

    subgraph Interfaces
        CLI["Command Line Interface"]:::interface
        PythonAPI["Python Package Interface"]:::interface
        SimRunner["Simulation Runner"]:::interface
        Validation["Validation Framework"]:::testing
    end

    subgraph External
        JSON["cJSON Parser"]:::external
        XML["pugixml Parser"]:::external
    end

    subgraph Output
        Results["Simulation Results"]
    end

    %% Connections
    NML & LEMS --> Parser
    Parser <--> LEMSEngine
    LEMSEngine --> LEMSCore
    Parser & LEMSEngine --> CodeGen
    CodeGen --> Compiler
    Compiler --> ExecEngine
    ExecEngine --> MemMgr
    ExecEngine --> ParallelPool
    ParallelPool --> MPI & OpenMP
    ExecEngine --> Results

    CLI & PythonAPI --> Parser
    SimRunner --> ExecEngine
    Parser --> XML
    LEMSEngine --> JSON
    Validation --> SimRunner

    %% Click Events
    click Parser "https://github.com/spanag/eden/blob/main/eden/NeuroML.cpp"
    click LEMSEngine "https://github.com/spanag/eden/blob/main/eden/neuroml/LEMS_Expr.cpp"
    click LEMSCore "https://github.com/spanag/eden/blob/main/eden/neuroml/LEMS_CoreComponents.inc.xml"
    click MemMgr "https://github.com/spanag/eden/blob/main/eden/MMMallocator.h"
    click PythonAPI "https://github.com/spanag/eden/tree/main/testing/python_package/eden_simulator"
    click CLI "https://github.com/spanag/eden/blob/main/testing/python_package/eden_simulator/command_line.py"
    click SimRunner "https://github.com/spanag/eden/blob/main/testing/python_package/eden_simulator/run_sim.py"
    click Validation "https://github.com/spanag/eden/blob/main/testing/validation_tests/eden_tools/validation.py"
    click JSON "https://github.com/spanag/eden/blob/main/thirdparty/cJSON-1.7.1"
    click XML "https://github.com/spanag/eden/blob/main/thirdparty/pugixml-1.9"

    %% Styles
    classDef core fill:#f9f,stroke:#333,stroke-width:2px;
    classDef interface fill:#bbf,stroke:#333,stroke-width:2px;
    classDef external fill:#ddd,stroke:#333,stroke-width:2px;
    classDef testing fill:#bfb,stroke:#333,stroke-width:2px;

    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        InterfaceComp["Interface Component"]:::interface
        ExtComp["External Dependency"]:::external
        TestComp["Testing Component"]:::testing
    end
```
