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-9.0.0.tar.gz (118.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-9.0.0-py3-none-any.whl (173.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hexkit-9.0.0.tar.gz
  • Upload date:
  • Size: 118.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hexkit-9.0.0.tar.gz
Algorithm Hash digest
SHA256 1377a5f34f70b7d395eb1395a732bc430265575a966eb5c0c7e81be95b89f222
MD5 a3bf626a2c284c4383ab22eefe532a30
BLAKE2b-256 0d513103f9f4dcd76f78a7b0f7848d25a68633a439c859bb8666cd3d3080084f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hexkit-9.0.0-py3-none-any.whl
  • Upload date:
  • Size: 173.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hexkit-9.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb0db74c4361694d76ef1bac50830390f9413c48a7abe2ac11ad821f58173620
MD5 fad233547963bc64f6fe75d31bc9bcd8
BLAKE2b-256 0888526a87b6f29a4de827b944ef13cd20ff83149da567b1ee1c0c6d4aa7f1bd

See more details on using hashes here.

Release history Release notifications | RSS feed

9.0.1

2 files

This release

9.0.0 This release

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