ADR 001: Choosing FastAPI for the Web Framework¶
Date: 2026-03-18
Context: Developer Productivity, Performance, Ecosystem
Status: Currently accepted
1. Context¶
Our project requires a modern, performant, and developer-friendly web framework to build RESTful APIs. The key requirements include:
- High performance and low latency
- Native support for asynchronous programming
- Automatic data validation and serialization
- Built-in support for OpenAPI documentation
- Easy integration with databases and authentication
- Strong type safety and IDE support
We evaluated several Python web frameworks to determine the best fit for our requirements.
2. Decision¶
We decided to adopt FastAPI as the primary web framework for our application.
3. Rationale¶
Benefits of using FastAPI:¶
- High Performance:
- On par with Node.js and Go frameworks (one of the fastest Python frameworks)
- Built on top of Starlette for routing and Pydantic for validation
- Native Async Support:
- First-class support for
asyncandawait - Non-blocking I/O for improved concurrency
- First-class support for
- Automatic Documentation:
- Auto-generated Swagger UI and ReDoc at
/docsand/redoc - OpenAPI schema generation out of the box
- Auto-generated Swagger UI and ReDoc at
- Data Validation:
- Pydantic integration for automatic request/response validation
- Clear error messages for validation failures
- Type Safety:
- Full type hints support
- Editor autocomplete and IDE integration
- Modern Python:
- Leverages Python 3.7+ features (type hints, dataclasses)
- Minimal boilerplate code
Alternatives considered:¶
| Option | Pros | Cons |
|---|---|---|
| Flask | Lightweight, flexible, large ecosystem | Manual validation, no async native, less type safety |
| Django | Full-featured, mature, batteries-included | Heavyweight, synchronous by default, steep learning curve |
| Aiohttp | Async-native, lightweight | Less mature, manual validation, smaller ecosystem |
| Starlette | Fast, minimal, async-native | Less batteries-included, requires more setup |
FastAPI provides the best balance of performance, developer experience, and modern Python practices.
4. Consequences¶
Positive Outcomes¶
- Faster development cycle with automatic validation and documentation
- Improved code quality through type hints and Pydantic models
- Better performance for I/O-bound operations with native async support
- Easier API exploration and testing with auto-generated documentation
- Lower learning curve for team members familiar with Python type hints
Tradeoffs and Considerations¶
- Newer framework with a smaller community compared to Django/Flask
- Less mature ecosystem for some use cases
- Requires Python 3.7+ (not an issue for modern deployments)
- Migration from synchronous frameworks may require rethinking architecture