Project Infrastructure
Relevant source files
- .github/workflows/build-docs.yml
- .github/workflows/contributors.yml
- .github/workflows/deploy-docs.yml
- .github/workflows/label-approved.yml
- .github/workflows/notify-translations.yml
- .github/workflows/people.yml
- .github/workflows/publish.yml
- .github/workflows/smokeshow.yml
- .github/workflows/sponsors.yml
- .github/workflows/test.yml
- .github/workflows/topic-repos.yml
- .github/workflows/translate.yml
- fastapi/applications.py
- fastapi/cli.py
- fastapi/dependencies/models.py
- fastapi/dependencies/utils.py
- fastapi/encoders.py
- fastapi/exceptions.py
- fastapi/openapi/models.py
- fastapi/openapi/utils.py
- fastapi/param_functions.py
- fastapi/params.py
- fastapi/routing.py
- fastapi/utils.py
- pyproject.toml
- tests/test_datetime_custom_encoder.py
- tests/test_dependency_wrapped.py
- tests/test_jsonable_encoder.py
- tests/test_skip_defaults.py
- uv.lock
Purpose and Scope
This document provides an overview of FastAPI's project infrastructure, including package configuration, dependency management, CI/CD pipelines, and development tooling. It describes how the project is built, tested, and released, and how developers interact with the codebase.
For information about code quality tools and pre-commit hooks, see Code Quality and Pre-commit Hooks. For details about the testing framework, see Test Framework and Coverage. For documentation build systems, see Documentation Build System.
Infrastructure Overview
FastAPI's infrastructure is built around modern Python tooling, with uv as the primary dependency manager and build tool, GitHub Actions for CI/CD automation, and pdm-backend for package building.
Infrastructure Component Overview
Sources: pyproject.toml1-341 uv.lock1-8 .github/workflows/test.yml1-212 .github/workflows/build-docs.yml1-118 .github/workflows/publish.yml1-30
Package Configuration
The project is defined in pyproject.toml which serves as the single source of truth for package metadata, dependencies, and tool configurations. For details, see Package Configuration and Dependencies.
Core Package Metadata
Sources: pyproject.toml1-15
Dependency Groups
FastAPI organizes dependencies into several groups for different use cases:
Dependency Group Structure
Sources: pyproject.toml44-192
Tool Configurations
The pyproject.toml file includes configurations for multiple development tools:
| Tool | Configuration Section | Purpose |
|---|---|---|
| PDM | [tool.pdm] | Version source, distribution settings |
| mypy | [tool.mypy] | Type checking with Pydantic plugin |
| pytest | [tool.pytest] | Test execution settings |
| coverage | [tool.coverage.*] | Code coverage measurement |
| ruff | [tool.ruff.lint] | Linting rules and ignores |
Sources: pyproject.toml194-340
Dependency Management with uv
FastAPI uses uv as its dependency manager, providing fast, reproducible builds through lock files. For details, see Dependency Management with uv.
uv Dependency Management Workflow
The lock file uv.lock1-8 specifies exact versions for all dependencies, ensuring reproducible builds across environments.
Common uv Commands
Sources: .github/workflows/test.yml104 .github/workflows/publish.yml26-29 pyproject.toml194-196
CI/CD Pipeline Architecture
FastAPI uses GitHub Actions for all CI/CD operations, organized into multiple workflow files that handle testing, documentation, releases, and community automation. For details, see CI/CD Pipeline.
CI/CD Workflow Dependencies
Sources: .github/workflows/test.yml1-212 .github/workflows/build-docs.yml1-118 .github/workflows/publish.yml1-30 .github/workflows/deploy-docs.yml1-83
Primary Workflows
Test Workflow
The .github/workflows/test.yml workflow runs comprehensive tests across multiple dimensions:
| Matrix Dimension | Values | Purpose |
|---|---|---|
| OS | ubuntu-latest, macos-latest, windows-latest | Cross-platform compatibility |
| Python | 3.10, 3.11, 3.12, 3.13, 3.14 | Version compatibility |
| Resolution | highest, lowest-direct | Dependency range testing |
| Starlette Source | starlette-pypi, starlette-git | Bleeding edge testing |
The workflow includes three main jobs:
- changes: Filters paths to determine if tests are needed .github/workflows/test.yml20-43
- test: Executes test matrix with coverage collection .github/workflows/test.yml45-121
- benchmark: Runs performance benchmarks with CodSpeed .github/workflows/test.yml123-154
- coverage-combine: Merges coverage reports and enforces 100% threshold .github/workflows/test.yml156-193
Sources: .github/workflows/test.yml1-212
Build Documentation Workflow
The .github/workflows/build-docs.yml workflow builds documentation for all supported languages in parallel:
Documentation Build Matrix
The workflow:
- Determines language list using
./scripts/docs.py langs-json.github/workflows/build-docs.yml62 - Builds each language in parallel with caching .github/workflows/build-docs.yml94-99
- Uploads artifacts for deployment .github/workflows/build-docs.yml100-104
Sources: .github/workflows/build-docs.yml1-118
Publish Workflow
The .github/workflows/publish.yml workflow triggers on GitHub release creation:
PyPI Publishing Pipeline
Key features:
- Uses OIDC trusted publishing (no API tokens needed) .github/workflows/publish.yml12
- Single command build:
uv build.github/workflows/publish.yml27 - Single command publish:
uv publish.github/workflows/publish.yml29
Sources: .github/workflows/publish.yml1-30
Deploy Documentation Workflow
The .github/workflows/deploy-docs.yml workflow deploys to Cloudflare Pages after documentation builds complete:
Documentation Deployment Flow
The workflow:
- Sets deployment status to pending .github/workflows/deploy-docs.yml37-43
- Downloads all language artifacts .github/workflows/deploy-docs.yml48-54
- Deploys to Cloudflare Pages .github/workflows/deploy-docs.yml55-66
- Comments deployment URL on PR .github/workflows/deploy-docs.yml75-82
Sources: .github/workflows/deploy-docs.yml1-83
Community Automation Workflows
FastAPI includes several scheduled workflows for community data management:
| Workflow | Schedule | Purpose | Script |
|---|---|---|---|
| people.yml | Monthly (1st, 14:00 UTC) | Update expert lists | scripts/people.py |
| contributors.yml | Monthly (1st, 03:00 UTC) | Update contributor data | scripts/contributors.py |
| sponsors.yml | Monthly (1st, 06:00 UTC) | Update sponsor information | scripts/sponsors.py |
| topic-repos.yml | Monthly (1st, 12:00 UTC) | Update related projects | scripts/topic_repos.py |
| label-approved.yml | Daily (12:00 UTC) | Auto-label approved PRs | scripts/label_approved.py |
| notify-translations.yml | On PR label/close | Notify translation reviewers | scripts/notify_translations.py |
| latest-changes.yml | On PR merge | Update release notes | External action |
Sources: .github/workflows/people.yml4-5 .github/workflows/contributors.yml4-5 .github/workflows/sponsors.yml4-5 .github/workflows/topic-repos.yml4-5 .github/workflows/label-approved.yml4-5 .github/workflows/notify-translations.yml3-6 .github/workflows/latest-changes.yml3-8
Coverage Reporting
The .github/workflows/smokeshow.yml workflow publishes coverage reports:
Smokeshow Coverage Reporting
Features:
- Automatic retry (up to 5 attempts) .github/workflows/smokeshow.yml40-47
- GitHub status check integration .github/workflows/smokeshow.yml49-51
- 100% coverage threshold .github/workflows/smokeshow.yml50
Sources: .github/workflows/smokeshow.yml1-55
Development Tools and Configuration
Code Quality Tools
FastAPI enforces code quality through multiple tools configured in pyproject.toml:
mypy Configuration
Type checking with strict mode enabled:
Overrides for specific modules:
fastapi.concurrency: Relaxed import checking pyproject.toml211-214fastapi.tests.*: Allow untyped defs pyproject.toml216-219docs_src.*: Allow incomplete definitions pyproject.toml221-225
Sources: pyproject.toml207-225
pytest Configuration
Test execution settings:
Sources: pyproject.toml227-238
coverage Configuration
Coverage measurement and reporting:
| Setting | Value | Purpose |
|---|---|---|
| parallel | true | Allow parallel test execution |
| data_file | coverage/.coverage | Coverage data location |
| source | ["docs_src", "tests", "fastapi"] | Measured packages |
| relative_files | true | Portable paths |
| omit | Multiple patterns | Exclude test files, benchmarks |
Sources: pyproject.toml240-261
ruff Configuration
Linting with multiple rule sets:
Per-file ignores defined for 50+ documentation example files pyproject.toml287-329
Sources: pyproject.toml270-336
Environment Configuration
FastAPI uses a .python-version file to specify the default Python version for development and CI:
- Python 3.13 is the current default
- Used by
uvand GitHub Actions viapython-version-fileparameter
Sources: .github/workflows/test.yml168 .github/workflows/build-docs.yml49
Build Configuration
The pdm-backend build system includes source files in distributions:
Sources: pyproject.toml198-205
Environment Variables
The CI/CD system uses several environment variables for configuration:
Sources: .github/workflows/test.yml15-17 .github/workflows/test.yml82-85 .github/workflows/deploy-docs.yml64 .github/workflows/smokeshow.yml54
Related Pages
- Package Configuration and Dependencies - Detailed pyproject.toml structure
- Dependency Management with uv - uv commands and lock file management
- CI/CD Pipeline - In-depth workflow documentation
- Development Workflow - Local development setup and practices
- Code Quality and Pre-commit Hooks - Quality enforcement tools
- Test Framework and Coverage - Testing infrastructure
Refresh this wiki
On this page
- Project Infrastructure
- Purpose and Scope
- Infrastructure Overview
- Package Configuration
- Core Package Metadata
- Dependency Groups
- Tool Configurations
- Dependency Management with uv
- Common uv Commands
- CI/CD Pipeline Architecture
- Primary Workflows
- Test Workflow
- Build Documentation Workflow
- Publish Workflow
- Deploy Documentation Workflow
- Community Automation Workflows
- Coverage Reporting
- Development Tools and Configuration
- Code Quality Tools
- mypy Configuration
- pytest Configuration
- coverage Configuration
- ruff Configuration
- Environment Configuration
- Build Configuration
- Environment Variables
- Related Pages
