Giter Club home page Giter Club logo

kant's Introduction

Kant Framework

WARNING: This repository is unmaintained

A CQRS and Event Sourcing framework, safe for humans.

Build Status codecov.io PyPI Package latest release Supported versions Supported implementations Join the chat at https://gitter.im/kant-es/Lobby Code style: black

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.id = event.id
        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
conn.create_keyspace('bank_account')

# create events
bank_account_created = BankAccountCreated(
    id=123,
    owner='John Doe',
)
deposit_performed = DepositPerformed(
    amount=20,
)

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

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.

kant's People

Contributors

patrickporto avatar carlos-novak avatar

Stargazers

Arona GUEYE avatar  avatar Ilya Khramtsov avatar shark99 avatar Tarlan Isaev avatar Durval Carvalho avatar Kamande Edwin avatar Georvic Tur avatar Gláuber Brennon avatar Darian Moody avatar Max Sysoev avatar Zy avatar  avatar Max Khrichtchatyi avatar Kristof Leroux avatar David Jiménez avatar Tanapol Prucksakorn avatar Federico Biccheddu avatar ulopong avatar Friedrich avatar Eugene Duvenage avatar Brian Richter avatar Fabricio Aguiar avatar Filipe Mondaini avatar Olmo Maldonado avatar Robson Roberto Souza Peixoto avatar  avatar Raissa Ferreira avatar Roberto Pereira da Costa avatar bianca rosa avatar Stefane Fermigier avatar

Watchers

James Cloos avatar Amidamaru avatar Thijs M avatar  avatar

kant's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.