--- name: "FastAPI Architecture" description: "Enforces standards for FastAPI route controllers, Pydantic data schemas, and dependency injection." --- # Skill: FastAPI Architecture ## 1. Purpose Maintain a uniform, scalable structure in the backend application, ensuring separation of routing, business logic, and database access. ## 2. When to Use Before editing or adding backend controllers, routers, or schemas. ## 3. Step-by-Step Checklist 1. **Router Separation**: Place routes inside domain-specific submodules and register them on the main router. 2. **Pydantic Schemas**: Separate request body schemas, response schemas, and database entity models. 3. **Dependency Injection**: Use `Depends` for database sessions, security authentication, and permissions. 4. **Error Handling**: Throw structured HTTPExceptions with clear detail messages rather than generic exceptions. 5. **Types and Documentation**: Add typing annotations and descriptions to all endpoint parameters for auto-generated OpenAPI documentation.