backend-fastapi

Automate secure multi-tenant FastAPI backends with SQLAlchemy 2.0 async and PostgreSQL.

Updated May 5, 2026
One-click install
npx skills add https://github.com/sonhaicoder/haiclaudeskill --skill backend-fastapi-sonhaicoder
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-fastapi
Source: https://github.com/sonhaicoder/haiclaudeskill/tree/main/skills/backend-fastapi
Command: npx skills add https://github.com/sonhaicoder/haiclaudeskill --skill backend-fastapi-sonhaicoder

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Backend FastAPI skill provides a production-ready blueprint for building a secure, multi-tenant FastAPI backend with SQLAlchemy 2.0 async support and PostgreSQL, ensuring data isolation and reliable money arithmetic.

Core Features & Use Cases

  • AUTO-TRIGGER rules to detect backend code patterns and migrations, enabling rapid, safe integration.
  • The seven hard rules enforce: shop_id filtering on all queries, decimal money handling, async HTTP calls via httpx, atomic stock updates, strict order state transitions, JWT authentication with role checks, and environment-based config via Settings.
  • Patterns such as lazy loading optimizations, safe Alembic migrations, AI gateway integration, Celery background tasks, and robust error handling for production-grade apps.
  • Typical use cases include building secure, scalable multi-tenant SaaS backends with strong data isolation, predictable money arithmetic, and maintainable deployment practices.

Quick Start

Drop this skill into your project and follow the auto-trigger and rules to bootstrap a secure, multi-tenant FastAPI backend.

Frequently Asked Questions about backend-fastapi

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

FAQPage Schema
How do I build a multi-tenant FastAPI backend with strict data isolation?

To build a multi-tenant FastAPI backend with strict data isolation, you enforce shop_id filtering on all SQLAlchemy queries. This ensures every database query is automatically scoped to a specific tenant, preventing data leakage across shops.

What is the best way to handle decimal currency and atomic inventory updates in FastAPI?

Handling decimal currency and atomic inventory updates in FastAPI requires strict decimal money handling and atomic stock updates. This guarantees precise financial arithmetic and prevents race conditions during concurrent inventory modifications.

How do I manage asynchronous database operations and HTTP calls in FastAPI?

Managing asynchronous database operations and HTTP calls in FastAPI uses SQLAlchemy 2.0 async support and httpx. This combination enables non-blocking database sessions and external API requests, maximizing application throughput.

Can I use Celery background tasks and Alembic migrations with a FastAPI backend?

Yes, you can use Celery background tasks and safe Alembic migrations with a FastAPI backend. Celery handles asynchronous background processing while Alembic manages safe, version-controlled database schema migrations for PostgreSQL.

How does JWT authentication with role checks work in a multi-tenant SaaS backend?

JWT authentication with role checks in a multi-tenant SaaS backend secures endpoints by validating JSON Web Tokens and verifying user permissions. It ensures only authorized users access specific shop resources and perform allowed actions.

Do I need environment-driven settings for AI gateway integration in FastAPI?

Yes, you need environment-driven settings for AI gateway integration in FastAPI to securely manage API keys and endpoints. Using environment-based config via Settings separates sensitive credentials from code and streamlines deployment.