fastapi-templates

Create FastAPI projects with async patterns, dependency injection, and layered architecture.

Updated Nov 30, 2025
One-click install
npx skills add https://github.com/Amakaflow/amakaflow-dev-workspace --skill fastapi-templates-amakaflow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi-templates
Source: https://github.com/Amakaflow/amakaflow-dev-workspace/tree/main/.claude/skills/fastapi-templates
Command: npx skills add https://github.com/Amakaflow/amakaflow-dev-workspace --skill fastapi-templates-amakaflow

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve? Setting up a new FastAPI backend from scratch involves many architectural decisions—project layout, async database sessions, authentication, testing—that are easy to get wrong and tedious to repeat across projects. ## Core Features & Use Cases - Project Scaffolding: Provides a layered directory structure separating API routes, services, repositories, models, and Pydantic schemas. - Async Patterns: Includes async SQLAlchemy session management, lifespan events, and async route handlers. - Auth & Security: Implements JWT token creation, password hashing with bcrypt, and OAuth2 dependency injection. - Testing Setup: Supplies pytest fixtures with in-memory SQLite and dependency overrides for integration tests. - Use Case: When starting a new microservice, use this Skill to generate a complete FastAPI application with user CRUD endpoints, JWT authentication, and a working test suite. ## Quick Start Create a new FastAPI project with async PostgreSQL support, JWT authentication, and a user management endpoint.

Frequently Asked Questions about fastapi-templates

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

FAQPage Schema
How do I structure a FastAPI project for production?

Organize code into layers: api/ for routes, services/ for business logic, repositories/ for data access, models/ for SQLAlchemy tables, and schemas/ for Pydantic validation. This separation keeps route handlers thin and makes each layer independently testable.

How to use async database sessions in FastAPI?

Create an async engine with create_async_engine and an AsyncSession factory, then expose a get_db dependency that yields sessions with automatic commit, rollback, and close handling. Inject it into routes using Depends(get_db).

Does FastAPI support JWT authentication out of the box?

FastAPI provides OAuth2PasswordBearer for token extraction but not JWT encoding itself. Combine it with python-jose for token signing and passlib with bcrypt for password hashing, as shown in the security module.

How do I test FastAPI endpoints with a test database?

Override the get_db dependency using app.dependency_overrides to inject a session backed by in-memory SQLite via aiosqlite. Then use httpx AsyncClient with pytest-asyncio fixtures to run requests against the app.

What are common mistakes when building async FastAPI apps?

Common pitfalls include calling synchronous database drivers inside async handlers, putting business logic directly in route functions, and failing to properly manage session lifecycles. Use async drivers throughout and delegate logic to a service layer.