Skip to main content

DDD Structure Generator for Python Projects

Project description

DDDify 🏗️

Ein Generator für Domain-Driven Design (DDD) Projektstrukturen mit Clean Architecture für Python.

🎯 Was macht DDDify?

DDDify generiert automatisch eine vollständige DDD-Projektstruktur mit allen notwendigen Dateien und Templates:

domain/                  # 🟢 DER KERN (Reines Python, KEINE Frameworks!)
├── entities.py          # Die Fachlogik-Objekte
├── value_objects.py     # Unveränderliche Werte
├── exceptions.py        # Fachliche Fehler
└── ports.py             # Interfaces

application/             # 🟡 DIE STEUERUNG (Use Cases)
├── services.py          # Orchestriert Domain & Infra
├── queries.py           # CQRS: Lese-Operationen
└── commands.py          # CQRS: Schreib-Operationen

infrastructure/          # 🔴 DIE DETAILS (Datenbank, Ext. APIs)
├── persistence/
│   ├── orm.py           # SQLAlchemy Modelle
│   └── repository.py    # Repository-Implementierung
└── adapters/            # z.B. SmtpEmailAdapter

presentation/            # 🔵 DIE SCHNITTSTELLE (HTTP, CLI)
├── router.py            # FastAPI Routes
└── schemas.py           # Pydantic DTOs

🚀 Installation

# Klone das Repository
git clone <repo-url>
cd dddify

# Aktiviere die virtuelle Umgebung (falls vorhanden)
.venv\Scripts\activate  # Windows
source .venv/bin/activate  # Linux/Mac

# Installiere Dependencies (falls nötig)
pip install -r requirements.txt

💻 Verwendung

Grundlegende Verwendung

cd ddify
python test.py generate "Order Management" "Order"

Dies generiert eine vollständige DDD-Struktur für eine "Order Management" Domain mit einer "Order" Entity.

Mit benutzerdefiniertem Ausgabeverzeichnis

python test.py generate "User Management" "User" --output-dir ./my-project

Verfügbare Templates anzeigen

python test.py list-templates

📋 Beispiele

E-Commerce Order Management

python test.py generate "Order Management" "Order"

User Management System

python test.py generate "User Management" "User"

Product Catalog

python test.py generate "Product Catalog" "Product"

🏗️ Generierte Struktur

Nach der Generierung erhältst du:

  • ✅ Vollständige DDD-Ordnerstruktur
  • ✅ Alle notwendigen Python-Dateien mit Code-Vorlagen
  • ✅ Clean Architecture Prinzipien
  • ✅ CQRS Pattern (Commands & Queries)
  • ✅ Repository Pattern
  • ✅ FastAPI Integration
  • ✅ SQLAlchemy ORM Setup
  • ✅ Pydantic Schemas
  • ✅ README.md mit Strukturübersicht

🎨 Templates

DDDify verwendet Jinja2-Templates für maximale Flexibilität:

  • entities.py.j2 - Domain Entities
  • value_objects.py.j2 - Value Objects
  • exceptions.py.j2 - Domain Exceptions
  • ports.py.j2 - Repository Interfaces
  • application_services.py.j2 - Application Services
  • commands.py.j2 - CQRS Commands
  • queries.py.j2 - CQRS Queries
  • orm.py.j2 - SQLAlchemy Models
  • repository.py.j2 - Repository Implementation
  • router.py.j2 - FastAPI Router
  • schemas.py.j2 - Pydantic Schemas

📚 DDD Prinzipien

Abhängigkeitsregeln

  1. Domain kennt niemanden (Pure Python, keine Frameworks)
  2. Application kennt nur Domain
  3. Infrastructure implementiert Domain-Interfaces
  4. Presentation kennt Application + Domain

Vorteile

  • ✅ Klare Trennung der Verantwortlichkeiten
  • ✅ Testbar durch Interface-basiertes Design
  • ✅ Framework-unabhängige Business-Logik
  • ✅ Einfach wartbar und erweiterbar
  • ✅ Skalierbar durch CQRS-Pattern

🛠️ Entwicklung

# Generator anpassen
vim ddify/main.py

# Neue Templates hinzufügen
vim ddify/templates/your_template.py.j2

# Testen
python ddify/test.py generate "Test Domain" "TestEntity"

📝 Lizenz

MIT

🤝 Contributing

Pull Requests sind willkommen!

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

dddify-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

dddify-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dddify-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for dddify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 83893e4ab6671aa62d1d99a37814a6758b6c17f6a069ef3c76c96838da480c5d
MD5 f7fb6a799c6182b92e0e5b26ef0470e5
BLAKE2b-256 fd789fc883e0cd96cc6333839d6869bc10d06828afb77c0befde8d8a1e5d90f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dddify-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for dddify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f9ec7d2b94da0a1ef8cbbd09968f75c0e070c6a3dfc5f115e17d1f37da1ec41
MD5 f7a3c2f47293919713a1ea217010146e
BLAKE2b-256 1f6c6ffd49ee1c94ae9737f5cd25f4ae722be294ce05f14fbf951b910595914d

See more details on using hashes here.

Supported by

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