backend-patterns

Codify FastAPI backend architecture patterns for routers, services, repositories, and models.

Updated Dec 16, 2025
One-click install
npx skills add https://github.com/adelabdelgawad/meal_request --skill backend-patterns-adelabdelgawad
Or copy as Structured Prompt for Agentβ–Ό
Please help me install this Agent Skill.
Skill: backend-patterns
Source: https://github.com/adelabdelgawad/meal_request/tree/main/.claude-plugins/fastapi-patterns/skills/backend-patterns
Command: npx skills add https://github.com/adelabdelgawad/meal_request --skill backend-patterns-adelabdelgawad

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill codifies FastAPI backend development patterns into a repeatable architecture, reducing boilerplate and enabling scalable, consistent code across routers, services, repositories, and models.

Core Features & Use Cases

  • Enforces a Router β†’ Service β†’ Repository β†’ Model layering, delivering clear ownership and testability.
  • Mandates CamelModel inheritance for all Pydantic schemas, ensuring camelCase JSON and smooth ORM conversion.
  • Promotes async data access and strictly uses domain exceptions (NotFoundError, ConflictError, ValidationError) over HTTP exceptions in services.
  • Provides a rapid blueprint for CRUD endpoints, authentication/authorization scaffolds, and robust error handling.
  • Use case: Spin up a new feature like /items with clean separation, validation, and consistent error responses.

Quick Start

Install dependencies, scaffold the feature by adding router_{feature}.py, {feature}service.py, repository{feature}.py, and corresponding models/schemas under the api/, services/, repositories/, and db/ directories, then run uvicorn app:app --reload --host 0.0.0.0 --port 8000

Frequently Asked Questions about backend-patterns

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

FAQPage Schema
How do I structure a FastAPI backend with routers, services, and repositories?β–Ό

Structure a FastAPI backend using a Router β†’ Service β†’ Repository β†’ Model layering to ensure clear ownership and testability. This pattern separates endpoint routing, business logic, and database operations for scalable code.

How do I enforce camelCase JSON responses in Pydantic schemas?β–Ό

Enforce camelCase JSON responses in Pydantic schemas by mandating CamelModel inheritance for all models. This ensures consistent camelCase JSON output and smooth ORM conversion across FastAPI projects.

Why should I use domain exceptions instead of HTTPException in FastAPI services?β–Ό

Use domain exceptions like NotFoundError, ConflictError, and ValidationError instead of HTTPException in FastAPI services to decouple business logic from HTTP protocols. This keeps the service layer testable and framework-agnostic.

How do I scaffold a new CRUD feature in FastAPI with async database operations?β–Ό

Scaffold a new CRUD feature in FastAPI by creating router, service, repository, and model files under respective directories, ensuring all database operations are async. This delivers clean separation, validation, and consistent error responses.

Should I pass the database session directly into FastAPI service classes?β–Ό

Avoid storing the database session directly in FastAPI service classes. This ensures all database operations remain async and testable.