# System map — fastapi/fastapi

> Canonical page: https://codevetter.com/unpack/fastapi/system-map

# System map — fastapi/fastapi

Scanned commit 50113da16fec53b66b80d75e80a89296de4fa5a5 (2026-09-01). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

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/__init__.py#L1-25](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/__init__.py#L1-L25)
- `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`. — [fastapi/routing.py](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/routing.py) [fastapi/applications.py](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/applications.py) [fastapi/param_functions.py](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/param_functions.py)
- 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/applications.py#L1020-1068](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/applications.py#L1020-L1068) [fastapi/applications.py#L1160-1164](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/applications.py#L1160-L1164)
- 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. — [fastapi/middleware/asyncexitstack.py#L1-18](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/middleware/asyncexitstack.py#L1-L18) [fastapi/routing.py#L121-186](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/routing.py#L121-L186) [fastapi/dependencies/utils.py#L601-609](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/dependencies/utils.py#L601-L609)
- 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. — [fastapi/_compat/__init__.py#L1-40](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/_compat/__init__.py#L1-L40) [fastapi/exceptions.py#L246-250](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/exceptions.py#L246-L250) [fastapi/encoders.py#L342](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/encoders.py#L342) [fastapi/utils.py#L67](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/utils.py#L67)
- 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). — [fastapi/_compat/v2.py#L114-235](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/_compat/v2.py#L114-L235)
- 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. — [pyproject.toml#L45-47](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/pyproject.toml#L45-L47) [fastapi/cli.py#L1-13](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/cli.py#L1-L13) [fastapi/__main__.py#L1-3](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/__main__.py#L1-L3)
- 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. — [pyproject.toml#L12-52](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/pyproject.toml#L12-L52)
- `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. — [fastapi/staticfiles.py](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/staticfiles.py) [fastapi/templating.py](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/templating.py) [fastapi/testclient.py](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/testclient.py) [fastapi/websockets.py](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/websockets.py)
- 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`. — [scripts/test.sh](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/scripts/test.sh) [scripts/test-cov.sh](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/scripts/test-cov.sh) [scripts/lint.sh](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/scripts/lint.sh) [scripts/format.sh](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/scripts/format.sh)
- 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). — [.github/workflows/publish.yml#L1-36](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/.github/workflows/publish.yml#L1-L36)
- 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`. — [.github/workflows/deploy-docs.yml#L1-60](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/.github/workflows/deploy-docs.yml#L1-L60) [scripts/deploy_docs_status.py](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/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. — [fastapi/.agents/skills/fastapi/SKILL.md](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/.agents/skills/fastapi/SKILL.md) [fastapi/.agents/skills/fastapi/references/streaming.md](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/.agents/skills/fastapi/references/streaming.md) [fastapi/.agents/skills/fastapi/references/dependencies.md](https://github.com/fastapi/fastapi/blob/50113da16fec53b66b80d75e80a89296de4fa5a5/fastapi/.agents/skills/fastapi/references/dependencies.md)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
