fastapi-templates

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

Updated Apr 29, 2026
One-click install
npx skills add https://github.com/iJosueeh/itera-workspace --skill fastapi-templates-ijosueeh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi-templates
Source: https://github.com/iJosueeh/itera-workspace/tree/main/.agents/skills/fastapi-templates
Command: npx skills add https://github.com/iJosueeh/itera-workspace --skill fastapi-templates-ijosueeh

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (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 fixtures—that are easy to get wrong. This Skill provides proven project structures and implementation patterns so you can scaffold a well-organized async API without reinventing the boilerplate. ## Core Features & Use Cases - Layered Project Structure: Standard layout separating API routes, services, repositories, models, and Pydantic schemas for maintainable codebases. - Async Implementation Patterns: Complete examples for async SQLAlchemy sessions, CRUD repositories, service layers, JWT authentication, and dependency injection with Depends. - Testing Setup: Ready-to-use pytest fixtures with httpx AsyncClient and in-memory SQLite for testing async endpoints. - Use Case: You need to build a new microservice with user authentication and CRUD endpoints. Use this Skill to generate the full project skeleton with repository pattern, JWT auth, and tests already wired together. ## Quick Start Ask the AI to scaffold a new FastAPI project with async database support, JWT authentication, and a user CRUD module using this skill.

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 and dependencies, core/ for config and database setup, models/ for SQLAlchemy models, schemas/ for Pydantic types, services/ for business logic, and repositories/ for data access. This separation keeps endpoints thin and logic testable.

How to implement async database sessions in FastAPI with SQLAlchemy?

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

How do I add JWT authentication to FastAPI endpoints?

Use python-jose to encode and decode tokens, passlib for password hashing, and OAuth2PasswordBearer as a dependency. A get_current_user dependency decodes the token, loads the user from the repository, and raises 401 on invalid credentials.

How to test async FastAPI endpoints with pytest?

Use httpx AsyncClient with the app, override the get_db dependency to point at an in-memory SQLite database via aiosqlite, and define async fixtures for the session and client. Mark tests with pytest.mark.asyncio.

What is the repository pattern in FastAPI and when should I use it?

The repository pattern wraps database queries in generic CRUD classes (get, create, update, delete) so services never touch SQLAlchemy directly. Use it when you want testable data access and consistent query logic across multiple models.