This release is a pre-release and may not be stable for production use.
FLEXT-Core
FLEXT-Core is the foundational library for the FLEXT ecosystem, providing a robust set of architectural primitives, patterns, and utilities for building enterprise-grade Python applications. It enforces Railway-Oriented Programming (ROP), Dependency Injection (DI), and Command Query Responsibility Segregation (CQRS) to ensure type safety, scalability, and maintainability.
Reviewed: 2026-02-17 | Version: 0.10.0-dev
Part of the FLEXT ecosystem.
🚀 Key Features
- Railway-Oriented Programming: handling errors as values using
FlextResult[T, E], eliminating unexpected exceptions in business logic. - Dependency Injection: A lightweight, type-safe DI container (
FlextContainer) with scoped services and bridge integration. - CQRS Dispatcher: A strictly typed
FlextDispatcherfor routing commands, queries, and events to their respective handlers. - Domain-Driven Design: Base classes (
FlextModels,FlextService) and mixins for rich domain modeling. - Protocol-Based Architecture: Extensive use of Python
Protocolfor loose coupling and improved testability. - Infrastructure Helpers: Built-in support for structured logging, configuration management, and context propagation.
📦 Installation
Install flext-core using pip:
pip install flext-core
Or with Poetry:
poetry add flext-core
🛠️ Usage
Railway-Oriented Results
Replace exception handling with FlextResult for predictable control flow.
from flext_core import FlextResult as r
def divide(a: int, b: int) -> r[float]:
if b == 0:
return r[float].fail("Division by zero")
return r[float].ok(a / b)
result = divide(10, 2)
if result.is_success:
print(f"Result: {result.unwrap()}")
else:
print(f"Error: {result.error}")
Dependency Injection
Manage your application's dependencies cleanly using FlextContainer and FlextRuntime.
from flext_core import FlextContainer, Provide, inject, FlextService
# 1. Register a service
container = FlextContainer.get_global()
container.register_factory("db_client", lambda: DatabaseClient())
# 2. Inject into functions
@inject
def get_user(user_id: str, db=Provide["db_client"]):
return db.query(user_id)
# 3. Inject into Services
class UserService(FlextService):
def get_user(self, user_id: str):
# Access container directly via self.container
db = self.container.get("db_client").unwrap()
return db.query(user_id)
CQRS Dispatching
Decouple your business logic using the FlextDispatcher.
from dataclasses import dataclass
from flext_core import FlextDispatcher, FlextResult as r
# 1. Define a Command
@dataclass
class CreateUser:
username: str
email: str
# 2. Define a Handler
def handle_create_user(cmd: CreateUser) -> r[str]:
# Business logic here...
return r[str].ok(f"User {cmd.username} created")
# 3. Register and Dispatch
dispatcher = FlextDispatcher()
dispatcher.register_handler(CreateUser, handle_create_user)
result = dispatcher.dispatch(CreateUser("alice", "alice@example.com"))
🏗️ Architecture
FLEXT-Core is designed around Clean Architecture and SOLID principles.
- Protocols First: Interfaces are defined using
Protocolto adhere to the Dependency Inversion Principle. - Layered Structure:
- Runtime: Bridges external libraries and provides the DI surface.
- Container: Manages service lifecycles (Singleton, Factory, Scoped).
- Handlers/Dispatcher: Orchestrates application flow.
🤝 Contributing
Contributions are welcome! Please read our Contributing Guide to get started.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for flext-core 0.12.0.dev0
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 | |
|---|---|---|---|---|
| flext_core-0.12.0.dev0.tar.gz | 361.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flext_core-0.12.0.dev0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 763.8 kB
Release files / flext_core-0.12.0.dev0.tar.gz
| Download URL | flext_core-0.12.0.dev0.tar.gz |
|---|---|
| Size | 361.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
090838d6f4ef84027fad93f54cfa9a8d270f69c14148428f427f101b0f8fcc2c
|
|
BLAKE2b-256 checksum How to use checksums |
fafe2318cae25afee39547a9ee8b4595aa3479ab25cfcb905ef1415b4026ad84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logRelease files / flext_core-0.12.0.dev0-py3-none-any.whl
| Download URL | flext_core-0.12.0.dev0-py3-none-any.whl |
|---|---|
| Size | 402.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27c4012f8e1a1aa3587e257a737dfd5fe342e953dc3b7878ba8d4154f9f1034a
|
|
BLAKE2b-256 checksum How to use checksums |
10f2507a1586ffe0dd38fa08085a61ffe3fbb504cab97b3989468a0f7fa59f8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logSecurity for flext-core 0.12.0.dev0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for flext_core-0.12.0.dev0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logA 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.