How jeprubio/marvel-compose works
Project Type & Purpose
• This is a full-stack mobile application (client-only) that displays Marvel-themed content.
• It uses a modular approach with separate modules for core app functionality (app), feature-specific components (feature-characters and feature-comics), and shared libraries (library-components, library-marvelapi, library-tests).
• The app communicates with external services (Marvel API) using Retrofit and processes network responses with Gson.
Analyzing the File Structure
• The top-level “app” directory contains the main Android application, including the Compose UI screens, navigation, and widget implementation.
• “feature-characters” and “feature-comics” modules house feature-specific implementation:
• They include their own presentation (screens, viewmodels), domain (use cases, models), and data layers (repositories, mappers).
• “library-marvelapi” encapsulates the networking logic, API models, and dependency injection for creating API service modules.
• “library-components” provides reusable UI components (like search bars, image loaders, error messages) and theming making use of Jetpack Compose.
• Several testing directories (unit and UI tests) indicate rigorous testing of each layer with frameworks such as JUnit5, Espresso, and Shot.
Components
a. Presentation/UI Layer:
• Compose UI Views: MainActivity, navigation components (BottomNavigationBar, NavigationHost, NavigationRailBar), screens for Comic and Character lists/details, widget views.
• Reusable Components: Built in library-components.
b. ViewModel Layer (MVVM):
• Separate ViewModels for character and comic features (HeroListViewModel, DetailsViewModel, ComicListViewModel, ComicDetailsViewModel).
c. Domain Layer:
• Use Cases encapsulated in the usecase subdirectories (e.g., GetCharacterDetailsUseCase, SearchUseCase, GetComicsUseCase).
• Domain Models representing Character, Comic, etc.
d. Data Layer:
• Repositories implementations in each feature module (CharactersRepository, ComicsRepository).
• Data mappers and repository modules.
e. Networking Layer:
• Library-marvelapi handles API calls via Retrofit.
• Contains APIs, network interceptors (MarvelInterceptor, LoggingInterceptor), and exception handling.
f. Dependency Injection:
• Dagger-Hilt is used for DI (see “infrastructure/di” directories in feature modules and library-marvelapi).
g. Testing:
• The test suites (both unit and UI testing) branch out to verify the functionality of each layer.
Relationships & Interactions
• UI (Compose screens) observes data from the ViewModel layer.
• The ViewModel layer processes user interactions by triggering domain use cases.
• Domain layer encapsulates business logic and interacts with data repositories.
• Data Repositories fetch data from the network layer (via API calls in library-marvelapi) or local sources (if any caching is implemented).
• Modules interact using dependency injection, ensuring loose coupling.
• External dependencies such as Retrofit, Dagger-Hilt, and third-party libraries (Timber, Coil) should be noted as supporting technologies.
Architectural Patterns & Design Principles
• Modularization: Clear separation into app, feature modules, and shared libraries.
• MVVM: Presentation is cleanly separated from business logic.
• Clean Architecture Components: Distinct separation among presentation, domain, and data layers.
• Dependency Injection: Facilitates testability and clear dependencies.
• Use of best practices from recommended Android app architecture.