How mostafanafie/swiftui-mvvm-di works
Main Components
• Application Entry Point:
– Represent the App’s lifecycle (ModularSwiftUIApp.swift and AppDelegate.swift) showing the initialization of the DI container and the starting point for SwiftUI.
• UI Layer (View Layer):
– Include separate modules for the UI such as CharacterList and CharacterDetails.
– Within each module, denote the SwiftUI views and how these views are bound to their respective ViewModels.
• ViewModel Layer (MVVM Pattern):
– For each UI module (like CharacterList and CharacterDetails), highlight their ViewModels.
– Represent how these VMs use separate Use Cases for business logic.
• Model/Domain Layer:
– Indicate models related to characters under CharacterModels, likely used across modules.
• Common Infrastructure:
– Networking:
▫ Show the Common/Networking and Common/NetworkingInterface components that handle API calls.
▫ Indicate HTTP Client (URLSessionClient.swift) and request/response classes.
– Dependency Injection (DI) Container:
▫ Include the DI folder (AppContainer, CharacterDetailsContainer, CharactersListContainer) that wires together dependencies.
– Utilities:
▫ List helper extensions like view helpers for navigation, error alerts, etc.
• Navigation / Coordinator:
– Emphasize the Coordinator pattern implemented in the Common/Coordinator folder.
– Show how the CharacterCoordinator is used to manage navigation between different screens.
• External Dependencies:
– Mark integration with external libraries such as Swinject (for DI) and Kingfisher (for image downloading and caching).
Relationships and Interactions
• Data Flow:
– Illustrate that the UI invokes actions in ViewModels, which in turn call UseCases to fetch data via the Networking layer.
• DI and IoC:
– Display how the DI container is responsible for resolving dependencies between ViewModels, UseCases, Network Clients, and Coordinators.
• Navigation Flow:
– Map out Navigator/Coordinator responsibilities that trigger navigation between the CharacterList view and the CharacterDetails view.
Architectural Patterns and Design Principles
• Modularization:
– Distinct modules (CharacterList, CharacterDetails, CharacterModels) reinforce separation of concerns.
– Emphasize how each module encapsulates its own networking, business logic, and UI components.
• MVVM:
• Dependency Injection and IoC:
– Show the central DI container and its role in constructing and providing dependencies.
• Coordinator Pattern:
– Illustrate the navigation flow handled by the Coordinator.
Relevant Technologies, Frameworks, and Libraries
• SwiftUI for UI rendering.
• MVVM for organizing presentation logic.
• Swift Package Manager as the dependency manager, coordinating package-based submodules (common libraries like Networking and Utilities are built as Swift Packages).
• External Libraries:
– Swinject for dependency management.
– Kingfisher for image caching.