Skip to main content

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

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 points
  • src/example/contacto/application/app.py - application composition through BusAppGroup
  • src/example/contacto/ports/drivens.py - infrastructure contracts and repository boundaries
  • src/example/app/application/api.py - top-level API wrapper consumers call
  • src/example/app/entrypoints/main.py - environment-driven bootstrap via EntrypointGroup
  • src/example/app/entrypoints/db/sqlalchemy.py - SQLAlchemy-specific infrastructure assembly
  • src/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, and hexagonal.entrypoints
  • Reach for hexagonal.integrations.sqlalchemy when 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.sqlalchemy as adapter-specific convenience, not the whole framework story
  • Do not treat hexagonal.__init__ as the public integration surface; right now it only exposes hello()
  • Do not cargo-cult example names like exampleAPI, exampleEntrypoint, or Exampletate; 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 under hexagonal.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

python_hexagonal-0.3.0.tar.gz (41.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_hexagonal-0.3.0-py3-none-any.whl (71.0 kB view details)

Uploaded Python 3

File details

Details for the file python_hexagonal-0.3.0.tar.gz.

File metadata

  • Download URL: python_hexagonal-0.3.0.tar.gz
  • Upload date:
  • Size: 41.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for python_hexagonal-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3baa7a6dd68b1f7210127e093595862e8eff933ecc880b45af74cc50027c09d1
MD5 9cfa845e5e7ca545a6b2f8eda7fe73f0
BLAKE2b-256 0f79edacaa152899b7c7428784f7e3d1a216c7a505cc0376368f8c97b39ab9c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_hexagonal-0.3.0.tar.gz:

Publisher: python-publish.yml on jose-matos-9281/python-hexagonal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_hexagonal-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_hexagonal-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1351f4c7a1ab7b454e77eb9b7457e9913e04da9d9bf39a5ff325f0fd0c52e8f3
MD5 ce3e71200a593378cc6fa9d08c64a690
BLAKE2b-256 93c7928fd6600429aea1a47cc405255acafd6c185a96d3fd7f58a77d93787a49

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_hexagonal-0.3.0-py3-none-any.whl:

Publisher: python-publish.yml on jose-matos-9281/python-hexagonal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page