Coding Challenge

About the application

On launch Application will try to fetch data using the default query “fruits”. If requests fail due to internet connection or any other api related problem app will show an error UI along with a retry button.

Users can search new topics by typing on search view and the result will be shown as pagination load. Users can scroll to up to 500 images, due to api constraints (Free account - 500 image results). If the request fails during pagination, app will show a footer error screen along with a retry button.

If no result is found during a search query, app will show an empty screen.

App also have a caching mechanism implemented with retrofit.

Users can select two themes light and dark, by default the app goes with system settings. If dark mode enabled the app will be dark mode otherwise light mode.

Users can navigate settings to change themes from the toolbar option menu.

Improvement area:

  • Could have written it Jetpack compose, unfortunately I haven’t learn UI test for jetpack compose and still learning Jetpack compose
  • Could have Use room database for offline caching instead I used retrofit caching(Due to time constraints)
  • Pixabay Api key could have store more securely with secrets gradle plugins
  • Could have write more Unit/UI test to cover more scenario
  • Could have write kotlin dsl plugin to avoid redundant plugin import in module

Some Trade-off:

Like most of the applications I also have trade off decisions in this application.

  • I put the ISettingPreference use case into the preference module, I did it because in some cases apps may need SettingPreference info like theme mode in other modules. If I put ISettingPreference in the settings module, In that case I have to add settings feature module to that module. It better to have implement a utils module rather than feature module
  • All test utils are put into testutils module and in gradle they were added as implementation rather than testImplementation. And later added it as testImplementation and androidTestImplementation in the feature module so test util could be shared in every feature module and it looks like a circular dependency. But it’s in the testing layer.

Demo

Screenshots

Architecture

MVVM with clean Architecture and modular approach

Third-party libraries

Project Structure

Application Data flow

Approach Explanation

  • ViewModel separate UI and Data layer. ViewModel allows data to survive configuration changes and improve testabilities.
  • Jetpack DataBinding to bind the layouts views and it's null safe.
  • Use Kotlin DSL for gradle management - it helps better gradle management in multi module projects. And increase readability, provide code navigation and auto suggestions
  • Write code maintaining SOLID principle
  • Used mapper class to convert network response into UI model
  • Wrote Unit test and UI test to ensure app stability and performance
  • Wrote some infix function to increase unit test readability
  • Add documentation in UI test to explain test scenario and write short comment for unit test

Build tools

  • Android Studio Electric Eel | 2022.1.1
  • Gradle 7.4.0