Skip to main content

Bendykit

Code generator for Python backends following DDD principles.

Describe your domain in a single Python file, get a full stack: domain models, repository, use cases, DTOs and FastAPI routers. Architecture is Onion, no ActiveRecord, strict layer separation.

Installation

pip install bendykit

Usage

# manifest.py
from decimal import Decimal
from enum import Enum
from typing import Optional
from datetime import datetime

from bendy import Aggregate, ValueObject, Field, auto_now


class OrderStatus(Enum):
    PENDING = "pending"
    CONFIRMED = "confirmed"


class Address(ValueObject):
    street: str
    city: str
    country: str = "US"


class Order(Aggregate):
    customer_id: str
    total_amount: Decimal
    status: OrderStatus = OrderStatus.PENDING
    shipping_address: Address
    notes: Optional[str] = None
    created_at: datetime = auto_now

    class Meta:
        use_cases = ["create", "get", "update", "delete", "list"]
bendykit manifest.py ./src

Generates for each aggregate:

src/order/
├── domain/
│   ├── models.py        # @dataclass Order
│   ├── enums.py         # OrderStatus(Enum)
│   ├── value_objects.py # @dataclass(frozen=True) Address
│   └── repository.py    # OrderRepository(ABC)
├── application/
│   ├── dtos.py          # OrderCreate / OrderUpdate / OrderResponse
│   └── use_cases.py     # Create/Get/Update/Delete/ListOrderUseCase
├── presentation/
│   └── router.py        # FastAPI router
└── infrastructure/
    ├── models.py        # OrderModel(Base) — SQLAlchemy 2.0
    └── repository.py    # SqlalchemyOrderRepository + mapper

Types

Manifest Python SQLAlchemy
str str String
int int Integer
float float Float
bool bool Boolean
Decimal Decimal Numeric
datetime datetime DateTime
date date Date
UUID UUID String
Optional[X] Optional[X] nullable=True
MyEnum(Enum) MyEnum String + mapper
MyVO(ValueObject) MyVO JSON

Manifest primitives

  • auto_now — value is set server-side, excluded from Create/Update DTOs
  • Field(unique=True, index=True, max_length=N) — column metadata
  • ValueObject — nested object without id, stored as JSON
  • Meta.use_cases — operations to generate: create, get, update, delete, list (default: create, get)

Roadmap

  • Phase I — CLI generator
  • Phase II — Python manifests (Enum, ValueObject, Field, auto_now, Meta)
  • Phase III — bendykit.runtime: Unit of Work, Domain Events

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bendykit-0.1.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bendykit-0.1.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file bendykit-0.1.0.tar.gz.

File metadata

  • Download URL: bendykit-0.1.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bendykit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cd9d2502bd8ef9352192d2ad78242e1025ca1510042b07f2dc00a69f3100ff2c
MD5 9cb9e1cb2dc55e753dd2d721f279c87b
BLAKE2b-256 78495abbd1b7b914f6cfc828826467625cf3aab6ccdf5b19a19ab1665aa55106

See more details on using hashes here.

File details

Details for the file bendykit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bendykit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for bendykit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1695ce66127b9e5d2c420adb53ca04da0b4d8c4c9a7397472625aa7b4b585629
MD5 edb8e7b36970e277b8b009517242b69c
BLAKE2b-256 7171fcb1d6c01923625895b876e46aac505d5a1b115458197b09698e41bbf883

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page