← ClaudeAtlas

python-patternslisted

Python backend patterns: layered architecture, async I/O, dependency injection, repository/service separation. TRIGGER when: creating routes, models, schemas, or services in a Python backend. SKIP: REST contract design (use api-design); schema/index tuning (use database-optimization). (Examples: FastAPI + SQLAlchemy + Pydantic.)
komluk/scaffolding · ★ 15 · API & Backend · score 75
Install: claude install-skill komluk/scaffolding
# Python Backend Patterns Skill ## Purpose Best practices for Python backend development: layered architecture, async I/O, dependency injection, and clear separation between HTTP handling, business logic, and data access. The concrete examples below use FastAPI, SQLAlchemy, and Pydantic, but the patterns apply to any Python web framework, ORM, and validation library. ## Auto-Invoke Triggers - Creating backend routes / endpoints - Working with ORM models - Implementing async operations - Creating request/response validation schemas --- ## Layer Responsibilities | Layer | Responsibility | |-------|----------------| | **Endpoints** | HTTP handling, request/response | | **Services** | Business logic, orchestration | | **Repositories** | Data access, queries | | **Models** | Database schema | | **Schemas** | Data validation, serialization | These layers are framework-agnostic — keep HTTP concerns, business rules, and data access in separate modules regardless of which framework/ORM you use. --- ## Example: FastAPI + SQLAlchemy + Pydantic (illustrative) > Illustrative — this is one concrete stack shown as an example. Substitute your > framework's equivalents (any ASGI/WSGI framework, ORM, and validation library). > The layering and separation-of-concerns patterns above are the reusable part. ### Project Structure ``` app/ └── backend/ ├── app/ │ ├── main.py # FastAPI app initialization │ ├── config.py # Settings (pydantic-settings)