Skip to content
STACK IT FAST

FastAPI

Curated OSSClassicHigh-Performance Python Web API Framework1M+ MAU

Audited from github.com/fastapi/fastapi

FastAPI is a Python web framework that generates request validation, serialization and an interactive OpenAPI/Swagger UI/ReDoc documentation site directly from type-hinted routes and Pydantic models, built on top of the Starlette ASGI toolkit.

Language
Python
License
MIT
Running for
6 years
Team
1M+ MAU

Why this architecture

FastAPI keeps its own dependency surface to Starlette and Pydantic and pushes servers, CLI, templating, forms and settings into an optional 'standard' extra, so a bare install stays minimal while typical apps opt into one bundle instead of assembling it dependency by dependency.

Tech stack by layer

9 technologies · audited Sep 17, 2026
Frontend & UI
  • Swagger UIInteractive API docs generated from the OpenAPI schema; configurable via fastapi/openapi and docs_src/configure_swagger_ui.
  • ReDocSecond interactive docs UI generated from the same OpenAPI schema, shown alongside or instead of Swagger UI.
Backend & APIs
  • StarletteASGI toolkit FastAPI builds routing, middleware, WebSockets and request/response handling on top of.
  • PydanticValidates and serializes request/response data from Python type hints (pydantic>=2.9.0 required).
  • UvicornASGI server used by `fastapi dev`/`fastapi run`; installed via the optional 'standard' extra (uvicorn[standard]).
Infrastructure & Deploy
  • uvDocumented install/run tool for FastAPI apps (`uv add "fastapi[standard]"`, `uv run fastapi dev`) per the README quick start.
  • pytestTest runner (pytest>=9.0.0) with strict-config, strict-markers and a 20s per-test timeout.
  • mypyStrict type checking (`strict = true`) across the codebase via the pydantic.mypy plugin.
  • RuffLints pyflakes/pycodestyle/isort/bugbear/comprehension/pyupgrade rules (E, W, F, I, B, C4, UP).
  • GitHub ActionsRuns the test suite, docs build/deploy, pre-commit hook bumps, translation automation and release drafts (20 workflows).
Tooling, Testing & Ops
  • Pydantic AIIncluded in the translations dependency group to assist the docs translation pipeline behind translate.yml.

FastAPI architecture diagram

Open SVG
FastAPI architecture diagramHTTP clients → Uvicorn (HTTP / WS); Swagger UI · ReDoc → Uvicorn (GET /docs); fastapi CLI → Uvicorn (start server); Uvicorn → FastAPI app (ASGI); FastAPI app → Starlette (routing); FastAPI app → Pydantic v2 (validate I/O); FastAPI app → fastapi/openapi (OpenAPI schema)CLIENTSSERVICESWORKERS & JOBSHTTP clientsbrowsers · API consumersSwagger UI · ReDocinteractive docsfastapi CLIdev · run ([standard])UvicornASGI serverFastAPI apppath operations · type hintsStarletterouting · middleware · WSPydantic v2validation · serializationfastapi/openapischema from type hintsASGIHTTP / WSGET /docsstart serverroutingvalidate I/OOpenAPI schema
How the main components of FastAPI connect, drawn from the audited repository.
Diagram as text
  • HTTP clients (browsers · API consumers) → Uvicorn (ASGI server): HTTP / WS
  • Swagger UI · ReDoc (interactive docs) → Uvicorn (ASGI server): GET /docs
  • fastapi CLI (dev · run ([standard])) → Uvicorn (ASGI server): start server
  • Uvicorn (ASGI server) → FastAPI app (path operations · type hints): ASGI
  • FastAPI app (path operations · type hints) → Starlette (routing · middleware · WS): routing
  • FastAPI app (path operations · type hints) → Pydantic v2 (validation · serialization): validate I/O
  • FastAPI app (path operations · type hints) → fastapi/openapi (schema from type hints): OpenAPI schema

Key architectural decisions

7 decisions
  1. 01

    Built directly on Starlette and Pydantic, not a custom core

    pyproject.toml's runtime dependencies list is just starlette>=0.46.0, pydantic>=2.9.0, typing-extensions, typing-inspection and annotated-doc; FastAPI's routing/ASGI layer is Starlette's, and all validation/serialization is Pydantic's, rather than FastAPI reimplementing either.

  2. 02

    Almost every feature is opt-in through the "standard" extra

    [project.optional-dependencies].standard in pyproject.toml pulls in fastapi-cli, httpx, jinja2, python-multipart, email-validator, uvicorn[standard], pydantic-settings and pydantic-extra-types; installing bare fastapi with no extras gives none of the CLI, templating, forms, or dev server.

  3. 03

    Two docs UIs are generated from one OpenAPI schema, not hand-written pages

    fastapi/openapi builds the OpenAPI schema from route type hints and Pydantic models; docs_src/configure_swagger_ui and docs_src/custom_docs_ui show both Swagger UI and ReDoc being served, restyled, or swapped out from that same generated schema.

  4. 04

    Strict mypy runs alongside a second, independent type checker

    [tool.mypy] sets strict = true with the pydantic.mypy plugin, and the tests dependency group additionally pins ty>=0.0.25 (Astral’s Rust type checker), so the same codebase is checked by two independently implemented type checkers rather than one.

  5. 05

    Performance regressions are benchmarked in CI, not just caught by tests

    The tests dependency group includes pytest-codspeed>=4.3.0, and tests/benchmarks plus tests/memory_benchmarks are separate directories explicitly excluded from coverage reporting in [tool.coverage.run].omit, keeping benchmark runs distinct from correctness tests.

  6. 06

    Docs translation has a dedicated automation dependency group

    A translations group in [dependency-groups] (gitpython, pydantic-ai, pygithub) backs the translate.yml and notify-translations.yml workflows listed under .github/workflows, rather than translations flowing through the same review path as code PRs.

  7. 07

    The documentation build pipeline spans two static-site generators

    The docs dependency group installs both zensical>=0.0.42 and mkdocstrings[python]>=1.0.3 (plus griffe-typingdoc and griffe-warnings-deprecated) to build the docs_src tutorials that are translated into 15+ language folders under docs/.

How FastAPI is built

How FastAPI is structured

The fastapi/ package is organized around one idea: turn Python type hints into request handling. fastapi/routing.py and fastapi/applications.py define the FastAPI app and path operations on top of Starlette; fastapi/dependencies/ implements the dependency-injection system that resolves function parameters (path/query/header/cookie params, request bodies, sub-dependencies) before a route handler runs; fastapi/_compat/ isolates the differences between supported Pydantic versions; fastapi/security/ holds the OAuth2/API-key/HTTP-auth building blocks; and fastapi/openapi/ turns all of the above into a generated OpenAPI schema. Nothing in pyproject.toml's core dependencies list is a database driver, template engine, or server — only starlette, pydantic, typing-extensions, typing-inspection and annotated-doc.

The repository is also the documentation: docs_src/ contains one small, runnable example script per documented feature (over 100 directories, e.g. docs_src/dependencies, docs_src/websockets_, docs_src/sql_databases), and tests/test_tutorial/ imports those same scripts as test fixtures, so the tutorial examples are continuously verified rather than left to rot. docs/ mirrors that content into 15+ language directories (docs/de, docs/es, docs/ja, docs/tr, docs/zh, …), coordinated by docs/language_names.yml and scripts/translate.py.

Backend & APIs

Routing and the ASGI request/response cycle are Starlette's; FastAPI's own code layers path-operation decorators, automatic request parsing, and response model filtering on top. Every parameter type (path, query, header, cookie, body, form, file, dependency) that a route function declares is resolved through fastapi/dependencies/utils.py, which is also what makes FastAPI's dependency-injection system reusable across routes — that resolution logic is shared with security schemes in fastapi/security/, which implement OAuth2 password/bearer flows, API key auth, and HTTP Basic/Bearer/Digest. Optional Uvicorn (uvicorn[standard], part of the standard extra defined in pyproject.toml) runs the resulting ASGI app; fastapi/cli.py and the fastapi console script wire fastapi dev/fastapi run to it. There is deliberately no bundled database layer: sql_databases-style examples under docs_src/ show usage patterns, but SQLModel, SQLAlchemy or any other ORM stays outside the framework's own dependencies (SQLModel appears only in the tests dependency group, to check compatibility, not as a runtime dependency).

Build, test & deploy

