Architecture Guard & Linter & Scanner for DDD projects
Project description
dddguard
Architecture Guard, Linter, and Scaffolder for Domain-Driven Design projects.
Stop arguing about folder structures and layer boundaries. dddguard enforces strict architectural rules, generates compliant boilerplate, and visualizes your project dependency graph.
It is designed to be your interactive architectural companion.
Quick Start
Install globally using uv (requires Python 3.10+):
uv tool install dddguard
Simply run the tool to enter the interactive HUD:
dddguard
The tool will guide you through scanning, linting, or creating new components.
Capabilities
๐ก๏ธ Lint Command: dddguard lint
You can explore detailed architectural rules and naming conventions interactively via diagrams using the 'View Rules (Summary)' and 'View Rules (Matrix)' options within the linter's interface.
๐ Draw Command: dddguard draw
The visualizer parses your actual code structure and generates an XML file compatible with Draw.io (diagrams.net). It maps relationships between Contexts and Layers based on real imports. When using dddguard drawdir to visualize a specific directory, the generated diagram will include comprehensive information in its legend, providing detailed insights into the visualized architecture.
๐ก Scan Command: dddguard scan
The core analysis engine. It builds a dependency graph of your entire project, detecting contexts and layers. Use the interactive filters to explore specific parts of your monolith or modular monolith.
The Standard
dddguard enforces a highly structured, granular architecture. This approach maximizes separation of concerns and clearly defines the role of every component, from the global entrypoint down to the individual Bounded Context.
src/
โโโ <context_name>/
โ โโโ domain/ # Pure Business Logic
โ โ โโโ aggregates/ # - Encapsulates business rules and consistency
โ โ โโโ entities/ # - Business objects with a distinct identity
โ โ โโโ vo/ # - Value Objects, immutable and without identity
โ โ โโโ services/ # - Domain-specific operations, not tied to an entity
โ โ โโโ events/ # - Represents something that happened in the domain
โ โ โโโ errors/ # - Custom domain-specific exceptions
โ โ
โ โโโ app/ # Application Layer: Orchestrates domain logic
โ โ โโโ use_cases/ # - Implements Commands that change system state
โ โ โโโ queries/ # - Implements Queries that read system state
โ โ โโโ workflows/ # - Manages long-running processes (Sagas)
โ โ โโโ handlers/ # - Reacts to domain or integration events
โ โ โโโ interfaces/ # - Defines contracts (ports) for driven adapters
โ โ
โ โโโ adapters/ # Translation layer between the core and the outside world
โ โ โโโ driving/ # - Adapters that drive the application (e.g., Controllers)
โ โ โโโ driven/ # - Adapters driven by the application (e.g., Repositories)
โ โ
โ โโโ ports/ # Technology-specific infrastructure code
โ โ โโโ driving/ # - Entry points for incoming signals (web server, CLI app)
โ โ โโโ driven/ # - Egress points for outgoing signals (DB client, HTTP client)
โ โ
โ โโโ composition.py # - Wires all dependencies for this specific context
โ
โโโ shared/ # Shared code: kernels, libraries, or models used by multiple contexts
โ
โโโ root/ # Global application entrypoint and composition root
โโโ composition.py # - Wires all contexts and shared services together
โโโ main.py # - Main application entrypoint (e.g., starts web server)
โโโ cli.py # - CLI application entrypoint
Anatomy of the Architecture
-
root/: The top-level entrypoint for your entire application. Itscomposition.pyassembles the different Bounded Contexts andshared/components. -
shared/: A place for code that is shared across multiple contexts, such as a shared kernel, common libraries, or cross-cutting concerns like logging. The structure withinshared/is intentionally flexible. -
<context_name>/: Represents a Bounded Context, a self-contained module with its own internal layers:domain/: The heart of the context's business logic. It is completely isolated and pure.app/: Orchestrates the domain logic to perform specific tasks, defining the application's capabilities.adapters/: Translate between the outside world and the application layer, implementing interfaces defined inapp/or triggeringapp/logic.ports/: Contain the raw, technology-specific code that connects to infrastructure.composition.py: The context's local "glue" that wires together its internal components.
Technology Stack
The project is built with modern Python tooling and development practices:
- Typer + Rich + InquirerPy best smooth CLI experience.
- Dishka lightweight Dependency Injection for clean and decoupled architecture.
Maintained by: Sense1Tapo4ek
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 dddguard-1.1.1.tar.gz.
File metadata
- Download URL: dddguard-1.1.1.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93be6d40060cbb4be773c0d3ce2b97e1d86a222f281410a60739be72bc47f284
|
|
| MD5 |
91556d5ae2406d360cfeeb02d2e25c29
|
|
| BLAKE2b-256 |
582b4e08d3f1ebefdc25b174fbac1c0e304a236877cb3b71cb8d51d29a5ff6d9
|
File details
Details for the file dddguard-1.1.1-py3-none-any.whl.
File metadata
- Download URL: dddguard-1.1.1-py3-none-any.whl
- Upload date:
- Size: 149.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6952d53fc6ea3764f8838700596677e4cec9b5ac1999e55d61e601397a39824e
|
|
| MD5 |
0ff10d8d440393c6195b542374c307f1
|
|
| BLAKE2b-256 |
a424a84ad9c00785688f6fb9817bae98e990a2b3ad2e8c1a70b18ef75faa6a5f
|