Nested modules example
Domain modules can be nested to any depth. This example shows a gateway context inside core.
File layout
Register with the full path
from archtool.dependency_injector import DependencyInjector
from archtool.global_types import AppModule
from pathlib import Path
injector = DependencyInjector(
modules_list=[AppModule("app.core.gateway")],
project_root=Path(__file__).parent.parent,
)
injector.inject()
archtool treats app.core.gateway as the bounded context and scans app.core.gateway.interfaces, app.core.gateway.services, and app.core.gateway.repos automatically.
interfaces.py
from abc import ABC, abstractmethod
class GatewayRepoABC(ABC):
@abstractmethod
def ping(self) -> bool:
...
class GatewayServiceABC(ABC):
repo: GatewayRepoABC
@abstractmethod
def check(self) -> bool:
...
repos.py
from app.core.gateway.interfaces import GatewayRepoABC
class GatewayRepo(GatewayRepoABC):
def ping(self) -> bool:
return True