/trivago

Mobile app to search Star Wars API [Trivago Interview Solution], for the Senior Android Engineer Role

Primary LanguageKotlinMIT LicenseMIT

Trivago Interview Solution

👀 Writing Trivago Interview Solution App using Android Architecture Components, in 100% Kotlin, using Android Jetpack Components.

Prerequisites

Before every commit, make sure you run the following commands:

./codeAnalysis

To check for dependency updates, run the following command:

./gradlew dependencyUpdate

Refer to this issue, if you get any issues running the lint commands on the terminal 🚀

Background

Implement a small but scalable app which interacts with the open Star Wars API. The app should contain 2 main areas:

  • Character Search (Home Screen)
  • Character Details

The following attributes should be displayed for the character details:

  • name
  • birth year
  • height (in cm and feet/inches)
  • name (species)
  • language (species)
  • homeworld (species)
  • population (planets)
  • films (movies the character appeared in)
  • opening crawl (detailed description of each movie)

On app start, the user lands on the character search screen. The user can search for characters from the Star Wars universe. The result of the search should display a character list. When tapping on a character, details are displayed as defined above.

Tech-stack

  • Tech-stack

    • Kotlin - a cross-platform, statically typed, general-purpose programming language with type inference.
    • Coroutines - perform background operations.
    • Flow - handle the stream of data asynchronously that executes sequentially.
    • KOIN - a pragmatic lightweight dependency injection framework.
    • Retrofit - a type-safe REST client for Android.
    • Jetpack
      • Room - a persistence library provides an abstraction layer over SQLite.
      • LiveData - is an observable data holder.
      • Lifecycle - perform action when lifecycle state changes.
      • ViewModel - store and manage UI-related data in a lifecycle conscious way.
    • Stetho - application debugging tool.
    • Timber - a highly extensible android logger.
    • Leak Canary - a memory leak detection library for Android.
  • Architecture

    • MVVM - Model View View Model
  • Tests

  • Gradle

    • Gradle Kotlin DSL - For reference purposes, here's an article explaining the migration.
    • Plugins
      • Ktlint - creates convenient tasks in your Gradle project that run ktlint checks or do code auto format.
      • Detekt - a static code analysis tool for the Kotlin programming language.
      • Spotless - format java, groovy, markdown and license headers using gradle.
      • Dokka - a documentation engine for Kotlin, performing the same function as javadoc for Java.
      • jacoco - a Code Coverage Library
  • CI/CD

    • Github Actions

Dependencies

All the dependencies (external libraries) are defined in the single place - Gradle buildSrc folder. This approach allows to easily manage dependencies and use the same dependency version across all modules.

Some notable issues

This sections mentions some of the issues that I have come across:

  • UI Tests fail on an Emulator running API 26 (Android 8), and are successful on an Emulator running API 29 (Android 10)

  • dokka documentation task doesn't work when run from the top level Trivago task

  • The spotless plugin doesn't apply the license header, and the jacoco plugin doesn't work as expected. Need more research on how to set them up using gradle plugins

License

MIT License

Copyright (c) 2020 Juma Allan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 
associated documentation files (the "Software"), to deal in the Software without restriction, including 
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to 
the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial 
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
WHETHER IN AN ACTION OF  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.