# fpom/pyddd architecture

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

- Interactive diagram: https://gitdiagram.com/fpom/pyddd
- Repository: https://github.com/fpom/pyddd

## Overview

##### Main Components

a. User Layer:
- Python Application Layer (where end users interact with the library)
- Two main classes: `ddd` and `sdd`

b. Binding Layer:
- Cython Interface (represented by ddd.pyx and ddd.pxd files)
- C++ Wrapper (dddwrap.h)

c. Core Library Layer:
- libDDD (external C++ library)

##### Component Relationships

**[Python Layer] → [Binding Layer] → [C++ Layer]**

Use the following specific elements:

- Rectangles: Python classes (ddd, sdd)
- Hexagons: Cython components (ddd.pyx, ddd.pxd)
- Diamonds: C++ components (dddwrap.h)
- Double rectangles: External library (libDDD)

##### Important Elements to Highlight

a. Build System:
- Pyproject.toml and setup.py connection to the build process
- G++ compiler requirement (v.11)

b. Runtime Dependencies:
- LibDDD.so dynamic library requirement
- LD_LIBRARY_PATH configuration

##### Additional Details

A notes section showing:
- Compiler requirements (G++ v.11)
- System requirements (Python 3, Cython)
- Installation paths for libDDD
- Testing components (test/test.py)

##### Key Aspects to Emphasize

a. Memory Management:
- How Python objects are wrapped/unwrapped to C++ objects
- Where garbage collection interfaces occur

b. Type System:
- How Python types map to C++ types through Cython
- Special type handling

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef python fill:#3572A5,color:white
    classDef cython fill:#27ae60,color:white
    classDef cpp fill:#f39c12,color:white
    classDef external fill:#95a5a6,color:white
    classDef config fill:#8e44ad,color:white
    classDef test fill:#2c3e50,color:white

    %% User/Python Layer
    subgraph PythonLayer["Python Application Layer"]
        PyApp[Python Application]:::python
        DDD[DDD Class]:::python
        SDD[SDD Class]:::python
    end

    %% Binding Layer
    subgraph BindingLayer["Binding Layer"]
        PYX[ddd.pyx]:::cython
        PXD[ddd.pxd]:::cython
        WRAP[dddwrap.h]:::cpp
    end

    %% Core Library Layer
    subgraph CoreLayer["C++ Layer"]
        LibDDD[libDDD Library]:::external
    end

    %% Build and Config
    subgraph BuildSystem["Build Configuration"]
        PyProject[pyproject.toml]:::config
        Setup[setup.py]:::config
    end

    %% Test Components
    subgraph TestLayer["Testing"]
        Test[test.py]:::test
    end

    %% Relationships
    PyApp --> DDD & SDD
    DDD & SDD --> PYX
    PYX --> PXD
    PXD --> WRAP
    WRAP --> LibDDD
    PyProject --> Setup
    Setup --> PYX
    Test --> DDD & SDD

    %% Click events
    click PYX "https://github.com/fpom/pyddd/blob/master/ddd.pyx"
    click PXD "https://github.com/fpom/pyddd/blob/master/ddd.pxd"
    click WRAP "https://github.com/fpom/pyddd/blob/master/dddwrap.h"
    click LibDDD "https://github.com/fpom/pyddd/blob/master/libDDD.tar.gz"
    click PyProject "https://github.com/fpom/pyddd/blob/master/pyproject.toml"
    click Setup "https://github.com/fpom/pyddd/blob/master/setup.py"
    click Test "https://github.com/fpom/pyddd/blob/master/test/test.py"

    %% Legend
    subgraph Legend
        L1[Python Components]:::python
        L2[Cython Interface]:::cython
        L3[C++ Components]:::cpp
        L4[External Libraries]:::external
        L5[Configuration]:::config
        L6[Tests]:::test
    end

    %% Notes
    subgraph Requirements
        note1["Requires G++ v.11"]
        note2["Python 3 & Cython"]
        note3["Not compatible with clang"]
    end
```
