CLI tool for generating DDD architecture in Python projects
Project description
PyConstructor ๐๏ธ
PyConstructor is a command-line tool that helps developers quickly create a project structure following Domain-Driven Design (DDD) principles. The tool generates architecture based on a YAML configuration that defines bounded contexts, entities, repositories, services, use cases, and other DDD elements.
๐ Quick Start
Installation
# Install via pip
pip install pyconstructor
# Install via uv
uv add pyconstructor
# Generate YAML file with example data
pyc init
# Edit the generated ddd-config.yaml file
# ...
# Generate structure
pyc run
Basic Usage
- Initialize a new project with a preset configuration:
pyc init --preset <PresetType(Optional argument, default to Standard)>
- Validate your configuration (Optional command):
pyc validate
- Preview the project structure (Optional command):
pyc preview --file <file_name> (Optional argument)
- Generate the project:
pyc run --file <file_name> (Optional argument)
๐ Available Commands
Core Commands
| Command | Description | Example |
|---|---|---|
init |
Initialize a new project with a preset configuration | pyc init --preset standard |
validate |
Validate your YAML configuration | pyc validate --file custom-config.yaml |
preview |
Preview the project structure without generating files | pyc preview --file custom-config.yaml |
run |
Generate the project structure | pyc run --file custom-config.yaml |
Command Options
init Command
# Create project with standard preset
pyc init --preset standard
# Force overwrite existing config
pyc init --preset standard --force
validate Command
# Validate default config (ddd-config.yaml)
pyc validate
# Validate specific config file
pyc validate --file custom-config.yaml
preview Command
# Preview default config
pyc preview
# Preview specific config
pyc preview --file custom-config.yaml
Output:
- Displays the project structure tree in the console
- Generates a
structure.mdfile with the same tree view for future reference
Example output:
app/
โโโ domain/
โ โโโ user/
โ โ โโโ entities/
โ โ โ โโโ user.py
โ โ โโโ value_objects/
โ โ โโโ email.py
โ โโโ catalog/
โ โโโ entities/
โ โโโ product.py
โโโ application/
โ โโโ user/
โ โโโ use_cases/
โ โโโ register_user.py
โโโ infrastructure/
โโโ repositories/
โโโ user_repository.py
run Command
# Generate from default config
pyc run
# Generate from specific config
pyc run --file custom-config.yaml
Architecture Presets
PyConstructor comes with three built-in presets:
Simple Preset
Basic DDD structure without bounded contexts:
pyc init --preset simple
Standard Preset
Default preset with bounded contexts:
pybuilder init --preset standard
Advanced Preset
Complex structure with nested contexts:
pyc init --preset advanced
Configuration
The tool uses YAML configuration files to define your project structure.
Example configurations are provided in the src/templates/config_templates directory.
Simple Configuration Example
settings:
preset: "simple"
layers:
domain:
entities: User, Product
value_objects: Email, Price
Standard Configuration Example
settings:
preset: "standard"
layers:
domain:
contexts:
- name: user
entities: [User, Profile]
value_objects: [Email, Password]
- name: catalog
entities: [Product, Category]
Advanced Configuration Example (for microservice architecture)
settings:
preset: "advanced"
layers:
contexts:
- name: user_context
domain:
entities: User
value_objects: Email
application:
use_cases: CreateUser
infrastructure:
repositories: UserRepository
- name: payment_context
domain:
entities: Payment
application:
use_cases: ProcessPayment
infrastructure:
repositories: TransactionRepository
๐ค Contributing
Contributions are welcome. Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git switch -c feature/amazing-feature) - Run tests (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT Licenseโsee the LICENSE file for details.
๐ค Author
Grigoriy Sokolov (Sokolov_Gr@proton.me)
Project details
Release history Release notifications | RSS feed
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 pyconstructor-0.2.0.tar.gz.
File metadata
- Download URL: pyconstructor-0.2.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc1ad2b4599c148bd93ed804268411f94d866fe700a9a9daba94456bd68df891
|
|
| MD5 |
60ca399169f212db454319d1127595f7
|
|
| BLAKE2b-256 |
66ec32756145098b24b546325602411cedeafc628f4be8000832fecab4970658
|
File details
Details for the file pyconstructor-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyconstructor-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5ee81f089c56ce170c07b2110b32aa620700eaa68947524d2407f6e59041880
|
|
| MD5 |
17374ba89d02dbe1fcd326b93f599d9a
|
|
| BLAKE2b-256 |
a28ea185b5d6760d6e5719047b55bf74f31150782b9436e826c7866fcf25a164
|