Skip to main content

Protean

Protean is an opinionated Python framework for building event-driven applications with Domain-Driven Design — aggregates, CQRS, and event sourcing are first-class, and your domain logic stays independent of the database, broker, and API you run it on.

Python Release Build Status Coverage Tests Maintainability

Installation

Protean is available on PyPI:

$ pip install protean

Protean officially supports Python 3.11+.

Quick Start

A command flows to its handler, the aggregate raises an event, and an event handler reacts — all wired by the domain, independent of infrastructure:

from protean import Domain
from protean.fields import Boolean, Identifier, String
from protean.utils.mixins import handle

domain = Domain(name="Publishing")
domain.config["command_processing"] = "sync"
domain.config["event_processing"] = "sync"


@domain.event(part_of="Post")
class PostPublished:
    post_id = Identifier()
    title = String()


@domain.aggregate
class Post:
    title = String(required=True, max_length=200)
    is_published = Boolean(default=False)

    def publish(self):
        self.is_published = True
        self.raise_(PostPublished(post_id=self.id, title=self.title))


@domain.command(part_of="Post")
class PublishPost:
    post_id = Identifier(identifier=True)
    title = String()


@domain.command_handler(part_of="Post")
class PostCommandHandler:
    @handle(PublishPost)
    def publish(self, command):
        post = Post(id=command.post_id, title=command.title)
        post.publish()
        domain.repository_for(Post).add(post)


@domain.event_handler(part_of="Post")
class Notifications:
    @handle(PostPublished)
    def announce(self, event):
        print(f"Published: {event.title}")


domain.init(traverse=False)
with domain.domain_context():
    domain.process(PublishPost(post_id="1", title="Hello, Protean"))

Documentation

Online docs are available at https://docs.proteanhq.com.

Versioning

Protean does not use strict semantic versioning. The promise is: Code that runs warning-free on 1.N runs unmodified on 1.N+1. Every removal is announced by a deprecation warning naming the release it lands in, at least one release ahead, so you can turn "will this upgrade break us?" into a test run. See the versioning policy for the full contract.

Quality

Protean is tested against 5 backing services across 4 Python versions on every commit.

Metric Value
Tests 12,000+ (quality report)
Linting Zero violations (Ruff)
Complexity Avg 3.38 cyclomatic (A grade)
Maintainability A rank (95% of files)
CI Matrix Python 3.11-3.14 x PostgreSQL, Redis, Elasticsearch, MessageDB, MSSQL

See the full Quality Report for details.

Contributing

Note: Protean framework is not associated or related to Protean eGov Technologies or Code for Gov Tech initiatives.

Protean is developed and maintained by a single maintainer. The contributions that help most are bug reports, real-world use cases, and adapter packages built against the public conformance suite.

  • Found a bug or have a use case to share? Open an issue. Clear, reproducible reports are the most valuable contribution you can make, and they are answered as a priority.
  • Planning a non-trivial code change? Open an issue to discuss it first, before investing in a pull request. Unsolicited large PRs may not be merged. Small, obvious fixes are welcome directly.
  • Building an adapter? Adapters live in their own packages, certified against the conformance suite. See the contributing guide.

See CONTRIBUTING.md and the community section for the full picture.

License

Protean is licensed under the Apache License 2.0.

Licensing commitment. The Protean framework core is, and will remain, available under the Apache License 2.0. This is a permanent commitment: the core will not be relicensed to a proprietary or source-available license.

Copyright 2018-2026 Subhash Bhushan C and the Protean contributors.

Download files

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

Source Distribution

protean-0.17.1.tar.gz (4.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

protean-0.17.1-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file protean-0.17.1.tar.gz.

File metadata

  • Download URL: protean-0.17.1.tar.gz
  • Upload date:
  • Size: 4.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for protean-0.17.1.tar.gz
Algorithm Hash digest
SHA256 88e568faffeda8692f0dcb46e52627bddb9525e83c1880eb47ca25e685ef6b70
MD5 6c0fdbd144a70d54173cfc9895665393
BLAKE2b-256 de8db832a50db00d13dbeb288bb312c632572a165ed572f33e7d5324cba43f86

See more details on using hashes here.

Provenance

The following attestation bundles were made for protean-0.17.1.tar.gz:

Publisher: publish.yml on proteanhq/protean

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file protean-0.17.1-py3-none-any.whl.

File metadata

  • Download URL: protean-0.17.1-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for protean-0.17.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f1573bcd582994aa7da06911977f31020bc8199c58a90289113b337bc190a3cb
MD5 9a4bab670f68687b5f4aae666fe9ee71
BLAKE2b-256 ebdd9f36a03c6e3d6152b3cbf31b67d0eb34f9e0f85d8c74cb952b8ba27b139e

See more details on using hashes here.

Provenance

The following attestation bundles were made for protean-0.17.1-py3-none-any.whl:

Publisher: publish.yml on proteanhq/protean

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page