# kjaved0/swifttd architecture

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

- Interactive diagram: https://gitdiagram.com/kjaved0/swifttd
- Repository: https://github.com/kjaved0/swifttd

## Overview

SwiftTD is a Python-accessible temporal-difference learning library with dense, sparse-binary, and sparse-valued linear-function-approximation variants. The user supplies features and a reward to `step`; the selected implementation updates its learning state and returns a value prediction. Python exports the native classes through a pybind11 extension. The graph focuses on runtime behavior; implementation details are limited to the shown excerpts, and no external service or persistent store is documented.

Main entry points: [`src/cpp/pybind.cpp`](https://github.com/kjaved0/swifttd/blob/main/src/cpp/pybind.cpp) (Native bindings), [`src/swifttd/__init__.py`](https://github.com/kjaved0/swifttd/blob/main/src/swifttd/__init__.py) (Python package API), [`src/cpp/SwiftTD.cpp`](https://github.com/kjaved0/swifttd/blob/main/src/cpp/SwiftTD.cpp) (Dense SwiftTD), [`src/cpp/SwiftTD.h`](https://github.com/kjaved0/swifttd/blob/main/src/cpp/SwiftTD.h) (C++ declarations)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("Python caller"))
node_package["Python package API<br/>[__init__.py]"]
node_version["Package version<br/>[_version.py]"]
node_bindings["Native bindings<br/>[pybind.cpp]"]
node_interface["C++ declarations<br/>[SwiftTD.h]"]
node_dense["Dense SwiftTD<br/>[SwiftTD.cpp]"]
node_binary["Binary sparse SwiftTD<br/>[SwiftTD.cpp]"]
node_valued["Valued sparse SwiftTD<br/>[SwiftTD.cpp]"]

node_user -->|"uses"| node_package
node_package -->|"imports classes"| node_bindings
node_package -->|"imports version"| node_version
node_bindings -->|"binds classes"| node_interface
node_dense -->|"implements declarations"| node_interface
node_bindings -->|"dispatches calls"| node_dense
node_bindings -->|"dispatches calls"| node_binary
node_bindings -->|"dispatches calls"| node_valued
node_dense -->|"returns prediction"| node_user
node_binary -->|"returns prediction"| node_user
node_valued -->|"returns prediction"| node_user

click node_package "https://github.com/kjaved0/swifttd/blob/main/src/swifttd/__init__.py"
click node_version "https://github.com/kjaved0/swifttd/blob/main/src/swifttd/_version.py"
click node_bindings "https://github.com/kjaved0/swifttd/blob/main/src/cpp/pybind.cpp"
click node_interface "https://github.com/kjaved0/swifttd/blob/main/src/cpp/SwiftTD.h"
click node_dense "https://github.com/kjaved0/swifttd/blob/main/src/cpp/SwiftTD.cpp"
click node_binary "https://github.com/kjaved0/swifttd/blob/main/src/cpp/SwiftTD.cpp"
click node_valued "https://github.com/kjaved0/swifttd/blob/main/src/cpp/SwiftTD.cpp"

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_user toneIndigo
class node_package toneMint
class node_version,node_bindings,node_interface,node_dense,node_binary,node_valued toneTeal
```

## Components

### Other components

- **Python caller**
- [Python package API](https://github.com/kjaved0/swifttd/blob/main/src/swifttd/__init__.py): `src/swifttd/__init__.py`
- [Package version](https://github.com/kjaved0/swifttd/blob/main/src/swifttd/_version.py): `src/swifttd/_version.py`
- [Native bindings](https://github.com/kjaved0/swifttd/blob/main/src/cpp/pybind.cpp): `src/cpp/pybind.cpp`
- [C++ declarations](https://github.com/kjaved0/swifttd/blob/main/src/cpp/SwiftTD.h): `src/cpp/SwiftTD.h`
- [Dense SwiftTD](https://github.com/kjaved0/swifttd/blob/main/src/cpp/SwiftTD.cpp): `src/cpp/SwiftTD.cpp`
- [Binary sparse SwiftTD](https://github.com/kjaved0/swifttd/blob/main/src/cpp/SwiftTD.cpp): `src/cpp/SwiftTD.cpp`
- [Valued sparse SwiftTD](https://github.com/kjaved0/swifttd/blob/main/src/cpp/SwiftTD.cpp): `src/cpp/SwiftTD.cpp`

## Connections

- Python caller → Python package API: uses (evidence: `README.md`)
- Python package API → Native bindings: imports classes (evidence: `src/swifttd/__init__.py`)
- Python package API → Package version: imports version (evidence: `src/swifttd/__init__.py`)
- Native bindings → C++ declarations: binds classes (evidence: `src/cpp/pybind.cpp`)
- Dense SwiftTD → C++ declarations: implements declarations (evidence: `src/cpp/SwiftTD.cpp`)
- Native bindings → Dense SwiftTD: dispatches calls (evidence: `src/cpp/pybind.cpp`)
- Native bindings → Binary sparse SwiftTD: dispatches calls (evidence: `src/cpp/pybind.cpp`)
- Native bindings → Valued sparse SwiftTD: dispatches calls (evidence: `src/cpp/pybind.cpp`)
- Dense SwiftTD → Python caller: returns prediction (evidence: `README.md`)
- Binary sparse SwiftTD → Python caller: returns prediction (evidence: `README.md`)
- Valued sparse SwiftTD → Python caller: returns prediction (evidence: `README.md`)
