A Python codegen tool for transport layers in DDD, supporting most popular transport / API frameworks.
Project description
Gendalf is a code-first generator for Python adapters.
It generates type-safe transport and persistence layers directly from existing Python code and SQL files — without requiring OpenAPI, Protobuf, AsyncAPI, or ORMs.
Your code is the source of truth.
Gendalf generates the glue.
Key ideas
-
Code-first
- Adapters are generated from Python modules and SQL files
- No external specs to write or maintain
-
Deterministic
- Gendalf uses a deterministic, AST-based algorithm to analyze code and generate adapters
- It does not use LLMs or any probabilistic generation
- Given the same inputs, the output is always identical
-
Adapter-oriented
- Transport adapters: FastAPI servers, HTTP clients, gRPC, WebSockets
- Persistence adapters: SQL → typed Python APIs
- Boundary code only — business logic remains untouched
-
Type-safe
- Python types propagate across generated code
- SQL queries produce typed inputs and outputs
-
Minimal opt-in
- Use standard Python type annotations
- Mark Python classes intended as entrypoints with
@entrypoint - Add
-- sqlcastmarkers to SQL files - Everything else is inferred
Why Gendalf
Most code generators require you to:
- write specs first,
- duplicate models,
- adopt specific frameworks or ORMs.
LLM-based code generation introduces other problems:
- non-deterministic output,
- mandatory manual review,
- runtime cost and token usage.
Gendalf does the opposite:
- Python code defines the contract,
- SQL defines persistence,
- adapters and DTOs are generated by explicit algorithms (type inspection and AST traversal).
Generated code can be committed, regenerated in CI, and treated as compiler output.
Transports
FastAPI & HTTPX
Run with gendalf src cast fastapi.
Supported patterns:
- request-response (POST, JSON body)
- duplex streaming (WebSocket, JSON frames)
Generated code
src/api/fastapi/models.py— Pydantic request/response modelssrc/api/fastapi/client.py— async typed HTTP clientsrc/api/fastapi/server.py— server handlers with serialization and domain invocation
Generated code is complete and requires no manual edits.
Aiohttp
Run with gendalf src cast aiohttp.
Supported patterns:
- request-response (POST, JSON body)
- duplex streaming (WebSocket, JSON frames)
Generated code
src/api/aiohttp/models.pysrc/api/aiohttp/client.pysrc/api/aiohttp/server.py
Examples
gRPC (planned)
Not supported yet.
Planned:
- unary-unary
- unary-stream
- stream-unary
- stream-stream
Persistence
SQL
WIP: Generate type-safe Python APIs directly from SQL files — no ORM required.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gendalf-0.4.0.tar.gz.
File metadata
- Download URL: gendalf-0.4.0.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77fbb9d79260eb4ce4899513f92a4c7fe714d4053d5f0be32158df93201beaa4
|
|
| MD5 |
693eee76248280cfeff1d909a2c00ab1
|
|
| BLAKE2b-256 |
f22a3c41eca381ba6d6a89e56ed01c32d527b3b30662ecd83e2b05607a5822fc
|
Provenance
The following attestation bundles were made for gendalf-0.4.0.tar.gz:
Publisher:
publish.yaml on zerlok/gendalf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gendalf-0.4.0.tar.gz -
Subject digest:
77fbb9d79260eb4ce4899513f92a4c7fe714d4053d5f0be32158df93201beaa4 - Sigstore transparency entry: 1058667695
- Sigstore integration time:
-
Permalink:
zerlok/gendalf@89ed6bf16f9c5d6b4859e1b7354f5b54209f7869 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/zerlok
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@89ed6bf16f9c5d6b4859e1b7354f5b54209f7869 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gendalf-0.4.0-py3-none-any.whl.
File metadata
- Download URL: gendalf-0.4.0-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e36586c7808a01b9f5f826364e0b0974ed77a667eaf0db453d9316716928b84c
|
|
| MD5 |
45470c369cd876808dfa167c4d890daa
|
|
| BLAKE2b-256 |
fc6a638522dba0aa35286bfa411a501f9944cf19c4a41c676d222aba0d6c0b1c
|
Provenance
The following attestation bundles were made for gendalf-0.4.0-py3-none-any.whl:
Publisher:
publish.yaml on zerlok/gendalf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gendalf-0.4.0-py3-none-any.whl -
Subject digest:
e36586c7808a01b9f5f826364e0b0974ed77a667eaf0db453d9316716928b84c - Sigstore transparency entry: 1058667697
- Sigstore integration time:
-
Permalink:
zerlok/gendalf@89ed6bf16f9c5d6b4859e1b7354f5b54209f7869 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/zerlok
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@89ed6bf16f9c5d6b4859e1b7354f5b54209f7869 -
Trigger Event:
release
-
Statement type: