Python CQRS Core Documentation
Welcome to the Python CQRS Core documentation!
Quick Links
Getting Started
- Usage Guide - Commands, queries, and examples
- Why Use BaseQuery/BaseCommand? - Benefits and use cases
Integration Guides
- Observability Integration - OpenTelemetry, Sentry, Prometheus
Reference
- API Reference - Complete API documentation
What is Python CQRS Core?
CQRS (Command Query Responsibility Segregation) interfaces and base classes with built-in tracing and audit support for Python applications.
Installation
pip install python-cqrs-core
Key Features
- Command/Query Separation: Type-safe CQRS pattern implementation
- Built-in Observability: Automatic request IDs, correlation IDs, audit fields
- Immutability: Frozen commands/queries prevent tampering
- Pagination: Built-in pagination support for queries
- Type Safety: Full generic type support with type hints
- Integration-Ready: Works seamlessly with OpenTelemetry, Sentry, Prometheus
Quick Example
from python_cqrs_core import BaseCommand, ICommandHandler
class CreateUserCommand(BaseCommand):
name: str
email: str
class CreateUserHandler(ICommandHandler[CreateUserCommand, int]):
async def handle(self, command: CreateUserCommand) -> int:
# Automatic tracing fields available:
logger.info(
f"[{command.request_id}] Creating user {command.email} "
f"requested by {command.requested_by}"
)
user_id = await self.user_repository.create(
name=command.name,
email=command.email
)
return user_id
Documentation Structure
Usage Guide
Practical examples and best practices:
- Commands and command handlers
- Queries and query handlers
- Paginated queries
- Tracing fields (request_id, correlation_id, requested_by, requested_at)
- Complete examples with logging and monitoring
Why Use BaseQuery/BaseCommand?
Learn about the benefits of using BaseQuery and BaseCommand over plain Pydantic models:
- Zero-effort observability
- Production debugging
- Distributed tracing
- Audit trail for compliance
- Performance monitoring
- When to use vs plain BaseModel
Observability Integration
Comprehensive guide to integrating with modern observability tools:
- OpenTelemetry integration patterns
- Sentry error tracking with business context
- Prometheus metrics with domain fields
- Audit trail for compliance (SOC 2, HIPAA, PCI DSS)
- Real-world examples and best practices
API Reference
Complete API documentation:
- Interfaces:
ICommand,ICommandHandler,IQuery,IQueryHandler - Base Classes:
BaseCommand,BaseQuery,PaginatedQuery - Type hints and generics
- Immutability guarantees
Dependencies
pydantic>=2.0.0
License
MIT
Metadata
Release files for python-cqrs-core 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_cqrs_core-0.1.0.tar.gz | 6.5 kB | Without provenance | Details for python_cqrs_core-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_cqrs_core-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for python_cqrs_core-0.1.0-py3-none-any.whl |
Total release size: 12.6 kB
Release files / python_cqrs_core-0.1.0.tar.gz
| Download URL | python_cqrs_core-0.1.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
63f38c95212d66d3a05217b55baca0dc6ddade74f7daf8dd7818a52b5a98fb3e
|
|
BLAKE2b-256 checksum How to use checksums |
ecc3fd52bb5927d820fd877adb680233bb2728b7a310050bdca7bbe25eb58c93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Release files / python_cqrs_core-0.1.0-py3-none-any.whl
| Download URL | python_cqrs_core-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
531758b9b2c3aee110bf3abe620855803bba8e9e31403973b6019fd19d1ac084
|
|
BLAKE2b-256 checksum How to use checksums |
5e01fa2ca038ca7c2ee6ae86aa5afc8408814f6677a12dbb5a673a0f3fa4150b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Security for python-cqrs-core 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.