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.

Metadata

Release files for hexkit 9.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hexkit 9.0.3
File Size Uploaded
hexkit-9.0.3.tar.gz 118.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hexkit 9.0.3
File Interpreter ABI Platform
hexkit-9.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 293.1 kB

Release files / hexkit-9.0.3.tar.gz

Download URL hexkit-9.0.3.tar.gz
Size 118.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a391235f4865cd3d803ad9e5a9e1e727cab64b81c7ef2e05b69d5ae5ec9c17ea
BLAKE2b-256 checksum
How to use checksums
ce083c848ffc9f6b743d44125167d32da17dc8df256926eb0e04d840dd4818f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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}

Release files / hexkit-9.0.3-py3-none-any.whl

Download URL hexkit-9.0.3-py3-none-any.whl
Size 174.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e4c802e03eba5525e9bb9274e42efa975f389d5ba3b2198bdd24b5e75510ad5
BLAKE2b-256 checksum
How to use checksums
a5b53b0401efe8b01b150bd909ad9d9831b381f67b07310831d19acf69a7f847
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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}

Release history Release notifications | RSS feed

This release

9.0.3 This release

2 release files

9.0.1

2 release files

9.0.0

2 release files

8.6.0

2 release files

8.5.0

2 release files

8.4.1

2 release files

8.4.0

2 release files

8.3.0

2 release files

8.2.1

2 release files

8.2.0

2 release files

8.1.0

2 release files

8.0.0

2 release files

7.3.0

2 release files

7.2.1

2 release files

7.2.0

2 release files

7.1.0

2 release files

7.0.0

2 release files

6.0.0

2 release files

5.4.1

2 release files

5.4.0

2 release files

5.3.0

2 release files

5.2.0

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.6.2

2 release files

4.6.1

2 release files

4.6.0

2 release files

4.5.0

2 release files

4.4.0

2 release files

4.3.1

2 release files

4.3.0

2 release files

4.2.0

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.8.2

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.11.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.0.0

2 release 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