from dependency_injector import containers, providers from emi_service import EMIService from emi_repository import EMIRepository from container import CoreContainer from utils.Utilities import Utilities class EMIContainer(CoreContainer): """ Container holds all the objects of the classes and their interdependencies The repository requires the database factory for saving to the database. The utilities hold external utils like sending mail, sms, s3 functionalities which may require database saving hence the repository object is injected into it. Likewise for the service which requires the repository and utilities injection as it would require those modules. """ wiring_config = containers.WiringConfiguration(packages=["applications", "authentication"]) emi_repository = providers.Factory( EMIRepository, query_results=CoreContainer.query_results ) utilities = providers.Factory( Utilities, repository=emi_repository ) emi_service = providers.Factory( EMIService, repository=emi_repository, utils=utilities )