Hexagonal Coherence Check
Project description
Hexagonal Coherence Check
This project checks if the dependency flow between the layers of the Hexagonal architecture defined for this project was respected.
How to install
It can be easily installed via pip: pip install hexagonal-py
How to configure your project
First it's necessary to define your hexagonal layers and their order.
The tool expects a default file name on your source folder dir with the name hexagonal_config.py
.
-
First you create the Hexagonal Layers you have on your system via the class name HexagonalLayer. There are two arguments:
name
: It can be any name,domain
,frontend
,infrastructure
, or any name you used for your layers.usecases
: This is the name of the directory the files related to this layer as storage. It's not the full path, it's the directory name relative path from source.
-
Import
hexagonal_config
on your file, and define the order with+
(add layers) then>>
(set the sequence of the layers). The most to the left layers is the most outer layer, while the most to the right layer is the most inner layer.
Example, for this folder structure:
. src
├── __init__.py
├── hexagonal_config.py
├── domain
│ ├── __init__.py
│ ├── __pycache__
│ └── person.py
├── infrastructure
│ ├── __init__.py
│ └── person_mysql_repository.py
├── main.py
├── services
│ ├── __init__.py
│ └── person_repository.py
└── usecases
├── __init__.py
└── create_person_usecase.py
.tests
The file:
from hexagonal.hexagonal_config import hexagonal_config
hexagonal_config.add_inner_layer_with_dirs(layer_name='infrastructure', directories=['/infrastructure'])
hexagonal_config.add_inner_layer_with_dirs(layer_name='use_cases', directories=['/use_cases'])
hexagonal_config.add_inner_layer_with_dirs(layer_name='services', directories=['/services'])
hexagonal_config.add_inner_layer_with_dirs(layer_name='domain', directories=['/domain'])
hexagonal_config.excluded_dirs = ['/tests']
Generating the Project Diagram
This command generate a visual diagram show the composition of your hexagonal layers.
Pre requisites
To generate the Hexagonal Diagram of the project, it's necessary to have Graphviz installed in the machine.
For Mac you can brew install graphviz
.
For other, check the documentation https://graphviz.org/download/.
CMD
hexagonal diagram --source_path ./
Checking Project's Hexagonal Integrity
This checks if the correct flow of the dependencies -from outer to inner layer- was respected.
CMD
hexagonal check --source_path ./
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
Hashes for hexagonal_py-0.0.26-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0c15531a34cf3d36ca7658807c83d70104099d7656cf7e92f0baf807d9614df |
|
MD5 | c855c1cec1965f9f997404c6249af6a2 |
|
BLAKE2b-256 | e1db6ec2f926a3be7b0ab6ca4370c1e94d7cf734859a9d3d40009ff0c486bb48 |