Move the MongoDB connection API to the root of the project since it is being used in several places besides the api module
Use a threading local object to isolate MongoDB connection between different threads but reuse the same connection in the same thread