fastapi-development

Implements layered FastAPI backends with SQLAlchemy, Pydantic, JWT auth, and Alembic migrations.

Updated Aug 15, 2026
One-click install
npx skills add https://github.com/jacksonlee-tw/mystock-vue --skill fastapi-development-jacksonlee-tw
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: fastapi-development
Source: https://github.com/jacksonlee-tw/mystock-vue/tree/main/mystock-analysis/.github/skills/fastapi-development
Command: npx skills add https://github.com/jacksonlee-tw/mystock-vue --skill fastapi-development-jacksonlee-tw

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building a FastAPI backend without consistent architecture leads to tangled routers, duplicated database logic, and inconsistent API responses. This Skill enforces a proven Router-Service-Repository-Model-Schema layered structure so every endpoint follows the same conventions. ## Core Features & Use Cases - Layered Architecture Patterns: Provides complete code templates for Router, Service, Repository, Model, and Schema layers with clear responsibility boundaries and naming conventions. - Full-Stack Alignment: Defines pagination, unified ApiResponse/ErrorResponse formats, and CORS setup that map directly to a PrimeVue frontend's DataTable lazy-loading expectations. - Production Essentials: Covers JWT authentication, global exception handlers, async SQLAlchemy sessions, Alembic migrations, and pytest async test fixtures. - Use Case: When asked to "add a new API" for a weighing record module, the Skill generates the model, Pydantic schemas, repository, service, and router following the exact project conventions, including pagination and error handling. ## Quick Start Ask the AI to create a new FastAPI endpoint for a resource, and it will generate the full layered implementation following this Skill's architecture.

Frequently Asked Questions about fastapi-development

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

FAQPage Schema
How do I structure a FastAPI project with clean architecture?▼

Organize code into five layers: routers handle HTTP requests, services contain business logic, repositories perform database queries, models define SQLAlchemy entities, and schemas define Pydantic DTOs. Each layer only calls the layer below it, keeping concerns separated.

How to implement pagination in FastAPI with SQLAlchemy?▼

Accept page and size query parameters, run a count query for total elements, then apply offset and limit to the select statement. Return a PageResponse containing content, total_elements, total_pages, page, and size to match frontend table components.

Does FastAPI support async SQLAlchemy database sessions?▼

Yes, SQLAlchemy 2.0 provides create_async_engine and async_sessionmaker for fully async database access. Inject sessions into routes via a get_db dependency that yields an AsyncSession and rolls back on exceptions.

How do I add JWT authentication to FastAPI endpoints?▼

Create tokens with python-jose using a secret key and expiry, then protect routes with an OAuth2PasswordBearer dependency that decodes the token and loads the current user. Raise a custom AuthenticationError handled globally as a 401 response.

Why use Alembic for FastAPI database migrations?▼

Alembic tracks schema changes as versioned migration scripts generated from your SQLAlchemy models. Run alembic revision --autogenerate to create migrations and alembic upgrade head to apply them, ensuring all models are imported in env.py.