|
| 1 | +# Architecture |
| 2 | + |
| 3 | +## Layer hierarchy |
| 4 | + |
| 5 | +``` |
| 6 | +Application layer (depends on Domain + Primitives) |
| 7 | +├── python-mediator |
| 8 | +├── python-cqrs-dispatcher (depends on cqrs-core + mediator) |
| 9 | +├── fastapi-config-patterns |
| 10 | +├── fastapi-middleware-toolkit |
| 11 | +├── python-structlog-config |
| 12 | +├── python-outbox-core |
| 13 | +├── sqlalchemy-async-session-factory |
| 14 | +└── sqlalchemy-async-repositories |
| 15 | +
|
| 16 | +Domain layer (depends on Primitives only) |
| 17 | +├── python-app-exceptions |
| 18 | +├── python-infrastructure-exceptions |
| 19 | +├── python-input-validation |
| 20 | +├── python-cqrs-core |
| 21 | +├── python-domain-events |
| 22 | +├── python-dto-mappers |
| 23 | +└── pydantic-response-models |
| 24 | +
|
| 25 | +Primitives layer (zero dependencies) |
| 26 | +└── python-technical-primitives |
| 27 | +``` |
| 28 | + |
| 29 | +## Import-linter contracts |
| 30 | + |
| 31 | +Layer boundaries are enforced via `import-linter` in `pyproject.toml`: |
| 32 | + |
| 33 | +- **Primitives** cannot import from domain or application |
| 34 | +- **Domain** can import from primitives, cannot import from application |
| 35 | +- **Application** can import from domain and primitives |
| 36 | + |
| 37 | +## Inter-package dependencies |
| 38 | + |
| 39 | +Only one cross-package dependency exists: |
| 40 | + |
| 41 | +``` |
| 42 | +python-cqrs-dispatcher |
| 43 | +├── python-cqrs-core (ICommand, IQuery interfaces) |
| 44 | +└── python-mediator (Mediator dispatch engine) |
| 45 | +``` |
| 46 | + |
| 47 | +All other packages are fully independent. |
| 48 | + |
| 49 | +## Design patterns used |
| 50 | + |
| 51 | +| Pattern | Package | |
| 52 | +|---------|---------| |
| 53 | +| Specification | `python-technical-primitives` | |
| 54 | +| Repository + Strategy | `sqlalchemy-async-repositories` | |
| 55 | +| Factory Method | `sqlalchemy-async-repositories` (pagination) | |
| 56 | +| Mediator | `python-mediator` | |
| 57 | +| CQRS | `python-cqrs-core`, `python-cqrs-dispatcher` | |
| 58 | +| Pipeline behaviors | `python-mediator` | |
| 59 | +| Transactional outbox | `python-outbox-core` | |
| 60 | +| Strategy (formatters) | `python-outbox-core` | |
| 61 | +| CloudEvents | `python-outbox-core` | |
0 commit comments