# kludex/uvicorn-worker architecture

> Architecture diagram of the GitHub repository kludex/uvicorn-worker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kludex/uvicorn-worker
- Repository: https://github.com/kludex/uvicorn-worker

## Overview

Uvicorn Worker is a small Gunicorn worker-class package that runs ASGI applications using Uvicorn. The main workflow is Gunicorn starting the worker, which builds Uvicorn configuration and serves the application on Gunicorn-provided sockets; a separate subclass selects asyncio and h11 for PyPy-compatible setups. The worker also bridges logging and manages worker signals and notifications. Runtime behavior is shown in the sampled worker source; deployment and the h11 use case are documented in the README.

Main entry points: [`uvicorn_worker/_workers.py`](https://github.com/kludex/uvicorn-worker/blob/main/uvicorn_worker/_workers.py) (Uvicorn worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_gunicorn(("Gunicorn manager"))
node_app(("ASGI application"))
node_worker["Uvicorn worker<br/>[_workers.py]"]
node_h11["H11 worker<br/>[_workers.py]"]
node_config["Uvicorn config"]
node_server["Uvicorn server"]

node_gunicorn -->|"starts worker"| node_worker
node_app -->|"supplies app"| node_worker
node_worker -->|"builds config"| node_config
node_worker -->|"runs server"| node_server
node_h11 -->|"extends worker"| node_worker

click node_worker "https://github.com/kludex/uvicorn-worker/blob/main/uvicorn_worker/_workers.py"
click node_h11 "https://github.com/kludex/uvicorn-worker/blob/main/uvicorn_worker/_workers.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gunicorn,node_app,node_config toneIndigo
class node_worker,node_h11 toneRose
class node_server toneMint
```

## Components

### Other components

- **Gunicorn manager**
- **ASGI application**
- [Uvicorn worker](https://github.com/kludex/uvicorn-worker/blob/main/uvicorn_worker/_workers.py): `uvicorn_worker/_workers.py`
- [H11 worker](https://github.com/kludex/uvicorn-worker/blob/main/uvicorn_worker/_workers.py): `uvicorn_worker/_workers.py`
- **Uvicorn config**
- **Uvicorn server**

## Connections

- Gunicorn manager → Uvicorn worker: starts worker (evidence: `README.md`)
- ASGI application → Uvicorn worker: supplies app (evidence: `README.md`)
- Uvicorn worker → Uvicorn config: builds config (evidence: `uvicorn_worker/_workers.py`)
- Uvicorn worker → Uvicorn server: runs server (evidence: `uvicorn_worker/_workers.py`)
- H11 worker → Uvicorn worker: extends worker (evidence: `uvicorn_worker/_workers.py`)
