# josejimenezluna/delfta architecture

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

- Interactive diagram: https://gitdiagram.com/josejimenezluna/delfta
- Repository: https://github.com/josejimenezluna/delfta

## Overview

#### Purpose and public entry points
DelFTa is a Python toolbox for predicting DFT-level quantum properties of drug-like molecules using 3D message-passing neural networks. It supports direct prediction and Δ-learning correction over a GFN2-xTB baseline. Primary user APIs are `DelftaCalculator` in `delfta/calculator.py` and the model-asset bootstrap module `delfta/download.py`. Package exports begin at `delfta/__init__.py`.

#### Molecular input and validation boundary
Molecules enter as Pybel/OpenBabel objects, allowing common molecular file formats and SMILES-derived structures. Input suitability and molecular checks are separated from inference in `delfta/molchecks.py`; general molecular/data transformations reside in `delfta/utils.py`. This boundary protects model execution from unsupported or malformed chemical representations.

#### Calculator orchestration
`delfta/calculator.py` is the main control plane. `DelftaCalculator` selects requested property models and learning mode, coordinates molecular preprocessing, optionally obtains the semiempirical baseline, invokes neural inference, and assembles predictions. This is the principal integration point for consumers and the natural place for batching or API-level behavior changes.

#### Neural prediction subsystem
`delfta/net.py` defines the 3D message-passing network architecture used for quantum-property inference. `delfta/net_utils.py` provides model-oriented data preparation and inference support. Model outputs cover molecular properties such as formation/orbital energies and dipoles, plus atom- or bond-level outputs such as Mulliken charges and Wiberg bond orders. The learned-model boundary is distinct from chemistry-tool execution and asset download.

#### Δ-learning baseline execution
`delfta/xtb.py` integrates the external GFN2-xTB calculation required by Δ-learning. In this path, the system obtains xTB baseline values, then combines them with neural corrections to approximate the DFT reference level. Direct-learning bypasses this dependency and uses neural predictions alone. xTB invocation is therefore a runtime/process boundary with different failure and deployment requirements than direct inference.

#### Model distribution and local assets
`delfta/download.py` fetches required trained model files before normal use. The repository intentionally does not carry these assets in its source tree, making download/bootstrap a required operational stage. Network access is needed for initial asset acquisition; subsequently inference depends on locally available downloaded weights.

#### Runtime and delivery
The supported runtime is Python 3.11–3.12 on Linux, distributed through Conda and a CUDA-capable Docker image. Core external dependencies include OpenBabel/Pybel for molecular handling and xTB for Δ-learning. Packaging and container deployment are defined by `setup.py`, `conda-recipe/meta.yaml`, and `Dockerfile`; CI validates builds through `.github/workflows/build.yml`.