The build backend is pdm-backend ([build-system] in pyproject.toml), with the package version sourced from fastapi/__init__.py via [tool.pdm]. uv.lock is checked in and the README's install/run instructions are uv-based (uv add "fastapi[standard]", uv run fastapi dev), even though the package itself builds with PDM. Testing runs through pytest ([tool.pytest], minversion 9.0, --strict-config --strict-markers, 20s timeout, docs_src excluded from direct collection but exercised indirectly via tests/test_tutorial), with mypy --strict and Ruff (E, W, F, I, B, C4, UP rule sets) as separate lint/type gates and ty as a second, independently implemented type checker in the tests dependency group. CI lives in .github/workflows/ — 20 workflow files covering test.yml, pre-commit.yml, build-docs.yml/deploy-docs.yml, zizmor.yml (GitHub Actions security linting), smokeshow.yml (coverage badge publishing), translate.yml/notify-translations.yml, and create-draft-release.yml/prepare-release.yml.

What to copy (and what not to)

The extras-based dependency split — one tiny core (starlette + pydantic + typing helpers) and one standard bundle for everything most apps actually want (CLI, server, templates, forms, settings) — is the most portable idea here: it keeps a library's mandatory dependency surface small without making users hand-assemble a dozen packages for the common case. The tutorial-as-tests pattern (docs_src/ scripts imported by tests/test_tutorial/) is also worth copying for any project whose docs contain runnable code samples, since it makes documentation examples fail CI the moment they go stale. What is specific to FastAPI's scale and is not worth copying wholesale for a smaller project is the 15+-language, partly AI-assisted (pydantic-ai in the translations dependency group) translation pipeline and the dual mypy/ty type-checking setup — both make sense for a widely used, heavily localized framework, not for most application codebases.

Sources & repo audit

Audited
Sep 17, 2026
Commit
50113da
License
MIT

Independent analysis of repository at github.com/fastapi/fastapi. Spotted an inaccuracy? Use the claim form to request a correction.

