Skip to main content

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.

PyPI version Python Support License Documentation

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-routes with decorator-based routing and auth tag filtering
  • Serves static files with StaticRouter and hierarchical resource loading with fallback chains
  • Handles WebSocket with the WSX extension protocol for structured request/response messaging
  • Exposes MCP endpoints via McpApplication for 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genro_asgi-0.5.1.dev1.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

genro_asgi-0.5.1.dev1-py3-none-any.whl (173.0 kB view details)

Uploaded Python 3

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

Hashes for genro_asgi-0.5.1.dev1.tar.gz
Algorithm Hash digest
SHA256 46d146c1ec82c14269424c887118fd08114a47accc86c39717ba93175d09b906
MD5 b3fc5a6973abf2fe95f94eb3512adfed
BLAKE2b-256 9b8acfa1fb02d205768565fcc4343d9f004c1f4c91f89788204a56c7b04b9364

See more details on using hashes here.

Provenance

The following attestation bundles were made for genro_asgi-0.5.1.dev1.tar.gz:

Publisher: publish.yml on genropy/genro-asgi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genro_asgi-0.5.1.dev1-py3-none-any.whl.

File metadata

File hashes

Hashes for genro_asgi-0.5.1.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 77fb1a1d6805d09a41fa551e717bec4773364bc909081f395c2b45721ca32723
MD5 20e4b3b530e2362cc38dad95299a65c3
BLAKE2b-256 bb921b36a848b1cda4fa986e419ff51fa90a355807f72469b86f368cba41a8e9

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page