Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Indroic/HexCore/llms.txt

Use this file to discover all available pages before exploring further.

HexCore is a batteries-included Python SDK for teams building applications with hexagonal architecture and Domain-Driven Design. It provides the base classes, ports, and infrastructure adapters you need — so you can focus on your domain logic instead of scaffolding.

Quickstart

Build a working CQRS app with HexCore in under 10 minutes.

Installation

Install HexCore with pip, with only the extras you need.

Core Concepts

Understand hexagonal architecture, DDD, and CQRS patterns.

API Reference

Complete reference for every public class and interface.

What HexCore Provides

HexCore is organized around the three layers of hexagonal architecture — domain, application, and infrastructure — and ships ready-to-use implementations for each.

Domain Abstractions

BaseEntity, IBaseRepository, IUnitOfWork, DomainEvent, and BaseDomainService give you a consistent, DDD-idiomatic domain model.

CQRS Buses

In-memory Command, Query, and Event buses with a middleware pipeline, handler registry, and smart routing to background workers.

Infrastructure Adapters

Drop-in SQLAlchemy and Beanie ODM repositories, Redis/PostgreSQL/RabbitMQ event buses, distributed locks, and cache backends.

Get Up and Running

1

Install HexCore

Install the core package plus any optional extras for your stack.
pip install hexcore[sql,redis]
2

Scaffold a project

Use the built-in CLI to create a fully wired project structure in seconds.
hexcore init my_app --template hexagonal
3

Define your domain

Subclass BaseEntity and IBaseRepository to model your business domain.
from hexcore.domain.base import BaseEntity
from hexcore.domain.repositories import IBaseRepository

class Order(BaseEntity):
    customer_id: str
    total: float
4

Wire up CQRS

Register command and query handlers, then dispatch through the bus.
from hexcore.application.cqrs.registry import HandlerRegistry
from hexcore.application.cqrs.in_memory_buses import InMemoryCommandBus

registry = HandlerRegistry()
registry.register_command_handler(CreateOrderCommand, CreateOrderHandler())
bus = InMemoryCommandBus(registry=registry)
await bus.dispatch(CreateOrderCommand(customer_id="u1", total=99.0))

Key Features

Smart Routing

Decorate commands and event handlers with @background_command or @background_handler to transparently offload work to Celery or Procrastinate — no bus refactoring required.

Pluggable Event Buses

Swap between in-memory, Redis Streams, PostgreSQL LISTEN/NOTIFY, and RabbitMQ event buses without changing your domain code.

Dynamic Scheduler

Run database-driven cron jobs that can be activated, deactivated, or rescheduled at runtime — with distributed locking to prevent duplicate execution.

CLI Scaffolding

Bootstrap hexagonal or vertical-slice projects, generate domain modules, and run migrations — all from the hexcore CLI.

Build docs developers (and LLMs) love