A minimal, stable ASGI foundation - framework-agnostic toolkit for building high-performance web services
Project description
Genro ASGI
A minimal ASGI server and application toolkit for building web services with routing, authentication, sessions, and middleware — configurable via config.yaml.
What it does
- Serves web applications mounted on URL prefixes (
/api/,/shop/, etc.) with config-driven loading - Authenticates requests via bearer tokens, basic auth, or JWT — O(1) credential lookup, lazy auth for zero overhead on unprotected routes
- Manages sessions with in-memory store, cookie-based reconnection, and user avatars (identity + tags + extensible Bag data)
- Applies middleware at two levels: global (CORS, errors, auth) and per-app (session, cache) with independent chains
- Routes requests via
genro-routeswith decorator-based routing and auth tag filtering - Serves static files with
StaticRouterand hierarchical resource loading with fallback chains - Handles WebSocket with the WSX extension protocol for structured request/response messaging
- Exposes MCP endpoints via
McpApplicationfor AI tool integration (Streamable HTTP transport) - Configures plugins at runtime via the
/_plugin_config/web UI with persistence to JSON
Installation
pip install genro-asgi # core
pip install genro-asgi[json] # + orjson for fast JSON
pip install genro-asgi[dev] # + test/lint tools
Quick Start
from genro_asgi import AsgiServer
server = AsgiServer(server_dir=".")
server.run() # Starts uvicorn, reads config.yaml
config.yaml:
server:
host: "127.0.0.1"
port: 8000
middleware:
cors: on
auth: on
auth_middleware:
bearer:
api_key:
token: "sk_live_abc123"
tags: "api,read"
apps:
shop:
module: "shop_app:Application"
middleware:
session: on
Architecture at a glance
The server is an instance with its own state — no global variables. Every component is an isolated instance connected via semantic parent-child references.
Request flow:
uvicorn → AsgiServer → global middleware (errors → cors → auth)
→ Dispatcher → per-app middleware (session, cache, ...)
→ handler(**query) → Response → ASGI send
Core components
| Component | Purpose |
|---|---|
| AsgiServer | ASGI entry point, loads config, mounts apps, composes BasicAuthMixin |
| Dispatcher | Resolves handler via router, applies per-app middleware chains |
| BasicAuthMixin | Server-side auth: server.authenticate(scope), server.verify_credentials() |
| SessionMiddleware | Per-app session lifecycle: cookie extraction, reconnection, Set-Cookie |
| Session / Avatar | Session with meta + Bag data + Avatar (identity, tags, extensible data) |
| MemorySessionStore | In-memory session store with dump/restore for persistence |
| HandlerExecutor | ASGI app executing pre-resolved nodes in per-app chains |
| AsgiApplication | Base class for mountable applications |
| McpApplication | MCP Streamable HTTP transport for AI tools |
| StaticRouter | Filesystem-backed static file serving |
| LocalStorage | Filesystem storage with mount system |
Middleware
| Middleware | Order | Default | Scope |
|---|---|---|---|
| ErrorMiddleware | 100 | on | global |
| CORSMiddleware | 300 | off | global |
| AuthMiddleware | 400 | off | global |
| SessionMiddleware | 450 | off | per-app |
| CacheMiddleware | 900 | off | per-app |
| CompressionMiddleware | 900 | off | global |
| LoggingMiddleware | 200 | off | global |
Documentation
Full documentation: https://genro-asgi.readthedocs.io
Development
git clone https://github.com/genropy/genro-asgi.git
cd genro-asgi
pip install -e .[dev]
pytest # run tests
ruff check . # lint
mypy src # type check
License
Copyright 2025-2026 Softwell S.r.l.
Licensed under the Apache License 2.0. See NOTICE for additional attribution.
Links
- GitHub: https://github.com/genropy/genro-asgi
- PyPI: https://pypi.org/project/genro-asgi/
- Documentation: https://genro-asgi.readthedocs.io
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 genro_asgi-0.5.1.dev1.tar.gz.
File metadata
- Download URL: genro_asgi-0.5.1.dev1.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46d146c1ec82c14269424c887118fd08114a47accc86c39717ba93175d09b906
|
|
| MD5 |
b3fc5a6973abf2fe95f94eb3512adfed
|
|
| BLAKE2b-256 |
9b8acfa1fb02d205768565fcc4343d9f004c1f4c91f89788204a56c7b04b9364
|
Provenance
The following attestation bundles were made for genro_asgi-0.5.1.dev1.tar.gz:
Publisher:
publish.yml on genropy/genro-asgi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genro_asgi-0.5.1.dev1.tar.gz -
Subject digest:
46d146c1ec82c14269424c887118fd08114a47accc86c39717ba93175d09b906 - Sigstore transparency entry: 1205578094
- Sigstore integration time:
-
Permalink:
genropy/genro-asgi@2132cd0c280e233a72253ec043b96ac5f272cf76 -
Branch / Tag:
refs/tags/v0.5.1.dev1 - Owner: https://github.com/genropy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2132cd0c280e233a72253ec043b96ac5f272cf76 -
Trigger Event:
release
-
Statement type:
File details
Details for the file genro_asgi-0.5.1.dev1-py3-none-any.whl.
File metadata
- Download URL: genro_asgi-0.5.1.dev1-py3-none-any.whl
- Upload date:
- Size: 173.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77fb1a1d6805d09a41fa551e717bec4773364bc909081f395c2b45721ca32723
|
|
| MD5 |
20e4b3b530e2362cc38dad95299a65c3
|
|
| BLAKE2b-256 |
bb921b36a848b1cda4fa986e419ff51fa90a355807f72469b86f368cba41a8e9
|
Provenance
The following attestation bundles were made for genro_asgi-0.5.1.dev1-py3-none-any.whl:
Publisher:
publish.yml on genropy/genro-asgi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genro_asgi-0.5.1.dev1-py3-none-any.whl -
Subject digest:
77fb1a1d6805d09a41fa551e717bec4773364bc909081f395c2b45721ca32723 - Sigstore transparency entry: 1205578104
- Sigstore integration time:
-
Permalink:
genropy/genro-asgi@2132cd0c280e233a72253ec043b96ac5f272cf76 -
Branch / Tag:
refs/tags/v0.5.1.dev1 - Owner: https://github.com/genropy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2132cd0c280e233a72253ec043b96ac5f272cf76 -
Trigger Event:
release
-
Statement type: