Skip to content

0001 fastapi

svchot edited this page Oct 29, 2024 · 1 revision

Use FastAPI as Python web API framework

Context and Problem Statement

We need to serve content from a backend linked to a database, to the frontend for display.

Historically Django (DRF) and Flask were best. Since asgi had more adoption, async frameworks are key.

FastAPI was the first to market to combine many powerful features:

  • ASGI Starlette + Uvicorn server.
  • Pydantic validation.
  • OpenAPI spec parsing.

Alternatives page in FastAPI docs.

Considered Options

  • Django Rest Framework
  • Flask
  • FastAPI

Decision Outcome

We chose FastAPI in 2022 is it was a well adopted, with a large community, and has great developer experience. It's also quite performant.

Consequences

  • Good, because code is much more concise and understandable.
  • Good, because endpoints are auto-documented as OpenAPI.
  • Bad, because as with any decision at this level, migration away becomes difficult (would require a rewrite using another framework).
Clone this wiki locally