Build Production-Ready Python Backends with FastAPI
Eight-phase FastAPI workflow covering project setup, database, routes, auth, error handling, testing, docs, and deployment.
Why it matters
Accelerate the development of robust, production-ready Python backends using FastAPI. This asset provides a structured workflow covering project setup, database integration, API route creation, authentication, error handling, testing, documentation, and deployment.
Outcomes
What it gets done
Scaffold new FastAPI projects with best practices.
Integrate SQLAlchemy ORM and Pydantic validation for data handling.
Implement authentication, error handling, and comprehensive testing.
Automate API documentation generation and containerized deployment.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-python-fastapi-development | bash Overview
Python/FastAPI Development Workflow
An eight-phase FastAPI development workflow covering project setup, database, routes, authentication, error handling, testing, documentation, and deployment, invoking a named sub-skill at each phase. Use when building new REST APIs with FastAPI, async Python backends, SQLAlchemy database integration, or API authentication.
What it does
This workflow builds a production-ready Python backend with FastAPI across eight phases: project setup, database setup, API routes, authentication, error handling, testing, documentation, and deployment. Each phase names specific sub-skills to invoke and gives copy-paste prompts for invoking them, and the stack is fixed to FastAPI, Python 3.11+, SQLAlchemy 2.0, Pydantic v2, PostgreSQL, Alembic migrations, JWT/OAuth2 auth, and pytest.
When to use - and when NOT to
Use this workflow when building new REST APIs with FastAPI, creating async Python backends, implementing database integration with SQLAlchemy, setting up API authentication, or developing microservices. It is not a substitute for environment-specific validation, testing, or expert review, and work should pause for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Inputs and outputs
Phase 1 (Project Setup) sets up the Python environment (uv/poetry), creates the project structure, configures the FastAPI app, sets up logging, and configures environment variables, invoking app-builder, python-development-python-scaffold, fastapi-templates, and uv-package-manager. Phase 2 (Database Setup) designs the schema, sets up SQLAlchemy models, creates the database connection, configures Alembic migrations, and sets up session management, invoking prisma-expert (as an alternative ORM), database-design, postgresql, and pydantic-models-py. Phase 3 (API Routes) designs endpoints, creates routers, implements CRUD operations, adds request validation, and configures response models, invoking fastapi-router-py, api-design-principles, and api-patterns. Phase 4 (Authentication) chooses a strategy (JWT, OAuth2), implements registration and login, creates auth middleware, and adds password hashing, invoking auth-implementation-patterns and api-security-best-practices. Phase 5 (Error Handling) creates custom exceptions, exception handlers, error responses, request logging, and error tracking, invoking fastapi-pro and error-handling-patterns. Phase 6 (Testing) sets up pytest, fixtures, unit and integration tests, and a test database, invoking python-testing-patterns and api-testing-observability-api-mock. Phase 7 (Documentation) configures the OpenAPI schema, endpoint docs, usage examples, API versioning, and generates docs, invoking api-documenter and openapi-spec-generation. Phase 8 (Deployment) creates a Dockerfile, sets up docker-compose, configures production settings and a reverse proxy, and deploys to cloud, invoking deployment-engineer and docker-expert.
Integrations
Each phase's skill is invoked with a copy-paste prompt, for example:
Use @fastapi-templates to scaffold a new FastAPI project
The technology stack is fixed: FastAPI on Python 3.11+, SQLAlchemy 2.0 for the ORM, Pydantic v2 for validation, PostgreSQL as the database, Alembic for migrations, JWT/OAuth2 for auth, and pytest for testing. Six quality gates close the workflow: all tests passing with over 80% coverage, mypy type checking passing, ruff/black linting clean, complete API documentation, a passed security scan, and met performance benchmarks. It's related to four neighboring bundles: development, database, security-audit, and api-development.
Who it's for
Backend engineers building a FastAPI service end-to-end - from project scaffolding through database integration, routing, auth, error handling, tests, docs, and deployment - who want a consistent phase-by-phase structure with named sub-skills and ready prompts rather than improvising the build order each time.
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.