Skip to main content

PyPI version shields.io PyPI pyversions Ruff Checked with mypy

hexkit

A chassis library for building domain-focused, infrastructure-agnostic, and event-driven microservices in Python

Read the short summary below, or jump straight to our full 📖 User Guide to learn the abstract concepts and patterns as well as the concrete infrastructure integrations and testing tools that hexkit provides for building better microservices.

In a Nutshell

hexkit implements the Triple Hexagonal Architecture pattern, an optimization of the ordinary Hexagonal Architecture for use with microservices: adapters (as per the hexagonal architecture) are divided into two parts. One part called translator is specific to one individual microservice and its domain-oriented ports. The other part called provider is service-agnostic but specific to one technology of the surrounding infrastructure. Both parts interact through a high-level interface called protocol (not to be confused with Python's typing.Protocol) which is neither specific to the technology nor to the microservice.

As a chassis lib, hexkit reduces redundancy and boilerplate across microservices by providing the service-independent building blocks — protocols and providers — ready to use. The only task that remains for an individual service is to implement service-specific translators between the service's ports and the general-purpose protocols (in addition to implementing the domain functionality of the service, of course). For an in-depth introduction to the pattern, please read the Architectural Concepts chapter of the User Guide.

The following protocols and providers are currently available:

Protocol Providers
Event Publishing Apache Kafka, MongoDB + Kafka (outbox)
Event Subscription Apache Kafka
Data Access Object MongoDB
Object Storage S3(-compatible)
Key-Value Store MongoDB, Redis, S3, HashiCorp Vault

In-memory implementations and per-backend test utilities are also included to support testing without real infrastructure.

You are not forced to go all-in on the idea of Triple Hexagonal Architecture. You can use it just for the technologies where you see benefits and use another approach for the rest. For example, you could use hexkit for simplifying the exchange of events between microservices but use a classical web framework such as FastAPI for designing REST APIs and an ORM like SQLAlchemy for interacting with databases.

Getting Started

The 📖 User Guide covers all protocols, providers, testing utilities, and observability tools with example code, and the API Reference documents all public classes and functions.

For a complete example service built with hexkit, have a look at the stream_calc example application. We also put a lot of effort into making the code self-documenting: you can find the protocols being defined at src/hexkit/protocols and the providers being implemented at src/hexkit/providers.

Installation

This package is available at PyPI: https://pypi.org/project/hexkit

You can install it from there using:

pip install hexkit

The following extras are available:

  • akafka: when using the Apache Kafka-based event publishing or subscription
  • mongodb: when using MongoDB as backend for the DAO protocol or key-value stores
  • s3: when interacting with S3-compatible object storages or key-value stores
  • redis: when using Redis-based key-value stores
  • vault: when using HashiCorp Vault-based key-value stores
  • opentelemetry: observability instrumentation (also available per backend, e.g. opentelemetry-akafka, opentelemetry-mongodb, opentelemetry-fastapi)
  • test-akafka, test-mongodb, test-s3, test-redis, test-vault: testing utils for the respective backend (test is a union of all of them)
  • all: a union of all the above

Contributing

Contributions are welcome! hexkit is developed in the GHGA monorepo under libs/hexkit, together with the services that build on it. Please see the contribution guide for how to set up the development environment and build the documentation locally.

Credits

The hexkit library is developed and maintained by the developer team of GHGA. We would especially like to thank its original author, Kersten Breuer, who came up with the idea for the library and designed and coded its first versions.

License

hexkit is free to use and modify according to the Apache 2.0 License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hexkit-9.0.1.tar.gz (117.9 kB view details)

Uploaded Source

Built Distribution

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

hexkit-9.0.1-py3-none-any.whl (174.1 kB view details)

Uploaded Python 3

File details

Details for the file hexkit-9.0.1.tar.gz.

File metadata

  • Download URL: hexkit-9.0.1.tar.gz
  • Upload date:
  • Size: 117.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for hexkit-9.0.1.tar.gz
Algorithm Hash digest
SHA256 08ddc4d4ba249e68c65f517777cd0134885401477e4e59ac627f0825a33bfa09
MD5 a7cec13f58b886e5842fa7c07cfd8211
BLAKE2b-256 69bf72de73d466cd603ca1ef54bafa3c32419db2a60c576c9f9c5096518ae646

See more details on using hashes here.

File details

Details for the file hexkit-9.0.1-py3-none-any.whl.

File metadata

  • Download URL: hexkit-9.0.1-py3-none-any.whl
  • Upload date:
  • Size: 174.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for hexkit-9.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a3dbbdf0e8cd20576dca5dba77a62ac465c1fb788fac95651e7d0c9c135ce477
MD5 e957f8ef599c228c7b03d8500df8aea6
BLAKE2b-256 e35c2596f3860f69e34418ca8fa8e528a3d40f10843a51f891cabd1eb902132b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

9.0.1 This release

2 files

9.0.0

2 files

8.6.0

2 files

8.5.0

2 files

8.4.1

2 files

8.4.0

2 files

8.3.0

2 files

8.2.1

2 files

8.2.0

2 files

8.1.0

2 files

8.0.0

2 files

7.3.0

2 files

7.2.1

2 files

7.2.0

2 files

7.1.0

2 files

7.0.0

2 files

6.0.0

2 files

5.4.1

2 files

5.4.0

2 files

5.3.0

2 files

5.2.0

2 files

5.1.1

2 files

5.1.0

2 files

5.0.0

2 files

4.6.2

2 files

4.6.1

2 files

4.6.0

2 files

4.5.0

2 files

4.4.0

2 files

4.3.1

2 files

4.3.0

2 files

4.2.0

2 files

4.1.1

2 files

4.1.0

2 files

4.0.0

2 files

3.8.2

2 files

3.8.1

2 files

3.8.0

2 files

3.7.0

2 files

3.6.0

2 files

3.5.0

2 files

3.4.0

2 files

3.3.0

2 files

3.2.2

2 files

3.2.1

2 files

3.2.0

2 files

3.1.0

2 files

3.0.2

2 files

3.0.1

2 files

3.0.0

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.11.1

2 files

0.11.0

2 files

0.10.2

2 files

0.10.1

2 files

0.10.0

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.1

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page