Enterprise Foundation Framework - Modern Python 3.13 + Clean Architecture
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flext_core-0.12.0.dev0.tar.gz.
File metadata
- Download URL: flext_core-0.12.0.dev0.tar.gz
- Upload date:
- Size: 361.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
090838d6f4ef84027fad93f54cfa9a8d270f69c14148428f427f101b0f8fcc2c
|
|
| MD5 |
d145f5200176f20b05ad7b940ec7d56d
|
|
| BLAKE2b-256 |
fafe2318cae25afee39547a9ee8b4595aa3479ab25cfcb905ef1415b4026ad84
|
Provenance
The following attestation bundles were made for flext_core-0.12.0.dev0.tar.gz:
Publisher:
workflow.yaml on flext-sh/flext-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flext_core-0.12.0.dev0.tar.gz -
Subject digest:
090838d6f4ef84027fad93f54cfa9a8d270f69c14148428f427f101b0f8fcc2c - Sigstore transparency entry: 983846108
- Sigstore integration time:
-
Permalink:
flext-sh/flext-core@d33dbc839a189f75d4642b22dcc961ece5311cba -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/flext-sh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@d33dbc839a189f75d4642b22dcc961ece5311cba -
Trigger Event:
push
-
Statement type:
File details
Details for the file flext_core-0.12.0.dev0-py3-none-any.whl.
File metadata
- Download URL: flext_core-0.12.0.dev0-py3-none-any.whl
- Upload date:
- Size: 402.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27c4012f8e1a1aa3587e257a737dfd5fe342e953dc3b7878ba8d4154f9f1034a
|
|
| MD5 |
987880a2278440c57650531e0c0d5ff9
|
|
| BLAKE2b-256 |
10f2507a1586ffe0dd38fa08085a61ffe3fbb504cab97b3989468a0f7fa59f8e
|
Provenance
The following attestation bundles were made for flext_core-0.12.0.dev0-py3-none-any.whl:
Publisher:
workflow.yaml on flext-sh/flext-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flext_core-0.12.0.dev0-py3-none-any.whl -
Subject digest:
27c4012f8e1a1aa3587e257a737dfd5fe342e953dc3b7878ba8d4154f9f1034a - Sigstore transparency entry: 983846121
- Sigstore integration time:
-
Permalink:
flext-sh/flext-core@d33dbc839a189f75d4642b22dcc961ece5311cba -
Branch / Tag:
refs/tags/v0.11.0 - Owner: https://github.com/flext-sh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yaml@d33dbc839a189f75d4642b22dcc961ece5311cba -
Trigger Event:
push
-
Statement type: