Dependency Injection/ Singleton management

Hi,

I’m a longtime software engineer but new to python and backend. I’m wondering how developers are currently handling singletons (examples: database connection, rag index connection) in Langgraph, specifically Langgraph Platform.

I am trying to follow SOLID principles and have some sort of dependency injection, which I see is possible in python for example with FastAPI Depends().

If it’s not some dependency management system, how can I safely and in a production-friendly way, avoid global singletons? Are global singletons safe? Not sure what the implications if the langgraph platform instance is horizontally scaled.

Thanks