# lepy/phuzzy architecture

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

- Interactive diagram: https://gitdiagram.com/lepy/phuzzy
- Repository: https://github.com/lepy/phuzzy

## Overview

##### Project type and purpose
- phuzzy is an open-source Python library for representing fuzzy numbers and fuzzy data, performing operations (add, subtract, multiply, divide, exponentiate), analysis (e.g. ALO), design-of-experiment approximations, and plotting.
- It exposes a core API (Triangle, Trapezoid, TruncNorm, Superellipse, etc.), plug-in contributions (pyDOE, SHGO, TGO), and plotting helpers.

##### File structure
- Top-level:
- phuzzy/            ← main package
- docs/ & doc/       ← Sphinx documentation & demo scripts
- tests/             ← pytest suite
- setup.py, requirements.txt, CI configs (Travis, tox, Coveralls)
- phuzzy/ subpackages:
- analysis/          ← analysis algorithms (e.g. ALO)
- approx/            ← DOE and modeling abstractions
- contrib/           ← external-algorithm bindings (pyDOE, SHGO, TGO)
- data/              ← data handling and simple plotting
- mpl/               ← matplotlib wrappers for plotting
- expression.py      ← CLI/expression parsing

##### README for additional insights
- Demonstrates core classes, API calls, plotting output, addition/subtraction/etc.
- No external server or database—pure in-process library.
- Dependencies: numpy, scipy, matplotlib, pyDOE-family, sphinx, pytest.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    subgraph "User Interface"
        direction TB
        User["User Scripts"]:::cli
    end

    subgraph "Entry Point"
        direction TB
        Expression["Expression Parser"]:::cli
    end

    subgraph "phuzzy Core" 
        direction TB
        CoreShapes["Shapes Module"]:::core
        Superellipse["Superellipse Shape"]:::core
        Truncnorm["TruncNorm Shape"]:::core
        Analysis["Analysis Module"]:::core
        ALO["ALO Algorithm"]:::core
        Approx["Approx/DOE Module"]:::core
        DoeUtils["DOE Utilities"]:::core
        Modeling["Modeling Interfaces"]:::core
        Results["Results (DataFrame)"]:::core
    end

    subgraph "Contrib Plugins"
        direction TB
        ContribPyDOE["pyDOE Family"]:::plugin
        ContribSHGO["SHGO Plugin"]:::plugin
        SHGOCore["Core SHGO Wrapper"]:::plugin
        SHGOsobol["SHGO sobol Utils"]:::plugin
        ContribTGO["TGO Plugin"]:::plugin
        TGOCore["Core TGO Wrapper"]:::plugin
        TGOData["TGO Data Helpers"]:::plugin
    end

    subgraph "Data & Plotting"
        direction TB
        DataHelpers["Data & Plot Helpers"]:::core
        MPL["Matplotlib Integration"]:::core
        PlotOutput["Plot Files"]:::core
    end

    subgraph "External Libraries"
        direction TB
        Numpy["NumPy"]:::ext
        SciPy["SciPy"]:::ext
        Matplotlib["Matplotlib"]:::ext
        PyDOEExt["pyDOE Family"]:::ext
    end

    subgraph "Documentation & CI"
        direction TB
        Docs["Documentation (Sphinx)"]:::side
        Tests["Test Suite (pytest)"]:::side
        CI["CI/CD Config"]:::side
        Travis["Travis CI"]:::side
        Tox["Tox"]:::side
        Coveralls["Coveralls"]:::side
        PackageMeta["Package Metadata"]:::side
    end

    %% Connections
    User --> Expression
    Expression --> CoreShapes
    Expression --> Analysis
    Expression --> Approx

    CoreShapes --> Analysis
    CoreShapes --> Approx
    Analysis --> ALO
    Approx --> DoeUtils
    Approx --> Modeling

    Analysis --> Results
    Approx --> Results

    Results --> DataHelpers
    DataHelpers --> MPL
    MPL --> PlotOutput

    Approx --- ContribPyDOE
    Approx --- ContribSHGO
    Approx --- ContribTGO

    ContribSHGO --> SHGOCore
    ContribSHGO --> SHGOsobol
    ContribTGO --> TGOCore
    ContribTGO --> TGOData

    Numpy --> CoreShapes
    SciPy --> CoreShapes
    Numpy --> Analysis
    SciPy --> Analysis
    Numpy --> Approx
    SciPy --> Approx
    Matplotlib --> DataHelpers
    Matplotlib --> MPL
    PyDOEExt --> ContribPyDOE

    CoreShapes --> Tests
    Analysis --> Tests
    Approx --> Tests
    ContribPyDOE --> Tests
    ContribSHGO --> Tests
    ContribTGO --> Tests
    DataHelpers --> Tests
    MPL --> Tests

    CoreShapes --> Docs
    Analysis --> Docs
    Approx --> Docs
    ContribPyDOE --> Docs
    ContribSHGO --> Docs
    ContribTGO --> Docs
    DataHelpers --> Docs
    MPL --> Docs

    Tests --> CI
    Docs --> CI

    CI --> Travis
    CI --> Tox
    CI --> Coveralls
    CI --> PackageMeta

    %% Click Events
    click Expression "https://github.com/lepy/phuzzy/blob/master/phuzzy/expression.py"
    click CoreShapes "https://github.com/lepy/phuzzy/tree/master/phuzzy/shapes/"
    click Superellipse "https://github.com/lepy/phuzzy/blob/master/phuzzy/shapes/superellipse.py"
    click Truncnorm "https://github.com/lepy/phuzzy/blob/master/phuzzy/shapes/truncnorm.py"
    click Analysis "https://github.com/lepy/phuzzy/tree/master/phuzzy/analysis/"
    click ALO "https://github.com/lepy/phuzzy/blob/master/phuzzy/analysis/alo.py"
    click Approx "https://github.com/lepy/phuzzy/tree/master/phuzzy/approx/"
    click DoeUtils "https://github.com/lepy/phuzzy/blob/master/phuzzy/approx/doe.py"
    click Modeling "https://github.com/lepy/phuzzy/blob/master/phuzzy/approx/model.py"
    click ContribPyDOE "https://github.com/lepy/phuzzy/tree/master/phuzzy/contrib/pydoe/"
    click ContribSHGO "https://github.com/lepy/phuzzy/tree/master/phuzzy/contrib/shgo/"
    click SHGOCore "https://github.com/lepy/phuzzy/blob/master/phuzzy/contrib/shgo/_shgo.py"
    click SHGOsobol "https://github.com/lepy/phuzzy/tree/master/phuzzy/contrib/shgo/shgo_m/"
    click ContribTGO "https://github.com/lepy/phuzzy/tree/master/phuzzy/contrib/tgo/"
    click TGOCore "https://github.com/lepy/phuzzy/blob/master/phuzzy/contrib/tgo/_tgo.py"
    click TGOData "https://github.com/lepy/phuzzy/blob/master/phuzzy/contrib/tgo/data.py"
    click DataHelpers "https://github.com/lepy/phuzzy/blob/master/phuzzy/data/plots.py"
    click MPL "https://github.com/lepy/phuzzy/blob/master/phuzzy/mpl/plots.py"
    click Tests "https://github.com/lepy/phuzzy/tree/master/tests/"
    click Docs "https://github.com/lepy/phuzzy/tree/master/docs/"
    click Travis "https://github.com/lepy/phuzzy/blob/master/.travis.yml"
    click Tox "https://github.com/lepy/phuzzy/blob/master/tox.ini"
    click Coveralls "https://github.com/lepy/phuzzy/blob/master/.coveralls.yml"
    click PackageMeta "https://github.com/lepy/phuzzy/blob/master/setup.py"

    %% Styles
    classDef core fill:#aedeff,stroke:#000,stroke-width:1px
    classDef plugin fill:#c3f0c3,stroke:#000,stroke-width:1px
    classDef ext fill:#ffd699,stroke:#000,stroke-width:1px
    classDef cli fill:#e5ccff,stroke:#000,stroke-width:1px
    classDef side fill:#f0f0f0,stroke:#000,stroke-width:1px
```
