How gibranhit/movies-challenge works
Project type and purpose
• This is a native Android mobile application that fetches popular movies from the TheMovieDB API.
• It follows Clean Architecture and MVVM to separate presentation, domain and data concerns.
File‐structure analysis
• Top‐level “app” module contains an Android Gradle project with src/main and src/test.
• src/main/java/mx/com/movieschallenge is organized into packages:
• base – Application class, BaseFragment, BaseViewModel
• ui – Activities, Fragments, ViewModels, Adapters, View-state models and listeners
• domain – Plain Kotlin entities (Movie), use-case interfaces and implementations
• data – Repository implementations, local (Room) and remote (Retrofit) data sources, mappers, models, DAO, database
• di – Koin module loader (ApplicationInjector)
• utils – Constants, extensions, RecyclerView helpers (pagination, decoration)
• Resources include layouts, navigation graph (Jetpack Navigation), drawables, raw animations.
Architecture layers and patterns
• Presentation layer (UI + MVVM): Fragments/Activities observe LiveData from ViewModels.
• Domain layer: pure Kotlin; UseCases encapsulate business rules, depend only on domain interfaces.
• Data layer: Repositories implement domain interfaces; choose between local (Room) and remote (Retrofit + HTTP interceptor) sources; use data mappers to convert between Data models and Domain entities.
• Dependency injection is managed by Koin.
• Coroutines handle asynchronous operations.
Main components
• App entry point: MoviesApplication → ApplicationInjector (DI container)
• Presentation: Activities/Fragments → ViewModels → UseCases
• Domain: UseCases → Domain Entities (Movie)
• Data:
• PopularMoviesRepository & FavoriteMoviesRepository
• RemoteDataSource: MovieEndpoints (Retrofit), HttpInterceptor
• LocalDataSource: MoviesDao, MoviesDataBase (Room)
• MapperData for converting between MovieData/PageMovie and Domain Movie
• External systems: TheMovieDB REST API
• Persistence: SQLite via Room
• Utility modules: extensions and RecyclerView helpers
Relationships and data flow
• ViewModel → Invoke a UseCase
• UseCase → Call Repository interface
• Repository → If network available: Retrofit → JSON → Mapper → Domain entity; Else: Room DAO → Entity → Mapper → Domain entity
• Domain entity → ViewModel → UI updates via LiveData
Architectural patterns & principles
• Clean Architecture: strict layer dependencies inward (UI → Domain → Data)
• MVVM in the presentation layer
• SOLID: each layer/component has single responsibility
• Dependency Inversion: ViewModels depend on UseCase interfaces; UseCases depend on Repository interfaces