What problem does it solve?
Large FastAPI projects require consistent patterns for dependency injection, per-request database sessions, background processing, WebSockets, middleware, and structured error handling to avoid duplicated code, resource leaks, and fragile endpoints. This Skill provides practical patterns and guidance to implement these concerns reliably so teams can ship maintainable, observable APIs.
Core Features & Use Cases
- Dependency Injection & Auth: Typed dependencies for DB sessions and current user extraction to keep route handlers clean and secure.
- Background Tasks & Async I/O: Fire-and-forget background work for notifications and nonblocking workflows, with guidance on when to use external job queues.
- Middleware & Error Handling: Request timing, logging middleware, and a structured AppError system with registered exception handlers for consistent API error responses.
- Use Case: Implement a project service with async SQLAlchemy sessions per request, admin-only routes via chained dependencies, background notifications, and centralized JSON error responses.
Quick Start
Create a FastAPI endpoint that uses an async DB session dependency, enforces authenticated user access, returns a Pydantic response model, registers AppError handlers, and adds timing middleware.