Main entry points: [`delfta/calculator.py`](https://github.com/josejimenezluna/delfta/blob/master/delfta/calculator.py) (DelftaCalculator), [`delfta/xtb.py`](https://github.com/josejimenezluna/delfta/blob/master/delfta/xtb.py) (GFN2-xTB execution), [`delfta/net.py`](https://github.com/josejimenezluna/delfta/blob/master/delfta/net.py) (3D message-passing network), [`delfta/__init__.py`](https://github.com/josejimenezluna/delfta/blob/master/delfta/__init__.py) (Package exports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_package["Package exports<br/>Python package<br/>[__init__.py]"]
  node_calculator["DelftaCalculator<br/>orchestrator<br/>[calculator.py]"]
  node_download["Model bootstrap<br/>asset downloader<br/>[download.py]"]
end

subgraph group_chemistry["Molecular Processing"]
  node_input(("Pybel/OpenBabel molecules<br/>molecular input"))
  node_checks["Molecule validation<br/>validation boundary<br/>[molchecks.py]"]
  node_utils["Molecular transforms<br/>data utilities<br/>[utils.py]"]
end

subgraph group_ml["Neural Inference"]
  node_net_utils["Inference preparation<br/>model utilities<br/>[net_utils.py]"]
  node_network["3D message-passing network<br/>neural model<br/>[net.py]"]
  node_weights[("Downloaded model weights<br/>local assets")]
end

subgraph group_runtime["External Runtime"]
  node_xtb{{"GFN2-xTB execution<br/>external process adapter<br/>[xtb.py]"}}
  node_openbabel{{"OpenBabel/Pybel<br/>chemistry runtime"}}
  node_xtb_runtime{{"xTB runtime<br/>external executable"}}
end

subgraph group_delivery["Distribution"]
  node_setup["Python package<br/>packaging<br/>[setup.py]"]
  node_conda["Conda distribution<br/>package recipe<br/>[meta.yaml]"]
  node_docker["CUDA Docker image<br/>container delivery"]
  node_ci["Build CI<br/>automation<br/>[build.yml]"]
end

node_package -->|"exports"| node_calculator
node_package -->|"exports"| node_download
node_input -->|"validate"| node_checks
node_checks -->|"accepted molecules"| node_utils
node_utils -->|"prepared molecules"| node_calculator
node_calculator -->|"coordinates inference"| node_net_utils
node_net_utils -->|"model inputs"| node_network
node_weights -->|"loaded weights"| node_network
node_download -->|"fetches"| node_weights
node_calculator -.->|"Δ-learning only"| node_xtb
node_xtb -->|"invokes"| node_xtb_runtime
node_xtb -->|"baseline values"| node_calculator
node_network -->|"direct predictions or corrections"| node_calculator
node_openbabel -->|"provides molecule objects"| node_input
node_setup -.->|"package metadata"| node_conda
node_docker -->|"installs package"| node_setup
node_ci -->|"validates builds"| node_conda
node_ci -->|"validates image"| node_docker

click node_package "https://github.com/josejimenezluna/delfta/blob/master/delfta/__init__.py"
click node_calculator "https://github.com/josejimenezluna/delfta/blob/master/delfta/calculator.py"
click node_download "https://github.com/josejimenezluna/delfta/blob/master/delfta/download.py"
click node_checks "https://github.com/josejimenezluna/delfta/blob/master/delfta/molchecks.py"
click node_utils "https://github.com/josejimenezluna/delfta/blob/master/delfta/utils.py"
click node_net_utils "https://github.com/josejimenezluna/delfta/blob/master/delfta/net_utils.py"
click node_network "https://github.com/josejimenezluna/delfta/blob/master/delfta/net.py"
click node_xtb "https://github.com/josejimenezluna/delfta/blob/master/delfta/xtb.py"
click node_setup "https://github.com/josejimenezluna/delfta/blob/master/setup.py"
click node_conda "https://github.com/josejimenezluna/delfta/blob/master/conda-recipe/meta.yaml"
click node_docker "https://github.com/josejimenezluna/delfta/blob/master/Dockerfile"
click node_ci "https://github.com/josejimenezluna/delfta/blob/master/.github/workflows/build.yml"

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_package,node_calculator,node_download toneBlue
class node_input,node_checks,node_utils toneAmber
class node_net_utils,node_network,node_weights toneMint
class node_xtb,node_openbabel,node_xtb_runtime toneRose
class node_setup,node_conda,node_docker,node_ci toneIndigo
```

## Components

### Public API

- [Package exports](https://github.com/josejimenezluna/delfta/blob/master/delfta/__init__.py): Python package · `delfta/__init__.py`
- [DelftaCalculator](https://github.com/josejimenezluna/delfta/blob/master/delfta/calculator.py): orchestrator · Selects properties and direct or Δ-learning mode. · `delfta/calculator.py`
- [Model bootstrap](https://github.com/josejimenezluna/delfta/blob/master/delfta/download.py): asset downloader · Fetches trained weights for local use. · `delfta/download.py`

### Molecular Processing

- **Pybel/OpenBabel molecules**: molecular input · Molecules originate from files or SMILES-derived structures.
- [Molecule validation](https://github.com/josejimenezluna/delfta/blob/master/delfta/molchecks.py): validation boundary · `delfta/molchecks.py`
- [Molecular transforms](https://github.com/josejimenezluna/delfta/blob/master/delfta/utils.py): data utilities · `delfta/utils.py`

### Neural Inference

- [Inference preparation](https://github.com/josejimenezluna/delfta/blob/master/delfta/net_utils.py): model utilities · `delfta/net_utils.py`
- [3D message-passing network](https://github.com/josejimenezluna/delfta/blob/master/delfta/net.py): neural model · Predicts molecular, atomic, and bond properties. · `delfta/net.py`
- **Downloaded model weights**: local assets · Required trained assets are absent from source control.

### External Runtime

- [GFN2-xTB execution](https://github.com/josejimenezluna/delfta/blob/master/delfta/xtb.py): external process adapter · Supplies semiempirical baselines for Δ-learning. · `delfta/xtb.py`
- **OpenBabel/Pybel**: chemistry runtime
- **xTB runtime**: external executable

### Distribution

- [Python package](https://github.com/josejimenezluna/delfta/blob/master/setup.py): packaging · `setup.py`
- [Conda distribution](https://github.com/josejimenezluna/delfta/blob/master/conda-recipe/meta.yaml): package recipe · Supports Python 3.11–3.12 on Linux. · `conda-recipe/meta.yaml`
- [CUDA Docker image](https://github.com/josejimenezluna/delfta/blob/master/Dockerfile): container delivery · `Dockerfile`
- [Build CI](https://github.com/josejimenezluna/delfta/blob/master/.github/workflows/build.yml): automation · `.github/workflows/build.yml`

## Connections

- Package exports → DelftaCalculator: exports
- Package exports → Model bootstrap: exports
- Pybel/OpenBabel molecules → Molecule validation: validate
- Molecule validation → Molecular transforms: accepted molecules
- Molecular transforms → DelftaCalculator: prepared molecules
- DelftaCalculator → Inference preparation: coordinates inference
- Inference preparation → 3D message-passing network: model inputs
- Downloaded model weights → 3D message-passing network: loaded weights
- Model bootstrap → Downloaded model weights: fetches
- DelftaCalculator → GFN2-xTB execution: Δ-learning only
- GFN2-xTB execution → xTB runtime: invokes
- GFN2-xTB execution → DelftaCalculator: baseline values
- 3D message-passing network → DelftaCalculator: direct predictions or corrections
- OpenBabel/Pybel → Pybel/OpenBabel molecules: provides molecule objects
- Python package → Conda distribution: package metadata
- CUDA Docker image → Python package: installs package
- Build CI → Conda distribution: validates builds
- Build CI → CUDA Docker image: validates image
