Genro ASGI Documentation
Genro ASGI is a minimal ASGI server and application toolkit for building
web services. It provides everything needed to run a production server:
routing, authentication, sessions, middleware, static files, WebSocket,
and MCP support — configured by a Python config.py builder recipe.
What it does
Serves web applications mounted on URL prefixes (
/api/,/shop/, etc.)Authenticates requests via bearer tokens, basic auth, or JWT — with O(1) lookup
Manages sessions with in-memory store, cookies, and user avatars (identity + Bag data)
Applies middleware globally (CORS, errors, auth) and per-app (session, cache)
Routes requests via
genro-routesdecorator-based router with auth tag filteringServes static files with
StaticRouterand hierarchical resource loadingHandles WebSocket with the WSX extension protocol for structured messaging
Exposes MCP endpoints via
McpApplicationfor AI tool integrationConfigures plugins at runtime via the
plugin_configweb UI (mounted under/_sys/plugin_config/)
Architecture
The server is an instance with its own state — no global variables. Every component (apps, middleware, sessions) is an isolated instance connected via semantic parent-child references.
Request flow:
uvicorn → AsgiServer → global middleware (errors → cors → auth)
→ Dispatcher (demultiplex on first path segment)
→ app → per-app middleware (session, cache, ...)
→ handle_request → handler(**query) → Response → ASGI send
Installation
pip install genro-asgi # core
pip install genro-asgi[json] # + orjson for fast JSON
Quick Start
The server boots from a config.py whose ServerConfiguration (a subclass
of AsgiConfigBuilder) is rendered onto it.
from genro_asgi import AsgiServer
server = AsgiServer("config.py") # the config.py directory is the server dir
server.run() # starts uvicorn on the configured host/port
# config.py
from genro_asgi.config import AsgiConfigBuilder
from shop_app import Application as Shop
class ServerConfiguration(AsgiConfigBuilder):
def main(self, root):
root.server(host="127.0.0.1", port=8000)
root.middleware(cors=True, auth=True)
apps = root.applications(default="shop")
apps.application(code="shop", app_class=Shop)
Contents
Architecture
- genro-asgi Architecture Overview
- AsgiServer
- Request System
- Response System
- Executors
- Lifespan
- WSX Protocol
- Streaming & Protections
- Overview
- Workload Separation (implemented)
- HTTP responses today: single-body
Response(implemented) - Streaming Protections (roadmap — NOT implemented)
- DoS Protections (roadmap — NOT implemented)
- StreamingResponse (roadmap — NOT implemented)
- FileResponse (roadmap — NOT implemented)
- WebSocket Streaming (implemented)
- Architecture Diagram
- Benefits
- Routing
- 09 - Authentication & Context System
License
Copyright 2025-2026 Softwell S.r.l.
Licensed under the Apache License, Version 2.0.