Global (database) dependencies in FastAPI, done right with lifespans

A deep dive into using ASGI lifespan to safely manage shared state in FastAPI, without falling back on globals.