← All unpacks
CodeVetter · Repo Unpack comparison

flask vs fastapi

flask scanned at d73fa1c (2026-09-08) · fastapi at 50113da (2026-09-01) · codevetter codevetter 1.12.0

Flask's WSGI microframework plus extension ecosystem vs FastAPI's ASGI + type-annotation-driven API surface.

pallets/flaskfastapi/fastapi
Files scanned2302950
Size1.1 MB21.0 MB
Primary source rootsrc/fastapi/
Top languagePython (83 files)Markdown (1692 files)
Packageflask v3.2.0.devfastapi v{ source = "file", path = "fastapi/__init__.py" }
Structural health7.5/10 avg, 8 hotspots8.2/10 avg, 12 hotspots
Test signalmissingmissing

Architectures

flask

Flask is the Pallets WSGI web framework — a thin, opinion-light composition layer over Werkzeug (routing, request/response, dev server), Jinja (templating), itsdangerous (signed session cookies), Click (CLI) and Blinker (signals), distributed as the `flask` package plus a `flask` console script. This checkout is the unreleased 3.2.0.dev line on `main`, whose headline change is the merger of `RequestContext` into a single `AppContext`: one context object now carries app, `g`, request, session and URL adapter, is pushed once per request and per CLI command, and is threaded explicitly as a `ctx` first argument through `dispatch_request`, `full_dispatch_request`, `finalize_request`, `preprocess_request`, `process_response` and the teardown methods. The codebase is deliberately split into a sans-IO core (`src/flask/sansio/`) that alternative implementations such as Quart reuse, and IO-bound subclasses (`app.py`, `blueprints.py`) that add WSGI, Click groups and file serving. It targets Python 3.10+, is fully typed (`py.typed`, strict mypy + pyright), and ships its own tutorial, JavaScript and Celery example applications.

fastapi

This is the FastAPI framework source repository at version 0.141.1 — a Pydantic v2-only, Starlette-based ASGI web framework whose distinguishing trick is deriving request parsing, validation, serialization and an OpenAPI 3.1 schema from ordinary Python type hints on endpoint functions. This tree is notably ahead of the classic FastAPI architecture: `include_router()` no longer flattens child routes into the parent but stores an `_IncludedRouter` wrapper resolved at match time, the package ships first-class Server-Sent Events (`fastapi/sse.py`) and JSON-Lines streaming, a `app.frontend()` / `router.frontend()` low-priority static-SPA router, and a bundled agent skill at `fastapi/.agents/skills/fastapi/SKILL.md`. The repo is overwhelmingly documentation and tests: 1692 Markdown files across 13 translated locales, 594 test files, and 464 runnable tutorial sources in `docs_src/` that the test suite executes directly. Its audience is Python API developers, and the repo itself enforces 100% line coverage, strict mypy, ty, and Ruff on every push.

System maps

flask

The library entrypoints are the `flask` package namespace (`src/flask/__init__.py` re-exports the public API), the `flask` console script wired to `flask.cli:main`, and `python -m flask` via `__main__.py`. Runtime is split across a sans-IO layer (`Scaffold` → `App` → `Blueprint` in `src/flask/sansio/`) that holds registries and setup logic with no IO, and the IO layer (`Flask`, `Blueprint`, `cli`, `helpers`, `templating`) that performs WSGI dispatch, file serving and server startup. There is no database or persistence layer; the only durable state Flask owns is the signed session cookie written by `SecureCookieSessionInterface`. External integrations are all Pallets-family libraries pinned in `pyproject.toml` dependencies, plus optional `asgiref` (async views) and `python-dotenv` (env files). Build is flit_core; test/lint/type/docs orchestration is tox driven by uv, executed in GitHub Actions.

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.

Repository structure

flask

  • docs/ — 82 files
  • tests/ — 61 files
  • examples/ — 42 files
  • src/ — 26 files
  • .github/ — 9 files
  • .devcontainer/ — 2 files

fastapi

  • docs/ — 1733 files
  • tests/ — 594 files
  • docs_src/ — 464 files
  • scripts/ — 68 files
  • fastapi/ — 56 files
  • .github/ — 28 files