fastapi/fastapi
The shipped artifact is the `fastapi/` package (~21k lines across 56 files), a thin-but-deep layer over Starlette and Pydantic v2. `fastapi/applications.py` defines the `FastAPI` app class (subclassing `starlette.applications.Starlette`) and `fastapi/routing.py` — the largest file at 6447 lines — defines `APIRouter`, `APIRoute`, the request handler factory, and the frontend static-file routing. There is no database or storage layer; the only persistent state is in-process route tables and the memoised OpenAPI schema. Everything else in the repo is supporting apparatus: `docs/` (13 locales), `docs_src/` (executable tutorial examples on `PYTHONPATH` during tests), `scripts/` (docs build, translation, release, sponsor tooling), and 23 GitHub Actions workflows. Deployment is a PyPI wheel built by pdm-backend and published via `uv publish` with OIDC trusted publishing; the docs deploy separately to Cloudflare Pages.
- The public API surface is re-exported from `fastapi/__init__.py`, which pins `__version__ = "0.141.1"` and exposes exactly 20 names including `FastAPI`, `APIRouter`, `Depends`, `Security`, `BackgroundTasks`, `UploadFile`, `HTTPException`, `WebSocketException` and Starlette's `status` module.
- `fastapi/routing.py` (6447 lines) and `fastapi/applications.py` (4774 lines) hold the bulk of the logic; `param_functions.py` is third at 2460 lines but is almost entirely `annotated_doc.Doc` docstrings for `Query`/`Path`/`Header`/`Body`/`Depends`.
- Runtime boundaries are ASGI-only: `FastAPI.__call__` injects `root_path` into the scope then delegates to Starlette, and `build_middleware_stack()` composes `ServerErrorMiddleware` → user middleware → `ExceptionMiddleware` → `AsyncExitStackMiddleware` → `self.router`.
- FastAPI-specific per-request state is carried in three ASGI scope keys holding `AsyncExitStack`s: `fastapi_middleware_astack` (set by `AsyncExitStackMiddleware` for closing uploaded files), plus `fastapi_inner_astack` and `fastapi_function_astack` set in the vendored `request_response`/`websocket_session` wrappers for request- and function-scoped `yield` dependencies.
- Pydantic v1 support has been fully removed: `fastapi/_compat/__init__.py` re-exports only from `.shared` and `.v2`, and `PydanticV1NotSupportedError` is raised from `fastapi/encoders.py` and `fastapi/utils.py` when a v1 model is detected.
- Validation is delegated to a single `ModelField` wrapper in `fastapi/_compat/v2.py` that owns a `pydantic.TypeAdapter` and exposes `validate`, `serialize` (dump_python) and `serialize_json` (dump_json).
- The CLI entrypoint `fastapi = "fastapi.cli:main"` is a shim that imports `fastapi_cli.cli.main` and raises a RuntimeError telling the user to `pip install "fastapi[standard]"` if the optional package is absent; `fastapi/__main__.py` calls the same function.
- Runtime dependencies are minimal and pinned by floor: `starlette>=0.46.0`, `pydantic>=2.9.0`, `typing-extensions>=4.8.0`, `typing-inspection>=0.4.2`, `annotated-doc>=0.0.2`, with Python >= 3.10 required.
- `fastapi/staticfiles.py`, `fastapi/templating.py`, `fastapi/testclient.py`, `fastapi/requests.py` and `fastapi/websockets.py` are one-to-three-line re-export shims over Starlette, so those integrations (Jinja2, httpx TestClient) are Starlette's, not FastAPI's.
- Build/test/lint commands are shell scripts: `scripts/test.sh` runs `pytest -n auto --dist loadgroup tests scripts/tests/` with `PYTHONPATH=./docs_src`, `scripts/test-cov.sh` adds `--cov --cov-context=test`, and `scripts/lint.sh` runs `mypy fastapi`, `ty check`, `ruff check`, `ruff format --check`.
- Release shape: `.github/workflows/publish.yml` triggers on GitHub release publication and runs `uv build` then `uv publish` with `id-token: write` (OIDC trusted publishing, no stored PyPI token).
- Docs deploy is a separate pipeline: `deploy-docs.yml` fires on `workflow_run` completion of Build Docs, downloads `docs-site-*` artifacts and pushes to Cloudflare Pages, reporting status through `scripts/deploy_docs_status.py`.
- The package ships an agent skill inside the wheel at `fastapi/.agents/skills/fastapi/SKILL.md` with six reference pages (dependencies, path-operations, pydantic, responses, streaming, other-tools), making FastAPI conventions machine-consumable by coding agents.