How cronos14/demoplatzi works
Main Components
• Presentation Layer (UI):
• Located primarily in the “app” module.
• Contains Activities, Fragments (e.g., CardsFragment, CardDetailFragment, DeckFragment) and ViewModels.
• Includes the Component Adapter system (adapter/factory/viewholder) for dynamic views.
• Domain Layer (Business Logic):
• Found in the “domain” module.
• Contains use cases (e.g., CardUseCase, DeckUseCase), repository interfaces, error handling (CardError), and data models (Card, MonsterCard, SpellCard, TrapCard).
• Captures core business rules, independent of UI and external data sources.
• Data Layer (Infrastructure):
• Found in the “data” module.
• Implements data sources (both remote and local), DAOs, Room database (AppDatabase), API interactions, and paging data source.
• Contains the Repository implementations (CardRepositoryImp and DeckRepositoryImp).
• Dependency Injection (DI) Module:
• Located in the “di” module.
• Contains modules for database, network, use cases, and view models.
• Ensures that dependencies are wired up correctly between UI, data, and domain layers.
Relationships and Interactions
• The Presentation Layer (UI) interacts with its ViewModels, which in turn call the use cases found in the Domain Layer.
• The Domain Layer (use cases) interacts with repository interfaces that abstract the data sources.
• The Data Layer provides concrete implementations of these repository interfaces and handles data fetching from local (Room database) and remote sources (API calls).
• The DI Module ties everything together using Hilt, ensuring that ViewModels, use cases, and repository implementations are injected where needed.
Key Architectural Patterns & Principles
• MVVM pattern is clearly applied in the separation between UI (Activities/Fragments), ViewModels, and business logic.
• Clean Architecture is observed by dividing the project into distinct modules – presentation, domain, and data – which reduces coupling.
• Dependency Injection is central using Hilt for modular configuration.
• Various design patterns (Adapter and Factory) are used for dynamically creating and managing UI components (e.g., the Component Adapter system).