python-backend-expert

Automate FastAPI backend patterns with SQLAlchemy 2.0 and Pydantic v2.

8|1|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/hieutrtr/ai1-skills --skill python-backend-expert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-backend-expert
Source: https://github.com/hieutrtr/ai1-skills/tree/main/skills/python-backend-expert
Command: npx skills add https://github.com/hieutrtr/ai1-skills --skill python-backend-expert

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill provides a structured approach to implementing FastAPI backends with SQLAlchemy 2.0, Pydantic v2, and async patterns, enabling consistent, maintainable code across endpoints, services, and repositories.

Core Features & Use Cases

  • Guided architecture: Covers project structure, repository pattern, service layer, and domain exceptions.
  • End-to-end endpoint pattern: Demonstrates how to wire routers, services, and repositories with proper error handling and DI.
  • Migration-friendly: Includes patterns for Alembic migrations, DI, and async session usage.

Quick Start

Run through the example project structure to scaffold a FastAPI + SQLAlchemy backend and apply the recommended patterns.

Frequently Asked Questions about python-backend-expert

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

FAQPage Schema
How do I structure a FastAPI backend with SQLAlchemy 2.0 and async session management?

Structure a FastAPI backend by applying repository and service layer separation, managing AsyncSession via dependency injection, and using Pydantic v2 for data validation to ensure maintainable endpoint wiring.

What is the best way to separate services and repositories in a FastAPI application?

The best way to separate services and repositories in FastAPI is implementing a domain-driven pattern where services handle business logic, repositories manage data access, and routers wire them using dependency injection.

Does this FastAPI pattern include Alembic migration examples for SQLAlchemy 2.0?

Yes, this FastAPI pattern includes Alembic migration examples for SQLAlchemy 2.0, providing structured approaches to database schema changes alongside async session usage and dependency injection.

How do I handle domain exceptions across FastAPI endpoints and service layers?

Handle domain exceptions across FastAPI endpoints by raising custom errors within the service layer, catching them at the router level, and mapping them to proper HTTP responses using dependency injection.

Can I use Pydantic v2 for request validation in a FastAPI service layer architecture?

Yes, you can use Pydantic v2 for request validation in a FastAPI service layer architecture, wiring validated schemas directly into endpoints before passing data to async services and repositories.

When should I migrate my Python API to async repository and service patterns?

Migrate your Python API to async repository and service patterns when you need consistent codebase maintainability, non-blocking database I/O with SQLAlchemy 2.0 AsyncSession, and scalable endpoint structures.