No project description provided
Project description
django-modulith
A toolkit for building modular, maintainable Django applications using the Modulith architectural pattern.
What is a Modulith?
A Modulith is a monolithic application that is internally structured as a collection of well-defined, loosely-coupled modules. It combines the deployment simplicity of a monolith with the architectural clarity of microservices.
Features
- Module Generation: Quickly scaffold new application modules with proper structure
- Interface Registry: Define clear boundaries between modules via the interface registry
- Import Control: Enforce architectural boundaries using import linting
- Django Integration: Seamlessly works with Django's existing patterns
Installation
Add to your Django project's INSTALLED_APPS:
INSTALLED_APPS = [
# ...
'django_modulith',
# ...
]
Quick Start
- Create a new module This will:
Create a new module directory with proper structure Update the importlinter configuration to include the new module
-
Define module interfaces
-
Use module interfaces
Architecture Enforcement
The library helps enforce module boundaries through import linting:
# Check for import rule violations
python -m importlinter
# Generate visualization of module dependencies
python -m importlinter.visualization
Interface Registry
The InterfaceRegistry serves as the core of the inter-module communication:
- Functions registered with the
@interfacedecorator become available via the registry - Type annotations are preserved for IDE autocomplete support
- The registry pattern discourages direct imports between modules
Best Practices
- Keep modules focused: Each module should have a single responsibility
- Use interfaces: Access other modules through the interface registry, not direct imports
- Honor boundaries: Structure code to respect the architectural boundaries
- Document interfaces: Well-documented interfaces make the module boundaries clear
Configuration
Import Linter Configuration
The .importlinter file controls module boundaries:
[importlinter]
root_package = modules
include_external_packages = n
[importlinter:contract:modulith_modules]
name = Domain modules are independent
type = independence
modules =
users
products
orders
Advanced Usage
Type Hints
A stub file (interface_registry.pyi) is automatically generated to provide proper type hints for registered interfaces.
Contributing
Contributions are welcome! Please check the contribution guidelines for more details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 Distributions
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 django_modulith-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_modulith-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de4210cb2514700e631addf8e9bb8225b41636bd502d0fab667f2a10eaf33a98
|
|
| MD5 |
f17545f46ddc05aaa9080d3250934a50
|
|
| BLAKE2b-256 |
9c8e337c15b0f0b33f3d7061439052e16f81a4ab67002cabf42340eac672d5b1
|
Provenance
The following attestation bundles were made for django_modulith-0.1.0-py3-none-any.whl:
Publisher:
python-package.yml on patzomir/django-modulith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_modulith-0.1.0-py3-none-any.whl -
Subject digest:
de4210cb2514700e631addf8e9bb8225b41636bd502d0fab667f2a10eaf33a98 - Sigstore transparency entry: 183470706
- Sigstore integration time:
-
Permalink:
patzomir/django-modulith@d726559b34a3d48962c20218f36ff3e7eab81fe3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/patzomir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package.yml@d726559b34a3d48962c20218f36ff3e7eab81fe3 -
Trigger Event:
push
-
Statement type: