A Python SDK for backend systems development @midil.io
Project description
MIDIL — Managed Interface for Data, Integration & Logic
Backend infrastructure, as a Python SDK.
MIDIL gives distributed backend systems a shared foundation — auth, eventing, HTTP, and API conventions — so teams spend less time rebuilding the same plumbing across every service.
Install
pip install pymidil
MIDIL is modular. Install only what your service needs:
| Extra | Installs | Use when you need |
|---|---|---|
pymidil[auth] |
httpx, pyjwt | Cognito auth, JWT verification, HTTP client |
pymidil[web] |
fastapi, starlette, uvicorn | REST APIs, middleware, pagination |
pymidil[aws] |
aioboto3 | SQS consumers, EventBridge scheduling |
pymidil[redis] |
redis | Redis-backed event streaming |
pymidil[mongodb] |
pymongo | MongoDB cursor pagination |
pymidil[cli] |
click, rich, cookiecutter | Project scaffolding and service launcher |
pymidil[full] |
everything | — |
Requires Python 3.12+.
What's included
Auth
Outbound machine-to-machine auth and inbound JWT verification, with a pluggable interface so you're not locked into any one provider.
from pymidil.auth.cognito import CognitoClientCredentialsAuthenticator, CognitoJWTAuthorizer
# Outbound — get a token for service-to-service calls
auth = CognitoClientCredentialsAuthenticator(
client_id="...",
client_secret="...",
cognito_domain="your-domain.auth.region.amazoncognito.com",
)
headers = await auth.get_headers() # {"Authorization": "Bearer ..."}
# Inbound — verify tokens from incoming requests
authorizer = CognitoJWTAuthorizer(user_pool_id="...", region="us-east-1")
claims = await authorizer.verify(token)
Event system
A transport-agnostic event bus. Swap between SQS, Redis, or webhooks through config — your handler code stays the same.
from pymidil.event.event_bus import EventBus
from pymidil.event.subscriber.base import EventSubscriber
from pymidil.event.message import Message
class OrderPlacedHandler(EventSubscriber):
async def handle(self, event: Message) -> None:
...
async def on_error(self, event: Message, error: Exception) -> None:
...
bus = EventBus()
bus.subscribe(OrderPlacedHandler())
await bus.publish({"order_id": "abc-123"})
await bus.start()
Transport is configured through your service settings — no code change needed to switch from Redis to SQS in production.
HTTP client
An HTTPX-based client with built-in retry, exponential backoff, and first-class auth integration.
from pymidil.http_client import HttpClient
client = HttpClient(auth_client=auth, base_url="https://api.example.com")
response = await client.send_request("POST", "/orders", data={...})
FastAPI extensions
Drop-in middleware and dependencies for auth and JSON:API-compliant responses.
from fastapi import FastAPI, Depends
from pymidil.midilapi.middleware.auth_middleware import CognitoAuthMiddleware
from pymidil.midilapi.dependencies.jsonapi import parse_sort, parse_include
app = FastAPI()
app.add_middleware(CognitoAuthMiddleware)
@app.get("/orders")
async def list_orders(sort=Depends(parse_sort), include=Depends(parse_include)):
...
JSON:API
Build spec-compliant API documents without boilerplate.
from pymidil.jsonapi import Document, ResourceObject
doc = Document(
data=ResourceObject(
id="1",
type="orders",
attributes={"status": "placed", "total": 99.00},
)
)
CLI
Scaffold and run services from the terminal.
midil init # create a new service from a template
midil launch # start the service with uvicorn
midil version # show the installed SDK version
Design principles
- Async-first. Every component is built for
asyncio— no sync wrappers. - Opt-in by default. Nothing is installed you didn't ask for.
- Interface-driven. Auth providers, event subscribers, retry strategies — all are abstract base classes you can swap or extend.
- Convention over configuration. Sane defaults, with escape hatches where it matters.
License
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 pymidil-0.1.0.tar.gz.
File metadata
- Download URL: pymidil-0.1.0.tar.gz
- Upload date:
- Size: 65.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11df6dbac8096654a9b8d51ea1fb31e4ad70f5407e86f88b996a0c32f8244439
|
|
| MD5 |
dce95b45bc143d6565b8310f0b4a53e4
|
|
| BLAKE2b-256 |
87cc0a099728034f91f95009b1404b67c73de5bc286368991c4966d522d31378
|
Provenance
The following attestation bundles were made for pymidil-0.1.0.tar.gz:
Publisher:
release.yml on chael-ai/pymidil
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymidil-0.1.0.tar.gz -
Subject digest:
11df6dbac8096654a9b8d51ea1fb31e4ad70f5407e86f88b996a0c32f8244439 - Sigstore transparency entry: 1902571475
- Sigstore integration time:
-
Permalink:
chael-ai/pymidil@df7f0c720e48082da865d9321c048de192ba7ca0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/chael-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df7f0c720e48082da865d9321c048de192ba7ca0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pymidil-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pymidil-0.1.0-py3-none-any.whl
- Upload date:
- Size: 104.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51b28fda7cfd7bfa1a7428514552b88746efd47db7bbdf43e6b6c1fb8101899c
|
|
| MD5 |
7d7796fab4f6194d9b434dc21f67ba19
|
|
| BLAKE2b-256 |
bb403d437faeb21196b166bc63872365d56971276c457d2f9e9f0c0a017fdc68
|
Provenance
The following attestation bundles were made for pymidil-0.1.0-py3-none-any.whl:
Publisher:
release.yml on chael-ai/pymidil
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymidil-0.1.0-py3-none-any.whl -
Subject digest:
51b28fda7cfd7bfa1a7428514552b88746efd47db7bbdf43e6b6c1fb8101899c - Sigstore transparency entry: 1902571646
- Sigstore integration time:
-
Permalink:
chael-ai/pymidil@df7f0c720e48082da865d9321c048de192ba7ca0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/chael-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@df7f0c720e48082da865d9321c048de192ba7ca0 -
Trigger Event:
release
-
Statement type: