advanced-alchemy-fastapi
Installation
SKILL.md
FastAPI
Execution Workflow
- Configure
SQLAlchemyAsyncConfigand attachAdvancedAlchemyto the FastAPI app. - Build request-scoped session dependencies with
Depends(alchemy.provide_session()). - Provide services through async generators and
Service.new(session=...)context managers. - Keep routers thin and return service-converted schema objects or paginated schema collections.
- Register routers only after the service and dependency layer is coherent.
Implementation Rules
- Use
AnnotatedplusDependsfor session and service injection to keep signatures explicit. - Set
commit_modeintentionally; do not rely on implicit transaction assumptions. - Keep
response_modelaligned with the schema returned byto_schema(). - Avoid passing ORM instances directly through FastAPI responses.