Skip to main content

Build type-safe, event-driven Python apps with zero boilerplate.

Project description

EventModel

Python 3.14+ uv Ruff Pydantic v2 Tests Pytest

Build type-safe, event-driven Python apps with zero boilerplate. Inspired by FastAPI and SQLModel, EventModel turns Pydantic classes into self-routing events. Just type-hint your inputs to subscribe and use return statements to emit. Pure, clean, and heavily typed.

Installation

uv add python-eventmodel

Quick Start

Define your events, type-hint your handlers, and let the framework handle the routing.

from eventmodel import App, EventModel

app = App()
users_app = App()

# 1. Define events with embedded routing metadata
class UserCreated(EventModel, topic="user.events.created"):
    user_id: int
    email: str

class SendWelcomeEmail(EventModel, topic="email.queue.outbound"):
    target_email: str
    body: str

# 2. Write pure domain logic. 
# The input type dictates the subscription topic.
# The return type dictates the emission topic.
@users_app.service()
async def process_new_user(event: UserCreated) -> SendWelcomeEmail:
    print(f"Processing new user: {event.user_id}")
    return SendWelcomeEmail(
        target_email=event.email, 
        body="Welcome!"
    )

app.include(users_app)

Core Concepts

  1. Self-Routing Events: By subclassing EventModel and specifying a topic, your data model intrinsically knows where it belongs on the message broker.
  2. Implicit Subscriptions: Handlers use the @service.service() decorator. The framework reads the type-hint of the input argument to determine which topic to subscribe to.
  3. Implicit Emissions: Handlers return initialized event objects. The framework automatically intercepts these returns and publishes them to their respective topics.
  4. Clean Architecture: Domain functions remain entirely pure. They take an EventModel as input and return an EventModel as output—no broker logic mixed in.
  5. Modular Routing: The framework supports Service instances that can be merged into a master App via app.include().

Project details


Download files

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

Source Distribution

python_eventmodel-0.0.0a1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

python_eventmodel-0.0.0a1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file python_eventmodel-0.0.0a1.tar.gz.

File metadata

  • Download URL: python_eventmodel-0.0.0a1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_eventmodel-0.0.0a1.tar.gz
Algorithm Hash digest
SHA256 07fbd201be5106b85e93a1e845ad704bd72f5b02a945a8afce1240d50e5b6d34
MD5 b29d4fcaefe60231092eea249d806939
BLAKE2b-256 bed455267252447a493fff15003a5d58bf327a7296618bc003670f6f83aa8028

See more details on using hashes here.

File details

Details for the file python_eventmodel-0.0.0a1-py3-none-any.whl.

File metadata

  • Download URL: python_eventmodel-0.0.0a1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_eventmodel-0.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 6663ef55ba12fc7a95ce440c8b93bcb93e8aa36643c664516136a5a5bbec8d8f
MD5 710d39f99f4d915e8b00c2b1de0a84c5
BLAKE2b-256 203a6257f28c6a273dc61bf8cf9fb01bf8d2001ec2b7c9793fd241d04c00e438

See more details on using hashes here.

Supported by

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