_db_engine is not available when register_starlette_routes() is called (it's set later during lifespan startup). Store the app reference instead and access app.state._db_engine lazily.