Managing App-Lifetime Resources in FastAPI with Lifespan Context Managers
Use FastAPI lifespan context managers to initialize app-scoped resources once at startup and guarantee cleanup on shutdown, exposing them via dependency injection without globals.