Metadata-Version: 2.4
Name: kernable-sdk
Version: 0.3.0
Summary: kernable SDK for Python: event-sourced business logic in Python on the kernable kernel
Author: kernable
License-Expression: MIT
Project-URL: Homepage, https://kernable.com
Project-URL: Documentation, https://kernable.com/docs/
Project-URL: Repository, https://github.com/kernable/kernable
Project-URL: Issues, https://github.com/kernable/kernable/issues
Keywords: event-sourcing,cqrs,grpc,kernable,sdk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: grpcio>=1.85
Requires-Dist: protobuf<8,>=7.35.1
Requires-Dist: cryptography>=43
Dynamic: license-file

# kernable-sdk

Event sourcing and CQRS with a Rust kernel and business logic in any language. This is the
Python SDK: aggregates, read models, reactors, middleware and business processes in Python, run by
the [kernable](https://github.com/kernable/kernable) kernel. The TypeScript, Python and Rust SDKs
share one API.

```sh
pip install kernable-sdk        # Python 3.10 or newer; import it as `kernable`
```

Start a kernel (macOS and Linux):

```sh
curl -fsSL https://kernable.com/install.sh | sh
kernable start --dev            # a kernel on 127.0.0.1:7233, its UI on :7234, keys in this directory
```

A worker that decides on a cart's commands:

```python
from kernable import Kernable, Rejected, domain

cart = domain("shop").aggregate("cart", {"items": 0})


@cart.apply("ItemAdded")
def _(state, data):
    state["items"] += data["qty"]


@cart.command("AddItem")
def _(state, data):
    if data["qty"] < 1:
        raise Rejected("At least one")
    return [{"type": "ItemAdded", "data": data}]


Kernable(key="app.key").worker(cart).run()
```

The [getting-started guide](https://kernable.com/docs/tutorial/getting-started) goes on from
here: a read model, a query that reads its own writes, the same in the other languages. Then
[build a shop](https://kernable.com/docs/tutorial/shop/) in ten parts, and the
[Python reference](https://kernable.com/docs/reference/sdk-python).

`kernable-sdk add kit` copies the kits (tenancy, accounts, identities, groups, invitations and
authorization) into your project as code you own: see [Kits](https://kernable.com/docs/kits/).

kernable is before 1.0: the protocol and the APIs may still change between 0.x releases. MIT
license.

## Developing this SDK

From the repository root, `make py` makes the venv and generates the gRPC stubs in
`kernable/v1/` (not checked in); `make test` and `make check-sdks` run the tests.
