backend: restructuring for Dependency Injection pattern