python-fastapi-development
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePython/FastAPI Development Workflow
Python/FastAPI 开发工作流
Overview
概述
Specialized workflow for building production-ready Python backends with FastAPI, featuring async patterns, SQLAlchemy ORM, Pydantic validation, and comprehensive API patterns.
这是用于构建生产级Python后端的专用工作流,基于FastAPI,涵盖异步模式、SQLAlchemy ORM、Pydantic验证及全面的API模式。
When to Use This Workflow
何时使用此工作流
Use this workflow when:
- Building new REST APIs with FastAPI
- Creating async Python backends
- Implementing database integration with SQLAlchemy
- Setting up API authentication
- Developing microservices
在以下场景使用此工作流:
- 基于FastAPI构建新的REST API
- 创建异步Python后端
- 实现与SQLAlchemy的数据库集成
- 搭建API认证机制
- 开发微服务
Workflow Phases
工作流阶段
Phase 1: Project Setup
阶段1:项目搭建
Skills to Invoke
可调用的技能
- - Application scaffolding
app-builder - - Python scaffolding
python-development-python-scaffold - - FastAPI templates
fastapi-templates - - Package management
uv-package-manager
- - 应用脚手架生成
app-builder - - Python项目脚手架
python-development-python-scaffold - - FastAPI模板
fastapi-templates - - 包管理
uv-package-manager
Actions
操作步骤
- Set up Python environment (uv/poetry)
- Create project structure
- Configure FastAPI app
- Set up logging
- Configure environment variables
- 搭建Python环境(uv/poetry)
- 创建项目结构
- 配置FastAPI应用
- 搭建日志系统
- 配置环境变量
Copy-Paste Prompts
可复制粘贴的提示词
Use @fastapi-templates to scaffold a new FastAPI projectUse @python-development-python-scaffold to set up Python project structureUse @fastapi-templates to scaffold a new FastAPI projectUse @python-development-python-scaffold to set up Python project structurePhase 2: Database Setup
阶段2:数据库搭建
Skills to Invoke
可调用的技能
- - Prisma ORM (alternative)
prisma-expert - - Schema design
database-design - - PostgreSQL setup
postgresql - - Pydantic models
pydantic-models-py
- - Prisma ORM(替代方案)
prisma-expert - - 数据库 schema 设计
database-design - - PostgreSQL 搭建
postgresql - - Pydantic 模型
pydantic-models-py
Actions
操作步骤
- Design database schema
- Set up SQLAlchemy models
- Create database connection
- Configure migrations (Alembic)
- Set up session management
- 设计数据库 schema
- 搭建SQLAlchemy模型
- 创建数据库连接
- 配置迁移工具(Alembic)
- 搭建会话管理
Copy-Paste Prompts
可复制粘贴的提示词
Use @database-design to design PostgreSQL schemaUse @pydantic-models-py to create Pydantic models for APIUse @database-design to design PostgreSQL schemaUse @pydantic-models-py to create Pydantic models for APIPhase 3: API Routes
阶段3:API路由
Skills to Invoke
可调用的技能
- - FastAPI routers
fastapi-router-py - - API design
api-design-principles - - API patterns
api-patterns
- - FastAPI 路由
fastapi-router-py - - API设计原则
api-design-principles - - API模式
api-patterns
Actions
操作步骤
- Design API endpoints
- Create API routers
- Implement CRUD operations
- Add request validation
- Configure response models
- 设计API端点
- 创建API路由
- 实现CRUD操作
- 添加请求验证
- 配置响应模型
Copy-Paste Prompts
可复制粘贴的提示词
Use @fastapi-router-py to create API endpoints with CRUD operationsUse @api-design-principles to design RESTful APIUse @fastapi-router-py to create API endpoints with CRUD operationsUse @api-design-principles to design RESTful APIPhase 4: Authentication
阶段4:认证机制
Skills to Invoke
可调用的技能
- - Authentication
auth-implementation-patterns - - API security
api-security-best-practices
- - 认证实现
auth-implementation-patterns - - API安全最佳实践
api-security-best-practices
Actions
操作步骤
- Choose auth strategy (JWT, OAuth2)
- Implement user registration
- Set up login endpoints
- Create auth middleware
- Add password hashing
- 选择认证策略(JWT、OAuth2)
- 实现用户注册功能
- 搭建登录端点
- 创建认证中间件
- 添加密码哈希处理
Copy-Paste Prompts
可复制粘贴的提示词
Use @auth-implementation-patterns to implement JWT authenticationUse @auth-implementation-patterns to implement JWT authenticationPhase 5: Error Handling
阶段5:错误处理
Skills to Invoke
可调用的技能
- - FastAPI patterns
fastapi-pro - - Error handling
error-handling-patterns
- - FastAPI进阶模式
fastapi-pro - - 错误处理模式
error-handling-patterns
Actions
操作步骤
- Create custom exceptions
- Set up exception handlers
- Implement error responses
- Add request logging
- Configure error tracking
- 创建自定义异常
- 搭建异常处理器
- 实现错误响应
- 添加请求日志
- 配置错误追踪
Copy-Paste Prompts
可复制粘贴的提示词
Use @fastapi-pro to implement comprehensive error handlingUse @fastapi-pro to implement comprehensive error handlingPhase 6: Testing
阶段6:测试
Skills to Invoke
可调用的技能
- - pytest testing
python-testing-patterns - - API testing
api-testing-observability-api-mock
- - pytest测试
python-testing-patterns - - API测试
api-testing-observability-api-mock
Actions
操作步骤
- Set up pytest
- Create test fixtures
- Write unit tests
- Implement integration tests
- Configure test database
- 搭建pytest环境
- 创建测试夹具
- 编写单元测试
- 实现集成测试
- 配置测试数据库
Copy-Paste Prompts
可复制粘贴的提示词
Use @python-testing-patterns to write pytest tests for FastAPIUse @python-testing-patterns to write pytest tests for FastAPIPhase 7: Documentation
阶段7:文档
Skills to Invoke
可调用的技能
- - API documentation
api-documenter - - OpenAPI specs
openapi-spec-generation
- - API文档生成
api-documenter - - OpenAPI规范生成
openapi-spec-generation
Actions
操作步骤
- Configure OpenAPI schema
- Add endpoint documentation
- Create usage examples
- Set up API versioning
- Generate API docs
- 配置OpenAPI schema
- 添加端点文档
- 创建使用示例
- 搭建API版本控制
- 生成API文档
Copy-Paste Prompts
可复制粘贴的提示词
Use @api-documenter to generate comprehensive API documentationUse @api-documenter to generate comprehensive API documentationPhase 8: Deployment
阶段8:部署
Skills to Invoke
可调用的技能
- - Deployment
deployment-engineer - - Containerization
docker-expert
- - 部署实施
deployment-engineer - - 容器化
docker-expert
Actions
操作步骤
- Create Dockerfile
- Set up docker-compose
- Configure production settings
- Set up reverse proxy
- Deploy to cloud
- 创建Dockerfile
- 搭建docker-compose环境
- 配置生产环境设置
- 搭建反向代理
- 部署至云端
Copy-Paste Prompts
可复制粘贴的提示词
Use @docker-expert to containerize FastAPI applicationUse @docker-expert to containerize FastAPI applicationTechnology Stack
技术栈
| Category | Technology |
|---|---|
| Framework | FastAPI |
| Language | Python 3.11+ |
| ORM | SQLAlchemy 2.0 |
| Validation | Pydantic v2 |
| Database | PostgreSQL |
| Migrations | Alembic |
| Auth | JWT, OAuth2 |
| Testing | pytest |
| 分类 | 技术 |
|---|---|
| 框架 | FastAPI |
| 语言 | Python 3.11+ |
| ORM | SQLAlchemy 2.0 |
| 验证 | Pydantic v2 |
| 数据库 | PostgreSQL |
| 迁移工具 | Alembic |
| 认证 | JWT, OAuth2 |
| 测试 | pytest |
Quality Gates
质量门禁
- All tests passing (>80% coverage)
- Type checking passes (mypy)
- Linting clean (ruff, black)
- API documentation complete
- Security scan passed
- Performance benchmarks met
- 所有测试通过(覆盖率>80%)
- 类型检查通过(mypy)
- 代码检查无问题(ruff, black)
- API文档完整
- 安全扫描通过
- 性能基准达标
Related Workflow Bundles
相关工作流包
- - General development
development - - Database operations
database - - Security testing
security-audit - - API patterns
api-development
- - 通用开发
development - - 数据库操作
database - - 安全测试
security-audit - - API模式
api-development