Framework to build hexagonal architecture applications in Python.
Project description
python-hexagonal
python-hexagonal is a library for building hexagonal applications in Python.
The real usage story lives in src/example and the proof lives in
src/tests/use_cases, so this documentation starts there instead of pretending a
two-line snippet is enough.
Start here
- Install the package:
pip install python-hexagonal - Follow the example-backed guide:
docs/getting-started/first-app.md - Understand the architecture roles:
docs/explanation/architecture-from-example.md - Bootstrap the adapter-specific SQLAlchemy path:
docs/how-to/bootstrap-sqlalchemy-app.md - Migrate existing apps to the scoped execution model:
docs/how-to/migrate-to-0.3.0-scoped-execution.md - Learn the canonical testing workflow:
docs/how-to/test-use-cases.md - Check the guardrails before copying imports:
docs/reference/supported-surface.md - Review the evidence map if you want to verify a claim against code or tests:
docs/reference/evidence-map.yaml
What you learn from the first path
After the first-app guide you should understand:
- where the domain model lives and why it stays isolated
- how application APIs wrap command, query, and event buses
- how ports describe the infrastructure your app needs
- how entrypoints assemble an app from environment and infrastructure
- how the use-case tests prove the workflow end to end
The blueprint we actually trust
These files are the baseline for the supported adoption story:
src/example/contacto/domain/contacto.py- aggregate behavior, value-object strategy, and query entry pointssrc/example/contacto/application/app.py- application composition throughBusAppGroupsrc/example/contacto/ports/drivens.py- infrastructure contracts and repository boundariessrc/example/app/application/api.py- top-level API wrapper consumers callsrc/example/app/entrypoints/main.py- environment-driven bootstrap viaEntrypointGroupsrc/example/app/entrypoints/db/sqlalchemy.py- SQLAlchemy-specific infrastructure assemblysrc/tests/use_cases/base.py- canonical test bootstrap with migrations, entrypoint creation, and topic registration
Supported path vs internals
The documented path is intentionally narrow.
- Start from
hexagonal.domain,hexagonal.application,hexagonal.ports.drivens,hexagonal.ports.drivers, andhexagonal.entrypoints - Reach for
hexagonal.integrations.sqlalchemywhen you need the reusable SQLAlchemy repository and unit-of-work utilities - Treat scoped execution as the default mental model: shared datastore and mapper, fresh write/read scope per operation
- Treat
hexagonal.entrypoints.sqlalchemyas adapter-specific convenience, not the whole framework story - Do not treat
hexagonal.__init__as the public integration surface; right now it only exposeshello() - Do not cargo-cult example names like
exampleAPI,exampleEntrypoint, orExampletate; copy the roles, not the labels - Do not build new code against
hexagonal.adapters.*; that path is kept for compatibility, while the supported SQLAlchemy extension surface now lives underhexagonal.integrations.sqlalchemy
Companion skill
This repo also ships an installable companion skill at
skills/python-hexagonal-usage/SKILL.md.
It is there to inspect a user repository, map it to the same architecture, and
point people back to the written docs. It does NOT replace the docs and it does
NOT get to invent new supported APIs.
Project details
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 python_hexagonal-0.3.2.tar.gz.
File metadata
- Download URL: python_hexagonal-0.3.2.tar.gz
- Upload date:
- Size: 42.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a609d8dc9de8608c2ef4e2253a19c34feb30644918a3f2a7986a18a7df30ef9e
|
|
| MD5 |
bf5dacc6100a871d343e76db69a15116
|
|
| BLAKE2b-256 |
a0914ce0d4759b57bab36cff3f5968be8d8d7f4a1f46ee754ffa394b45a06d9d
|
Provenance
The following attestation bundles were made for python_hexagonal-0.3.2.tar.gz:
Publisher:
python-publish.yml on jose-matos-9281/python-hexagonal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_hexagonal-0.3.2.tar.gz -
Subject digest:
a609d8dc9de8608c2ef4e2253a19c34feb30644918a3f2a7986a18a7df30ef9e - Sigstore transparency entry: 1153960256
- Sigstore integration time:
-
Permalink:
jose-matos-9281/python-hexagonal@b34fe6c6d622dde16fa48c88fc2276aed23bd3d3 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/jose-matos-9281
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b34fe6c6d622dde16fa48c88fc2276aed23bd3d3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file python_hexagonal-0.3.2-py3-none-any.whl.
File metadata
- Download URL: python_hexagonal-0.3.2-py3-none-any.whl
- Upload date:
- Size: 71.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7f4a410310b79215982be95838dc7f2659a0d5f042f0e3bfd28a7dd088247e8
|
|
| MD5 |
5242602aa245d7a6a8a0d2ceda095561
|
|
| BLAKE2b-256 |
f97138488128f7aa5abc95ebfed32f5cf978bf49c271d60762b3b3d1e86463a5
|
Provenance
The following attestation bundles were made for python_hexagonal-0.3.2-py3-none-any.whl:
Publisher:
python-publish.yml on jose-matos-9281/python-hexagonal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_hexagonal-0.3.2-py3-none-any.whl -
Subject digest:
a7f4a410310b79215982be95838dc7f2659a0d5f042f0e3bfd28a7dd088247e8 - Sigstore transparency entry: 1153960257
- Sigstore integration time:
-
Permalink:
jose-matos-9281/python-hexagonal@b34fe6c6d622dde16fa48c88fc2276aed23bd3d3 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/jose-matos-9281
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b34fe6c6d622dde16fa48c88fc2276aed23bd3d3 -
Trigger Event:
release
-
Statement type: