# m1nquan/pytodynamic architecture

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

- Interactive diagram: https://gitdiagram.com/m1nquan/pytodynamic
- Repository: https://github.com/m1nquan/pytodynamic

## Overview

PTD Engine turns a Python script into a Windows DLL exposing a C ABI; hosts then initialize the embedded runtime and invoke exported Python callables. PTD Studio offers a graphical build and verification workflow. The README documents the broader compiler and inspection capabilities, while excerpts confirm Studio’s call into the engine and parts of runtime invocation; unsampled internals are represented only where documented.

Main entry points: [`ptd_gui.py`](https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py) (Studio interface), [`ptd.py`](https://github.com/m1nquan/pytodynamic/blob/main/ptd.py) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build engine"]
  node_cli["CLI entry<br/>[ptd.py]"]
  node_sdk["SDK discovery<br/>[ptd.py]"]
  node_envelope["Payload envelope<br/>[ptd.py]"]
  node_native["Native compiler<br/>[ptd.py]"]
end

subgraph group_runtime["DLL runtime"]
  node_abi["C-ABI exports<br/>[ptd.py]"]
  node_runtime_init["Runtime lifecycle<br/>[ptd.py]"]
  node_invoke["Callable invocation<br/>[ptd.py]"]
end

subgraph group_studio["PTD Studio"]
  node_studio_ui["Studio interface<br/>[ptd_gui.py]"]
  node_studio_build["Build workflow<br/>[ptd_gui.py]"]
  node_diagnostics["Environment diagnostics<br/>[ptd_gui.py]"]
  node_inspector["PE / ABI inspector<br/>[ptd_gui.py]"]
  node_verification["Verification matrix<br/>[ptd_gui.py]"]
end

node_developer(("Developer"))
node_toolchain["C++ toolchain"]
node_python["CPython SDK"]

node_developer -->|"runs CLI"| node_cli
node_cli -->|"selects SDK"| node_sdk
node_cli -->|"packages bytecode"| node_envelope
node_cli -->|"builds DLL"| node_native
node_native -->|"uses compiler"| node_toolchain
node_sdk -->|"locates SDK"| node_python
node_developer -->|"uses workstation"| node_studio_ui
node_studio_ui -->|"configures build"| node_studio_build
node_studio_build -->|"calls compile_engine"| node_cli
node_studio_ui -->|"shows diagnostics"| node_diagnostics
node_studio_ui -->|"inspects exports"| node_inspector
node_studio_ui -->|"runs verification"| node_verification
node_abi -->|"exposes lifecycle"| node_runtime_init
node_abi -->|"exposes calls"| node_invoke
node_runtime_init -->|"gates invocation"| node_invoke
node_invoke -->|"loads payload"| node_envelope

click node_cli "https://github.com/m1nquan/pytodynamic/blob/main/ptd.py"
click node_sdk "https://github.com/m1nquan/pytodynamic/blob/main/ptd.py"
click node_envelope "https://github.com/m1nquan/pytodynamic/blob/main/ptd.py"
click node_native "https://github.com/m1nquan/pytodynamic/blob/main/ptd.py"
click node_abi "https://github.com/m1nquan/pytodynamic/blob/main/ptd.py"
click node_runtime_init "https://github.com/m1nquan/pytodynamic/blob/main/ptd.py"
click node_invoke "https://github.com/m1nquan/pytodynamic/blob/main/ptd.py"
click node_studio_ui "https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py"
click node_studio_build "https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py"
click node_diagnostics "https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py"
click node_inspector "https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py"
click node_verification "https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_sdk,node_envelope,node_native toneBlue
class node_abi,node_runtime_init,node_invoke toneAmber
class node_studio_ui,node_studio_build,node_diagnostics,node_inspector,node_verification toneMint
class node_developer,node_toolchain,node_python toneIndigo
```

## Components

### Build engine

- [CLI entry](https://github.com/m1nquan/pytodynamic/blob/main/ptd.py): `ptd.py`
- [SDK discovery](https://github.com/m1nquan/pytodynamic/blob/main/ptd.py): `ptd.py`
- [Payload envelope](https://github.com/m1nquan/pytodynamic/blob/main/ptd.py): `ptd.py`
- [Native compiler](https://github.com/m1nquan/pytodynamic/blob/main/ptd.py): `ptd.py`

### DLL runtime

- [C-ABI exports](https://github.com/m1nquan/pytodynamic/blob/main/ptd.py): `ptd.py`
- [Runtime lifecycle](https://github.com/m1nquan/pytodynamic/blob/main/ptd.py): `ptd.py`
- [Callable invocation](https://github.com/m1nquan/pytodynamic/blob/main/ptd.py): `ptd.py`

### PTD Studio

- [Studio interface](https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py): `ptd_gui.py`
- [Build workflow](https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py): `ptd_gui.py`
- [Environment diagnostics](https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py): `ptd_gui.py`
- [PE / ABI inspector](https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py): `ptd_gui.py`
- [Verification matrix](https://github.com/m1nquan/pytodynamic/blob/main/ptd_gui.py): `ptd_gui.py`

### Other components

- **Developer**
- **C++ toolchain**
- **CPython SDK**

## Connections

- Developer → CLI entry: runs CLI (evidence: `Readme.md`)
- CLI entry → SDK discovery: selects SDK (evidence: `Readme.md`)
- CLI entry → Payload envelope: packages bytecode (evidence: `Readme.md`)
- CLI entry → Native compiler: builds DLL (evidence: `Readme.md`)
- Native compiler → C++ toolchain: uses compiler (evidence: `Readme.md`)
- SDK discovery → CPython SDK: locates SDK (evidence: `Readme.md`)
- Developer → Studio interface: uses workstation (evidence: `Readme.md`)
- Studio interface → Build workflow: configures build (evidence: `Readme.md`)
- Build workflow → CLI entry: calls compile_engine (evidence: `ptd_gui.py`)
- Studio interface → Environment diagnostics: shows diagnostics (evidence: `ptd_gui.py`)
- Studio interface → PE / ABI inspector: inspects exports (evidence: `Readme.md`)
- Studio interface → Verification matrix: runs verification (evidence: `ptd_gui.py`)
- C-ABI exports → Runtime lifecycle: exposes lifecycle (evidence: `Readme.md`)
- C-ABI exports → Callable invocation: exposes calls (evidence: `Readme.md`)
- Runtime lifecycle → Callable invocation: gates invocation (evidence: `Readme.md`)
- Callable invocation → Payload envelope: loads payload (evidence: `ptd.py`)
