# soenmezmehmet/nibelungenbrueckejupyternfdi architecture

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

- Interactive diagram: https://gitdiagram.com/soenmezmehmet/nibelungenbrueckejupyternfdi
- Repository: https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi

## Overview

##### Project type and purpose
- This is an open-source Python demonstrator for building a stochastic Digital Twin (DT) of a bridge. It provides a repeatable workflow—from geometry/mesh creation through synthetic data generation, preprocessing, Bayesian inference, posterior-predictive querying, and results postprocessing—wrapped as a set of doit tasks (a data-pipeline/orchestration tool).

##### File structure
- Top-level:
- setup.py, pyproject.toml, environment files → package & environment management
- nibelungenbruecke/ → Python package containing core modules
- Binder/, tests/, use_cases/ → CI recipes, unit tests, sample workflows
- dodo.py in each use_case → doit task runner
- Inside nibelungenbruecke/:
- dt_api/ → HTTP API layer (access.py, main.py, schemas.py, test.py)
- scripts/ → modular pipeline stages
– data_generation/ (synthetic sensor data)
– digital_twin_orchestrator/ (DT orchestration, caching, base models)
– modelling/ (geometry, mesh creation)
– inference/ (wrappers for probeye forward/inverse solves)
– preprocessing/, postprocessing/
– utilities/ (boundary conditions, sensors, file I/O)
- tasks/ → high-level doit tasks grouping pipeline scripts
- use_cases/… → preconfigured inputs (JSON, h5), outputs, logs, figures for two demo scenarios

##### README for additional insights
- The README describes the workflow stages, dependencies (fenics-dolfinx, gmsh, h5py, probeye, doit), the doit-based orchestration, input/output formats, and extension points via base classes. It also describes integration points (DT database, HTTP API).

1. CLI / doit orchestrator
2. Task modules (grouped by pipeline stage):
- Geometry & mesh creation
- Synthetic data generation
- Data preprocessing
- Bayesian inference
- Posterior predictive querying
- Results postprocessing
- Document generation
3. Core package modules (nibelungenbruecke/scripts & utilities)
4. Digital Twin Orchestrator (in-memory cache, update triggers)
5. HTTP API (nibelungenbruecke/dt_api)
6. External libs & services: FEniCS/DolfinX, gmsh, probeye, h5py, paraview
7. Input data store (JSON settings, sensor metadata, h5 files)
8. Output data store (results folder: figures, logs, paraview files, posterior data)
9. Optional external database (for a larger DT integration)

- CLI/doit → invokes Task modules in sequence
- Task modules → call core scripts and utilities
- Scripts → call external libs (e.g., mesh creation calls gmsh; inference calls probeye)
- Synthetic data → produces h5 → Preprocessing → formats data → Inference → outputs parameter distributions
- Posterior predictive → uses distributions → outputs new sensor data
- Postprocessing → generates figures/logs → Output store
- HTTP API ↔ Orchestrator (exposes endpoints to trigger runs, fetch state)
- Orchestrator → maintains cache of DT state, integrates with Task modules
- Database (external) ↔ HTTP API (data retrieval/upload)

c. Architectural patterns & principles
- Modular pipeline (doit tasks as DAG)
- Plugin/Factory patterns (generator_model_factory, forward_model_factory)
- Base classes & inheritance for extensibility (GeneratorModel, ForwardModel)
- Separation of concerns: scripts vs. utilities vs. API vs. orchestrator
- FAIR principles: clearly defined inputs/outputs, metadata, reproducibility

