Skip to main content

The CQRS and Event Sourcing framework for Python

Project description

# Kant Framework
[![Build Status](](
[![PyPI Package latest release](](
[![Supported versions](](
[![Supported implementations](](

A CQRS and Event Sourcing framework, safe for humans.

## Feature Support

* Event Store
* Optimistic concurrency control
* JSON serialization
* SQLAlchemy Projections
* Snapshots **[IN PROGRESS]**

Kant officially supports Python 3.5-3.6.

## Getting started

Create declarative events

from kant import events

class BankAccountCreated(events.Event):
id = events.CUIDField(primary_key=True)
owner = events.CharField()

class DepositPerformed(events.Event):
amount = events.DecimalField()

Create aggregate to apply events

from kant import aggregates

class BankAccount(aggregates.Aggregate):
id = aggregates.CUIDField()
owner = aggregates.CharField()
balance = aggregates.DecimalField()

def apply_bank_account_created(self, event): =
self.owner = event.owner
self.balance = 0

def apply_deposit_performed(self, event):
self.balance += event.amount

Now, save the events

from kant.eventstore import connect

await connect(user='user', password='user', database='database')

# create event store for bank_account

# create events
bank_account_created = BankAccountCreated(
owner='John Doe',
deposit_performed = DepositPerformed(

bank_account = BankAccount()
bank_account.dispatch([bank_account_created, deposit_performed])

stored_bank_account = BankAccount.objects.get(123)

## Installing
To install Kant, simply use [pipenv]( (or pip)

$ pipenv install kant

## Contributing

Please, read the contribute guide [CONTRIBUTING](

Project details

Download files

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

Files for kant, version 2.1.0
Filename, size File type Python version Upload date Hashes
Filename, size kant-2.1.0.tar.gz (9.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page