fastapi-best-practices

Organize FastAPI projects with domain-driven structure and conventions.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/LucasBiason/cursor-multiagent-system --skill fastapi-best-practices
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi-best-practices
Source: https://github.com/LucasBiason/cursor-multiagent-system/tree/main/skills/backend/fastapi
Command: npx skills add https://github.com/LucasBiason/cursor-multiagent-system --skill fastapi-best-practices

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a standardized, domain-oriented structure and conventions for FastAPI projects, improving consistency, testability, and maintainability across teams.

Core Features & Use Cases

  • Domain-driven project layout with clear separation of concerns (routers, schemas, models, services, dependencies).
  • Guidelines for async vs sync routes, Pydantic models, global vs domain settings, and robust error handling.
  • Use Case: start a new FastAPI service with a scalable structure and ready-to-extend modules for domains like auth, posts, and payments.

Quick Start

Initialize a new FastAPI project using the recommended domain-based structure, install dependencies, and run the app with uvicorn. Create a minimal example in src/{domain}/ with router.py, schemas.py, and models.py to see the pattern in action.

Frequently Asked Questions about fastapi-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a FastAPI project for maintainability?

Structure a FastAPI project for maintainability by adopting a domain-driven layout with clear separation of concerns. Organize code into routers, schemas, models, services, and dependencies to ensure scalable and testable code across teams.

What is the best way to organize domain-driven routes in FastAPI?

Organize domain-driven routes in FastAPI by grouping modules by domain, such as auth or payments. Place router.py, schemas.py, and models.py inside src/{domain}/ directories to establish consistent routing patterns and clear separation of concerns.

When should I use async versus sync routes in FastAPI?

Use async versus sync routes in FastAPI based on I/O blocking operations. The best-practice structure provides guidelines for async vs sync routes to ensure optimal performance and maintainable endpoint implementations.

How do I manage Pydantic models and settings in a scalable FastAPI app?

Manage Pydantic models and settings in a scalable FastAPI app by applying standardized conventions. The structure provides guidelines for robust Pydantic usage and separates global settings from domain-specific settings for clarity.

Does this FastAPI structure support database migrations?

Yes, this FastAPI structure supports database migrations by applying standardized migration practices. The domain-oriented layout ensures migrations are handled consistently across new projects and refactors for scalable code.

Can I refactor an existing FastAPI application into this domain-oriented structure?

Yes, you can refactor an existing FastAPI application into this domain-oriented structure. The conventions apply to refactors and endpoint implementations, ensuring your existing codebase becomes scalable and testable.