Skip to main content

PyPI version shields.io PyPI pyversions tests Coverage Status 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! 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

This repository 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-8.5.0.tar.gz (116.1 kB view details)

Uploaded Source

Built Distribution

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

hexkit-8.5.0-py3-none-any.whl (170.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hexkit-8.5.0.tar.gz
  • Upload date:
  • Size: 116.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hexkit-8.5.0.tar.gz
Algorithm Hash digest
SHA256 5d781a01e11d9737b076bc4a1d24b19f1ad45c879eae141fdc8258b8feea8e3c
MD5 5ee065a8065a3f4cee0f21ad11890038
BLAKE2b-256 3615630a1df8d905680dac5ecb4608568ce7a20e2e2ad2b60e75c1837cd3a75b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hexkit-8.5.0-py3-none-any.whl
  • Upload date:
  • Size: 170.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hexkit-8.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 010effde769416dafc5782383772310f056370f9408b5435e66140109e93f6ab
MD5 ae48dea2cd124ab4291b7c8e5f2ae271
BLAKE2b-256 988d295e6b7fe3ab9988a7d8964c37224307cdbde473fb1f2fa3464eea5800ef

See more details on using hashes here.

Release history Release notifications | RSS feed

9.0.1

2 files

9.0.0

2 files

8.6.0

2 files

This release

8.5.0 This release

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