fastapi-best-practices is a collection of best practices and conventions for building production FastAPI applications.
The project addresses the challenge of making sound architectural and implementation decisions when building FastAPI systems at scale. It distills lessons learned from several years of production experience, covering areas where poor choices significantly impact developer experience. The approach is opinionated, presenting specific recommendations across project structure, async patterns, dependency injection, Pydantic usage, database interactions, and testing strategies. Rather than prescribing a single way to do everything, it acknowledges that different project sizes and types may warrant different structures, but emphasizes consistency and avoiding surprises.
The tool suits teams building FastAPI applications who want to learn from production experience without repeating common mistakes. It is particularly relevant for those scaling from small microservices to larger monolithic systems with multiple domains, where file-type-based organization breaks down. The collection covers practical concerns like handling I/O and CPU-intensive tasks, managing async dependencies, database naming conventions, and migration strategies. A machine-readable format is available for those working with AI agents, providing the same guidance in a structured form with version matrices and anti-patterns checklists.
The maintainers typically respond to new issues and pull requests within a day.