← Back to list

fastapi
by jamaliumair
⭐ 0🍴 0📅 Jan 11, 2026
SKILL.md
name: fastapi description: | Complete FastAPI backend development skill with production-ready patterns for building modern APIs. Use when: (1) Creating new FastAPI projects or APIs, (2) Adding authentication (JWT, OAuth2, Argon2), (3) Setting up SQLModel ORM with relationships and migrations, (4) Adding MongoDB/NoSQL integration, (5) Implementing middleware (CORS, rate limiting, logging), (6) Creating CRUD endpoints with pagination, (7) Setting up pytest for TDD, (8) Configuring Docker, PM2, or UV for deployment, (9) Implementing event-driven patterns, observers, or microservices architecture.
FastAPI Development Skill
Production-ready patterns for modern FastAPI backend development.
Quick Reference
| Feature | Reference File |
|---|---|
| Project setup, structure, UV, PM2 | references/project-setup.md |
| JWT auth, OAuth2, Argon2 | references/authentication.md |
| SQLModel, relationships, migrations | references/sqlmodel-orm.md |
| MongoDB, Beanie ODM | references/mongodb.md |
| Middleware, CORS, rate limiting | references/middleware.md |
| Pagination, responses, schemas | references/responses.md |
| Events, observers, signals | references/events.md |
| Pytest, TDD, fixtures | references/testing.md |
| Microservices patterns | references/microservices.md |
Core Patterns
Minimal FastAPI App
from fastapi import FastAPI
from contextlib import asynccontextmanager
@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup
yield
# Shutdown
app = FastAPI(title="My API", lifespan=lifespan)
@app.get("/")
async def root():
return {"message": "Hello World"}
Standard Project Structure
project/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI app
│ ├── api/v1/ # Routers
│ ├── core/ # Config, security, database
│ ├── models/ # SQLModel/Pydantic models
│ ├── repositories/ # Data access layer
│ ├── services/ # Business logic
│ ├── schemas/ # Request/response schemas
│ └── middleware/ # Custom middleware
├── alembic/ # Migrations
├── tests/
├── pyproject.toml
└── .env
Config with Pydantic Settings
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
APP_NAME: str = "FastAPI App"
DEBUG: bool = False
DATABASE_URL: str
SECRET_KEY: str
class Config:
env_file = ".env"
settings = Settings()
Dependency Injection Pattern
from typing import Annotated
from fastapi import Depends
from sqlalchemy.ext.asyncio import AsyncSession
async def get_session() -> AsyncSession:
async with async_session() as session:
yield session
DbSession = Annotated[AsyncSession, Depends(get_session)]
@app.get("/items")
async def get_items(session: DbSession):
# session is injected
pass
Repository Pattern
class BaseRepository[T]:
def __init__(self, session: AsyncSession, model: type[T]):
self.session = session
self.model = model
async def get_by_id(self, id: int) -> T | None:
return await self.session.get(self.model, id)
async def create(self, data: dict) -> T:
obj = self.model(**data)
self.session.add(obj)
await self.session.flush()
return obj
Feature Implementation Checklist
Adding Authentication
- Read references/authentication.md
- Add security dependencies (python-jose, passlib, argon2-cffi)
- Create
core/security.pywith JWT functions - Create
core/dependencies.pywith auth dependencies - Create User model and repository
- Add auth router with login/register endpoints
Adding Database (SQLModel)
- Read references/sqlmodel-orm.md
- Add dependencies (sqlmodel, asyncpg)
- Create
core/database.pywith async engine - Define models with relationships
- Set up Alembic for migrations
- Create repositories for data access
Adding Middleware
- Read references/middleware.md
- Add CORS middleware in main.py
- Create custom middleware in
middleware/folder - Register middleware in correct order (last added = first executed)
Adding Tests
- Read references/testing.md
- Add test dependencies (pytest, pytest-asyncio, httpx)
- Create
tests/conftest.pywith fixtures - Write tests using async client
Commands
# Development
fastapi dev app/main.py
# Production
fastapi run app/main.py
# With UV
uv run fastapi dev app/main.py
# With PM2
pm2 start ecosystem.config.js
# Migrations
alembic revision --autogenerate -m "message"
alembic upgrade head
# Tests
pytest -v
pytest --cov=app tests/
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon