# sumannam/devs-python architecture

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

- Interactive diagram: https://gitdiagram.com/sumannam/devs-python
- Repository: https://github.com/sumannam/devs-python

## Overview

##### Project Type Analysis
This is a specialized simulation framework implementing the DEVS formalism, with multiple example projects focusing on pipe monitoring systems and nuclear facility simulations.

##### Main Architectural Components

A. Core DEVS Framework (src/ directory):
- Model Components
- ATOMIC_MODELS.py
- COUPLED_MODELS.py
- MODELS.py
- Simulation Engine
- SIMULATORS.py
- CO_ORDINATORS.py
- ROOT_CO_ORDINATORS.py
- Communication
- MESSAGE.py
- PORT.py
- COUPLING.py
- Support Components
- ENTITIES.py
- CONTENT.py
- util.py

B. Example Projects Structure:
- Configuration (config.py)
- Model Base (mbase/)
- Coupling Base (coupbase/)
- Test Base (tbase/)
- Integration with External Systems (kafka_producer.py)

**┌─────────────────────────────────────┐**
- Application Layer         │
- (FukushimaNuclearPipe, PipeLeaking)│
- ┤
- DEVS Framework Layer        │
- ┤
- Infrastructure Layer        │
- ┘

**┌─────────────┐    ┌─────────────┐    ┌─────────────┐**
- Models    │ ─> │ Simulation  │ ─> │   Output    │
- Hierarchy  │    │   Engine    │    │  Handlers   │
- ┘    └─────────────┘    └─────────────┘

##### Key Architectural Patterns to Highlight

**┌─────────────────────────────────────────────────┐**
- DEVS Hierarchy                  │
- ┬─────────────────┬────────────────┤
- Atomic     │    Coupled      │  Root          │
- Models     │    Models       │  Coordinator   │
- ┬───┴────────┬────────┴────────┬───────┘

- v            v                 v
**┌─────────────────────────────────────────────────┐**
- Simulation Engine                  │
- (Processors, Coordinators, Simulators)         │
- ┘

##### Implementation Details

- Message passing mechanisms
- Model state transitions
- External system interfaces (Kafka)
- Test framework integration
- Configuration management

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef framework fill:#b3d1ff,stroke:#333
    classDef models fill:#90EE90,stroke:#333
    classDef external fill:#FFE5B4,stroke:#333
    classDef support fill:#E6E6E6,stroke:#333
    classDef testing fill:#FFB6C1,stroke:#333
    classDef docs fill:#DDA0DD,stroke:#333

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        PipeLeakSystem["Pipe Leak Monitoring System"]
        FukushimaSim["Fukushima Nuclear Pipe Sim"]
    end

    %% DEVS Framework Layer
    subgraph CoreLayer["DEVS Framework Layer"]
        %% Model Components
        subgraph Models["Model Components"]
            AtomicModels["Atomic Models"]:::framework
            CoupledModels["Coupled Models"]:::framework
            BaseModels["Base Models"]:::framework
        end

        %% Simulation Engine
        subgraph SimEngine["Simulation Engine"]
            Simulators["Simulators"]:::framework
            Coordinators["Coordinators"]:::framework
            RootCoord["Root Coordinator"]:::framework
            Processors["Processors"]:::framework
        end

        %% Communication
        subgraph Comm["Communication Components"]
            Message["Message Handler"]:::framework
            Port["Port Manager"]:::framework
            Coupling["Coupling Manager"]:::framework
        end

        %% Support
        subgraph Support["Support Components"]
            Entities["Entities"]:::support
            Content["Content"]:::support
            Util["Utilities"]:::support
        end
    end

    %% Infrastructure Layer
    subgraph InfraLayer["Infrastructure Layer"]
        Config["Configuration"]:::support
        KafkaProducer["Kafka Producer"]:::external
        TestFramework["Test Framework"]:::testing
        Documentation["Documentation"]:::docs
    end

    %% Relationships
    AtomicModels --> Simulators
    CoupledModels --> Coordinators
    BaseModels --> RootCoord
    Simulators --> Message
    Coordinators --> Message
    RootCoord --> Message
    Message --> Port
    Port --> Coupling
    PipeLeakSystem --> AtomicModels
    PipeLeakSystem --> CoupledModels
    FukushimaSim --> AtomicModels
    FukushimaSim --> CoupledModels
    KafkaProducer --> Message
    TestFramework --> SimEngine

    %% Click Events
    click AtomicModels "https://github.com/sumannam/DEVS-Python/blob/master/src/ATOMIC_MODELS.py"
    click CoupledModels "https://github.com/sumannam/DEVS-Python/blob/master/src/COUPLED_MODELS.py"
    click BaseModels "https://github.com/sumannam/DEVS-Python/blob/master/src/MODELS.py"
    click Simulators "https://github.com/sumannam/DEVS-Python/blob/master/src/SIMULATORS.py"
    click Coordinators "https://github.com/sumannam/DEVS-Python/blob/master/src/CO_ORDINATORS.py"
    click RootCoord "https://github.com/sumannam/DEVS-Python/blob/master/src/ROOT_CO_ORDINATORS.py"
    click Processors "https://github.com/sumannam/DEVS-Python/blob/master/src/PROCESSORS.py"
    click Message "https://github.com/sumannam/DEVS-Python/blob/master/src/MESSAGE.py"
    click Port "https://github.com/sumannam/DEVS-Python/blob/master/src/PORT.py"
    click Coupling "https://github.com/sumannam/DEVS-Python/blob/master/src/COUPLING.py"
    click Entities "https://github.com/sumannam/DEVS-Python/blob/master/src/ENTITIES.py"
    click Content "https://github.com/sumannam/DEVS-Python/blob/master/src/CONTENT.py"
    click Util "https://github.com/sumannam/DEVS-Python/blob/master/src/util.py"
    click Config "https://github.com/sumannam/DEVS-Python/blob/master/projects/PipeLeakMonitoringSystem/config.py"
    click KafkaProducer "https://github.com/sumannam/DEVS-Python/blob/master/projects/PipeLeakMonitoringSystem/kafka_producer.py"
    click TestFramework "https://github.com/sumannam/DEVS-Python/tree/master/test/engine"
    click Documentation "https://github.com/sumannam/DEVS-Python/blob/master/doc/DEVS.md"

    %% Legend
    subgraph Legend["Legend"]
        L1["Framework Components"]:::framework
        L2["Model Elements"]:::models
        L3["External Interfaces"]:::external
        L4["Support Utilities"]:::support
        L5["Testing Components"]:::testing
        L6["Documentation"]:::docs
    end
```
