Fastapi Patterns
Production FastAPI patterns covering project layout, Pydantic v2 schemas, dependency injection, auth, and testing.
- CCM score
- 73 of 100
- skills.sh installs
- 9.4K
- GitHub stars
- 312.6K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers project layout, app factory and lifespan, pydantic-settings configuration, Pydantic v2 schemas, dependency injection, routers, and testing with httpx and pytest
- Includes sample code for
main.py,config.py,dependencies.py,schemas/user.py, androuters/users.py, with JWT-basedget_current_userand active-user checks - Enforces password confirmation through a model validator and blocks unauthorized updates by comparing the current user's ID to the target user
- Designed for teams building or reviewing FastAPI apps with SQLAlchemy async sessions and Pydantic schemas
Install
$ npx -y skills add affaan-m/ecc --skill fastapi-patterns -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
FastAPI Patterns
Modern, production-grade FastAPI development: project layout, Pydantic v2 schemas, dependency injection, async patterns, auth, transactional service methods, and testing.
Project Structure
my_app/
|-- app/
| |-- main.py # App factory, lifespan, middleware
| |-- config.py # Settings via pydantic-settings
| |-- dependencies.py # Shared FastAPI dependencies
| |-- database.py # SQLAlchemy engine + session
| |-- routers/
| | `-- users.py
| |-- models/ # SQLAlchemy ORM models
| | `-- user.py
| |-- schemas/ # Pydantic request/response schemas
| | `-- user.py
| `-- services/ # Business logic layer
| `-- user_service.py
|-- tests/
| |-- conftest.py
| `-- test_users.py
|-- pyproject.toml
`-- .env
App Factory and Lifespan
# app/main.py
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.config import settings
from app.database import engine, Base
from app.routers import users
Details
- Repository
- github.com/affaan-m/ecc
- Categories
- Python, Backend & APIs
- First seen
- Jul 14, 2026
Questions
What does the fastapi-patterns skill do for my FastAPI app?
The fastapi-patterns skill gives best practices for FastAPI development, covering project structure, Pydantic v2 schemas, dependency injection, async handlers, authentication, authorization, transactional service layers, and testing with httpx and pytest. It applies when you are building or reviewing FastAPI apps that use Pydantic schemas, dependencies, async handlers, auth, or tests.
How do I install the fastapi-patterns skill?
Run npx -y skills add affaan-m/ecc --skill fastapi-patterns -y in your project. Once installed, the agent gets the FastAPI guidance for project layout, schemas, dependencies, auth and tests.
Where does fastapi-patterns rank among Python skills?
On the Python category page, fastapi-patterns ranks in the top 25. Other skills in that category include python-performance-optimization and python-design-patterns.
Which patterns for FastAPI apps does this skill cover?
The skill shows an app factory with lifespan handling, configuration through pydantic-settings, and Pydantic v2 request and response schemas. It also covers router design, database session dependencies, and JWT-based current-user checks for protected endpoints.
More from affaan-m/ecc
All 257- Hermes Imports9.3K
- Blender Motion State Inspection9.3K
- Vite Patterns9.2K
- Agent Architecture Audit9.1K
- Error Handling9.1K
- Windows Desktop E2e9.1K
- Redis Patterns9.1K
- Mysql Patterns9.1K
- Production Audit9K
- Make Interfaces Feel Better9K
- Motion Patterns9K
- Motion Foundations9K
- Motion Advanced8.9K
- Ecc Guide8.9K
- Mle Workflow8.9K
- Django Celery8.8K
- Homelab Network Setup8.8K
- Ios Icon Gen8.8K
- Agentic Os8.8K
- Skill Stocktake8.8K
- Ui To Vue8.8K
- Network Interface Health8.7K
- Homelab Wireguard Vpn8.7K
- Netmiko Ssh Automation8.7K
Similar to Fastapi Patterns
More Pythonfastapi-templateswshobson/agents27K installsProduction-ready FastAPI project layout with async patterns, dependency injection, and tested examples.
fastapi-expertjeffallan/claude-skills6.7K installsBuild async Python REST APIs with FastAPI and Pydantic V2, including auth, database, and WebSocket patterns.
fastapi-developmentaj-geddes/useful-ai-prompts627 installsProduction-ready FastAPI guide covering async routes, Pydantic validation, dependency injection, and JWT security.
django-patternsaffaan-m/ecc15.2K installsDjango architecture patterns for scalable apps covering DRF APIs, ORM queries, caching, and middleware.
python-fastapi-developmentsickn33/agentic-awesome-skills420 installsPhased workflow for building production FastAPI backends with async patterns, SQLAlchemy, and Pydantic v2.