fastapi-at-scale

Build production-grade FastAPI applications with async SQLAlchemy, JWT auth, and Celery.

17|3|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/jayll1303/AIEKit --skill fastapi-at-scale
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi-at-scale
Source: https://github.com/jayll1303/AIEKit/tree/main/.kiro/skills/fastapi-at-scale
Command: npx skills add https://github.com/jayll1303/AIEKit --skill fastapi-at-scale

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Large FastAPI projects struggle with event-loop blocking, connection pool exhaustion, brittle authentication, unreliable background processing, and fragile deployments when patterns for async databases, migrations, dependency injection, logging, and worker configuration are missing. This Skill provides clear, production-ready patterns and diagnostic checklists to avoid performance regressions, security gaps, and operational failures as traffic and team size grow.

Core Features & Use Cases

  • Domain-driven project structure for organizing routers, services, repositories, and shared core modules.
  • Async SQLAlchemy 2.0 + Alembic async migrations with session management and pool sizing guidance to prevent connection exhaustion.
  • Auth & middleware patterns including JWT/OAuth2 flows, RBAC, rate limiting, CORS, and request ID propagation.
  • Background processing strategies: when to use FastAPI BackgroundTasks vs Celery + Redis, plus Docker Compose examples for workers.
  • Testing & observability: httpx AsyncClient fixtures, dependency overrides for tests, structured JSON logging with structlog, and health/readiness endpoints.
  • Deployment & scaling: uvicorn/gunicorn worker recommendations, Docker multi-stage builds, Kubernetes manifests, and graceful shutdown patterns.
  • Use Case: bootstrapping a medium-to-large API that needs async DB access, role-based auth, reliable background jobs, and containerized production deployment.

Quick Start

Scaffold a production-grade FastAPI project using async SQLAlchemy, Alembic migrations, JWT auth, Redis caching, Celery for background tasks, structured logging, and Docker/Kubernetes deployment configuration.

Frequently Asked Questions about fastapi-at-scale

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

FAQPage Schema
How do I prevent connection pool exhaustion when scaling FastAPI with async SQLAlchemy?

Prevent connection pool exhaustion in async SQLAlchemy by applying proper session management and pool sizing guidance. This Skill provides production-ready patterns for connection handling to avoid blocking and pool starvation as concurrent request volume grows.

What is the best way to configure Alembic for async migrations in a FastAPI application?

The best way to configure Alembic for async migrations is to use dedicated async migration patterns that match your SQLAlchemy 2.0 setup. This Skill supplies the necessary patterns to run database schema migrations reliably without blocking the event loop.

Should I use FastAPI BackgroundTasks or Celery with Redis for background processing?

Choose FastAPI BackgroundTasks for lightweight jobs and Celery with Redis for reliable, heavy background processing. This Skill provides decision strategies and Docker Compose examples to configure workers correctly for your workload.

How do I structure a large FastAPI project for domain-driven design and team scaling?

Structure large FastAPI projects by organizing code into routers, services, repositories, and shared core modules. This Skill provides a domain-driven project structure that prevents brittle code and operational failures as your team and traffic grow.

Does this approach support JWT and OAuth2 authentication with role-based access control?

Yes, this approach supports JWT and OAuth2 authentication flows along with role-based access control (RBAC). The Skill implements auth and middleware patterns including rate limiting, CORS, and request ID propagation for secure API endpoints.

How do I deploy FastAPI to Kubernetes with graceful shutdown and structured logging?

Deploy FastAPI to Kubernetes using Docker multi-stage builds and uvicorn/gunicorn worker configurations with graceful shutdown patterns. This Skill includes manifests and structlog setup for structured JSON logging, health checks, and reliable scaling.