# thiebes/dice architecture

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

- Interactive diagram: https://gitdiagram.com/thiebes/dice
- Repository: https://github.com/thiebes/dice

## Overview

##### And Label Primary Components
- Simulation Engine (detailed breakdown)
- Parameter Input Module
- Output & Plotting Module
- Web Application Wrapper
- Entry Point / Utility Scripts

- Break out several sub-components:
- Profile Generation:
▸ Generates a time-series of Gaussian profiles with decay and diffusion. (Core computations in dice.py)
- Noise Addition:
▸ Adds uniform white noise to each profile simulating experimental uncertainty.
- Fitting Module:
▸ Performs Gaussian functional fitting on the noisy profiles.
▸ Computes Mean Squared Displacement (MSD) at each time point.
▸ Executes linear (weighted/unweighted) fit to extract diffusion coefficients.
- Analysis Module:
▸ Compares simulation-derived diffusion estimates to the nominal input.
▸ Evaluates precision by checking what fraction of the estimates are within defined proximity thresholds.
- Plotting and Visualization:
▸ Generates histogram plots and summary visualizations using matplotlib, seaborn, etc.
- Iteration & Parallel Processing Controller:
▸ Orchestrates multiple simulation runs based on the specified number of iterations.
▸ Manages parallel processing if enabled.
[Parameter Values] → [Gaussian Profile Generation] → [Noise Addition] → [Fit Computation] → [Analysis] → [Plotting]

- Represents files like parameters.txt and example_profile.csv.
- Reads and validates experimental/simulation parameters.
- Feeds configuration details (initial guess, simulation iterations, plotting options, spatial and temporal axis definitions) directly into the Simulation Engine.

- Handles generation of text summary, CSV results, and image plots.

- Groups all the web-related modules contained in the "webapp" folder (e.g., dice_web_app.py, dice.py under webapp, HTML templates, static assets).
- Acts as a front-end interface that calls the same Simulation Engine in the backend.

- Contains scripts like run_dice.py.
- Serves as the command-line interface to kick off the simulation process.

- Within the Simulation Engine, illustrate the internal flow, from data generation to analysis and plotting.
- Simulation Engine to the Output & Plotting Module, showing that processed simulation data is sent out as results.
- Similarly, show that the command-line Entry Point feeds into the same Simulation Engine.

## Diagram (Mermaid)

```mermaid
graph TD
    PI["Parameter Input Module"]:::inputModule
    subgraph "Simulation Engine (Detailed)"
        SECore["Simulation Engine Core"]:::simEngine
        PG["Gaussian Profile Generation"]:::simEngine
        NA["Noise Addition"]:::simEngine
        FM["Fitting Module"]:::simEngine
        AM["Analysis Module"]:::simEngine
        PV["Plotting & Visualization"]:::simEngine
        IPC["Iteration & Parallel Processing Controller"]:::simEngine
    end
    OP["Output & Plotting Module"]:::outputModule
    WA["Web Application (UI and API)"]:::webApp
    EP["Entry Point / Utility Scripts"]:::entryPoint

    PI -->|"parameters→"| SECore
    SECore -->|"generates_profile"| PG
    PG -->|"adds_noise"| NA
    NA -->|"computes_fit"| FM
    FM -->|"performs_analysis"| AM
    AM -->|"generates_plots"| PV
    SECore -.->|"orchestrates"| IPC
    PV -->|"simulationresults→"| OP

    WA <-->|"api_calls"| SECore
    EP -->|"initializes"| SECore

    classDef simEngine fill:#C6E5FF,stroke:#1f78b4,stroke-width:2px;
    classDef inputModule fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef outputModule fill:#ABEBC6,stroke:#27AE60,stroke-width:2px;
    classDef webApp fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef entryPoint fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;

    click SECore "https://github.com/thiebes/dice/blob/main/dice.py"
    click PI "https://github.com/thiebes/dice/blob/main/parameters.txt"
    click PI "https://github.com/thiebes/dice/blob/main/example_profile.csv"
    click WA "https://github.com/thiebes/dice/blob/main/webapp/dice_web_app.py"
    click WA "https://github.com/thiebes/dice/blob/main/webapp/dice.py"
    click EP "https://github.com/thiebes/dice/blob/main/run_dice.py"
```
