backend-patterns

Implement FastAPI backend architectures using router-service-model patterns with SQLAlchemy async and Alembic migrations.

Updated Nov 23, 2025
One-click install
npx skills add https://github.com/Konstantin212/countOnMe --skill backend-patterns-konstantin212
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-patterns
Source: https://github.com/Konstantin212/countOnMe/tree/main/.cursor/skills/backend-patterns
Command: npx skills add https://github.com/Konstantin212/countOnMe --skill backend-patterns-konstantin212

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps developers implement scalable, well-structured backend architectures for Python services, reducing boilerplate and ensuring consistency.

Core Features & Use Cases

  • RESTful router patterns and modular organization for FastAPI apps
  • Service layer and dependency injection patterns that separate concerns
  • Device-scoping, soft-delete, and security-conscious data access
  • Configuration, migrations (Alembic), and test scaffolding

Quick Start

Inspect the backend-patterns structure and adapt the provided patterns to scaffold a new FastAPI project with a router, service, and model following the examples in this Skill unit.

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 SQLAlchemy for scalability?

Structure a FastAPI backend using a router-service-model pattern to separate concerns, paired with SQLAlchemy 2.x async data access and Alembic migrations. This enforces consistent API design, modular organization, and reduces boilerplate across modules.

What is the best way to implement device-scoped queries and soft deletes in FastAPI?

Implement device-scoped queries and soft deletes using a service layer with dependency injection in FastAPI. This separates data access logic from routes, enforcing security-conscious querying and robust error handling across modules.

How do I set up authentication and configuration for a FastAPI service?

Set up FastAPI authentication and configuration using Pydantic settings for environment management and a service layer pattern. This approach isolates security logic and configuration validation, ensuring robust and maintainable API design.

Does this backend pattern support async SQLAlchemy 2.x and Alembic migrations?

Yes, this backend pattern explicitly supports async SQLAlchemy 2.x for data access and Alembic for database migrations. It integrates these tools within a router-service-model architecture to manage schema changes and async queries safely.

How do I scaffold test scaffolding and pytest for a FastAPI project?

Scaffold pytest for a FastAPI project by applying a router-service-model pattern that isolates business logic. This allows targeted unit testing of services and data access layers, ensuring robust error handling and consistent test coverage.

Why use a service layer pattern for API design in FastAPI instead of direct database queries?

Use a service layer pattern in FastAPI to separate routing logic from data access, enforcing device-scoping and soft deletes. This reduces boilerplate, centralizes error handling, and ensures scalable, maintainable software architecture.