d. Key technologies, frameworks, libraries
- doit (workflow orchestration)
- fenics-dolfinx, gmsh (FEM geometry/mesh)
- h5py (data serialization)
- probeye (Bayesian inference)
- pytest (tests)
- FastAPI or similar? (if API.HTTP inside dt_api indicates an HTTP server)
- JSON for settings & sensor metadata

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Orchestrator CLI
    CLI["CLI / doit Orchestrator"]:::orchestrator
    click CLI "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/blob/thermal_orchestrator/use_cases/nibelungenbruecke_demonstrator_line_test/dodo.py"

    %% Pipeline Stages
    subgraph "Pipeline Stages"
        direction TB
        Geometry["Geometry & Mesh Creation"]:::pipeline
        SyntheticData["Synthetic Data Generation"]:::pipeline
        Preprocessing["Data Preprocessing"]:::pipeline
        Inference["Bayesian Inference Module"]:::pipeline
        PosteriorPredictive["Posterior Predictive Querying"]:::pipeline
        Postprocessing["Results Postprocessing"]:::pipeline
        DocumentGen["Document Generation"]:::pipeline
    end

    %% Core Task Modules
    Tasks["Task Modules"]:::pipeline
    click Tasks "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/tasks/"

    %% Core Utilities
    subgraph "Core Utilities" 
        direction TB
        Utilities["Utilities"]:::extensible
        click Utilities "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/scripts/utilities/"
    end

    %% Digital Twin Orchestrator
    DTO["Digital Twin Orchestrator"]:::api
    click DTO "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/scripts/digital_twin_orchestrator/"

    %% HTTP API
    API["HTTP API Layer"]:::api
    click API "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/dt_api/"

    %% External Dependencies
    subgraph "External Dependencies"
        direction TB
        Fenics["FEniCS/DolfinX"]:::external
        Gmsh["gmsh"]:::external
        Probeye["probeye"]:::external
        H5py["h5py"]:::external
        ParaView["paraview"]:::external
    end

    %% Data Stores
    Inputs["Input Data Store"]:::storage
    click Inputs "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/use_cases/nibelungenbruecke_demonstrator_line_test/input/"
    Outputs["Output Data Store"]:::storage
    click Outputs "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/use_cases/nibelungenbruecke_demonstrator_line_test/output/"
    Database["External DT Database"]:::storage

    %% Connections
    CLI -->|invokes tasks| Tasks
    Tasks -->|runs| Geometry
    Tasks -->|runs| SyntheticData
    Tasks -->|runs| Preprocessing
    Tasks -->|runs| Inference
    Tasks -->|runs| PosteriorPredictive
    Tasks -->|runs| Postprocessing
    Tasks -->|runs| DocumentGen

    Geometry -->|uses| Gmsh
    Geometry -->|uses| Fenics

    SyntheticData -->|calls| Utilities
    SyntheticData -->|uses| Probeye
    SyntheticData -->|produces h5 files| Inputs

    Preprocessing -->|reads from| Inputs
    Preprocessing -->|formats data| Inference

    Inference -->|uses| Probeye
    Inference -->|uses| Utilities
    Inference -->|outputs distributions| Outputs

    PosteriorPredictive -->|uses distributions| Outputs
    PosteriorPredictive -->|writes new data| Outputs

    Postprocessing -->|reads from| Outputs
    Postprocessing -->|generates figs/logs| Outputs

    DocumentGen -->|reads results| Outputs

    CLI -->|config via| Inputs

    API -->|exposes endpoints| DTO
    DTO -->|triggers| Tasks
    API -->|reads/writes| Database
    Database <-->|integrates| API

    %% Style Definitions
    classDef pipeline fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef external fill:#E6FFED,stroke:#28A745,color:#28A745
    classDef storage fill:#F0F0F0,stroke:#6A737D,color:#6A737D
    classDef api fill:#F5E6FF,stroke:#6F42C1,color:#6F42C1
    classDef orchestrator fill:#FFF5D0,stroke:#D69E2E,color:#D69E2E
    classDef extensible fill:#FFF0E6,stroke:#D9730D,color:#D9730D

    %% Click Events for specific modules
    click Geometry "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/scripts/modelling/"
    click SyntheticData "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/scripts/data_generation/"
    click Preprocessing "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/scripts/preprocessing/"
    click Inference "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/scripts/inference/"
    click PosteriorPredictive "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/blob/thermal_orchestrator/nibelungenbruecke/scripts/postprocessing/posterior_predictive.py"
    click Postprocessing "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/scripts/postprocessing/"
    click DocumentGen "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/blob/thermal_orchestrator/nibelungenbruecke/tasks/generate_document_tasks.py"
    click DTO "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/scripts/digital_twin_orchestrator/"
    click API "https://github.com/soenmezmehmet/nibelungenbrueckejupyternfdi/tree/thermal_orchestrator/nibelungenbruecke/dt_api/"
```