Show this stack on your README or website
Tech stack of FastAPI
[![Tech stack of FastAPI on STACK IT FAST](https://stackitfast.com/badge/fastapi.svg)](https://stackitfast.com/project/fastapi)

Paste it into your README. It shows your current stack and links to this page.

Use this stack

Scaffold it with your agent

Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with FastAPI's architecture.

  1. 1Copy the promptThe full markdown spec, with every layer and decision.
  2. 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
  3. 3Paste and scaffoldUse it as the first instruction; review before you ship.
use-this-stack.md · 61 lines · 7.8 KB
# MISSION: Scaffold "FastAPI" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **FastAPI**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: FastAPI
- **What It Does**: FastAPI is a Python web framework that generates request validation, serialization and an interactive OpenAPI/Swagger UI/ReDoc documentation site directly from type-hinted routes and Pydantic models, built on top of the Starlette ASGI toolkit.
- **Domain & Category**: High-Performance Python Web API Framework
- **Production Scale**: 1M+ MAU
- **Development Mode**: CLASSIC
- **Architectural Rationale**: FastAPI keeps its own dependency surface to Starlette and Pydantic and pushes servers, CLI, templating, forms and settings into an optional 'standard' extra, so a bare install stays minimal while typical apps opt into one bundle instead of assembling it dependency by dependency.
- **Live Website Reference**: https://fastapi.tiangolo.com
- **Source Repository**: https://github.com/fastapi/fastapi
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: Python, Starlette, Pydantic, Uvicorn, uv, pytest, mypy, Ruff, GitHub Actions
- **Primary Language(s)**: Python
- **License of the reference repo**: MIT
- **Frontend**: Swagger UI — Interactive API docs generated from the OpenAPI schema; configurable via fastapi/openapi and docs_src/configure_swagger_ui.; ReDoc — Second interactive docs UI generated from the same OpenAPI schema, shown alongside or instead of Swagger UI.
- **Backend & APIs**: Starlette — ASGI toolkit FastAPI builds routing, middleware, WebSockets and request/response handling on top of.; Pydantic — Validates and serializes request/response data from Python type hints (pydantic>=2.9.0 required).; Uvicorn — ASGI server used by `fastapi dev`/`fastapi run`; installed via the optional 'standard' extra (uvicorn[standard]).
- **Infrastructure & deploy**: uv — Documented install/run tool for FastAPI apps (`uv add "fastapi[standard]"`, `uv run fastapi dev`) per the README quick start.; pytest — Test runner (pytest>=9.0.0) with strict-config, strict-markers and a 20s per-test timeout.; mypy — Strict type checking (`strict = true`) across the codebase via the pydantic.mypy plugin.; Ruff — Lints pyflakes/pycodestyle/isort/bugbear/comprehension/pyupgrade rules (E, W, F, I, B, C4, UP).; GitHub Actions — Runs the test suite, docs build/deploy, pre-commit hook bumps, translation automation and release drafts (20 workflows).
- **Tooling, testing & ops**: Pydantic AI — Included in the translations dependency group to assist the docs translation pipeline behind translate.yml.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/fastapi/fastapi @ 50113da)
1. **Built directly on Starlette and Pydantic, not a custom core**: pyproject.toml's runtime `dependencies` list is just starlette>=0.46.0, pydantic>=2.9.0, typing-extensions, typing-inspection and annotated-doc; FastAPI's routing/ASGI layer is Starlette's, and all validation/serialization is Pydantic's, rather than FastAPI reimplementing either.
2. **Almost every feature is opt-in through the "standard" extra**: [project.optional-dependencies].standard in pyproject.toml pulls in fastapi-cli, httpx, jinja2, python-multipart, email-validator, uvicorn[standard], pydantic-settings and pydantic-extra-types; installing bare `fastapi` with no extras gives none of the CLI, templating, forms, or dev server.
3. **Two docs UIs are generated from one OpenAPI schema, not hand-written pages**: fastapi/openapi builds the OpenAPI schema from route type hints and Pydantic models; docs_src/configure_swagger_ui and docs_src/custom_docs_ui show both Swagger UI and ReDoc being served, restyled, or swapped out from that same generated schema.
4. **Strict mypy runs alongside a second, independent type checker**: [tool.mypy] sets strict = true with the pydantic.mypy plugin, and the `tests` dependency group additionally pins `ty>=0.0.25` (Astral’s Rust type checker), so the same codebase is checked by two independently implemented type checkers rather than one.
5. **Performance regressions are benchmarked in CI, not just caught by tests**: The `tests` dependency group includes pytest-codspeed>=4.3.0, and tests/benchmarks plus tests/memory_benchmarks are separate directories explicitly excluded from coverage reporting in [tool.coverage.run].omit, keeping benchmark runs distinct from correctness tests.
6. **Docs translation has a dedicated automation dependency group**: A `translations` group in [dependency-groups] (gitpython, pydantic-ai, pygithub) backs the translate.yml and notify-translations.yml workflows listed under .github/workflows, rather than translations flowing through the same review path as code PRs.
7. **The documentation build pipeline spans two static-site generators**: The `docs` dependency group installs both zensical>=0.0.42 and mkdocstrings[python]>=1.0.3 (plus griffe-typingdoc and griffe-warnings-deprecated) to build the docs_src tutorials that are translated into 15+ language folders under docs/.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
   - Structure as a Turborepo monorepo with strict package boundaries:
     - `apps/web`: Application UI, routing, layouts, and server endpoints.
     - `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
     - `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
     - `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
   - Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
   - Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
   - Isolate interactive UI state to leaf components. Keep core pages lightweight and performant.
4. **Design System & Aesthetics**:
   - Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
   - Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
   - Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
   - Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer: client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.
Scaffolded something with this prompt?
Would you pick this stack for a high-performance python web api framework project?

Frequently asked about FastAPI

What is FastAPI built with?

FastAPI's only core runtime dependencies are Starlette (ASGI routing/middleware) and Pydantic (validation and serialization from type hints); Uvicorn, the CLI, templating and forms all come from an optional 'standard' extra rather than the base install.

Does FastAPI include a database or ORM?

No. pyproject.toml declares no database or ORM as a core or 'standard' dependency; SQLModel appears only inside the tests dependency group to verify compatibility, so persistence (SQLAlchemy, SQLModel, or anything else) is entirely up to the application.

Can I self-host a FastAPI application?

Yes. A FastAPI app is a plain ASGI application; fastapi dev and fastapi run serve it with Uvicorn (installed via the standard extra) for local development and production respectively, with no hosting-specific config in this repository.

How does FastAPI generate its interactive API docs?

It builds an OpenAPI schema from route type hints and Pydantic models (fastapi/openapi), then serves that schema through both a Swagger UI page and a ReDoc page, which can be customized or disabled per docs_src/configure_swagger_ui and docs_src/custom_docs_ui.

What Python versions does FastAPI support?

pyproject.toml sets requires-python = ">=3.10" and lists trove classifiers for Python 3.10 through 3.14.

One email a month: new deep dives and stack trends

New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.

use-this-stack.md