/Movies

Includes modular app architecture, version catalog, navigation, paging3, hilt, retrofit, okhttp, room, coil, coroutines, flow, r8...

Primary LanguageKotlinMIT LicenseMIT

Movies

This project showcases a modern approach to Android application development using Kotlin and the latest technology stack and focusing on listing movies using TMDB API.

📸 Screenshots

Screenshot

🛠️ Setup

API_KEY = xxxxxxxxxxxxxxxxxxx

📐 Architecture

  • Android Architecture Components - is a collection of libraries that help you design robust, testable, and maintainable apps.
  • Model-View-ViewModel (MVVM) - is a software architectural pattern that separates the user interface logic (View) from the application's business logic and data (Model), facilitating separation of concerns using an intermediary component called ViewModel.
  • Modular App Architecture - is an architectural approach where a project is divided into multiple modules, each focusing on a specific aspect or functionality, promoting modularization and better organization of code.
  • S.O.L.I.D - design principles intended to make software designs more understandable, flexible and maintainable.
  • Clean Architecture - is an architectural approach in software projects that ensures code cleanliness, flexibility, and maintainability by separating business logic from external dependencies.

Modules

Modules are collection of source files and build settings that allow you to divide a project into discrete units of functionality. In this case apart from dividing by functionality/responsibility, existing the following dependence between them :

App Module

The :app module is an com.android.application, which is needed to create the app bundle. It is also responsible for initiating the dependency modules (Hilt) and another project global libraries, differentiating especially between different app environments.

Data Module

The :data module represents the data layer of the application. This module provides access to both local and remote data sources, manages data models and mappings, and handles data streams. Additionally, repository classes in this module manage the interaction and business logic between data sources. This architecture is used to ensure data management within the application and abstract the data layer from other modules. Also, it contains unit test about this structures.

Domain Module

The :domain module represents the domain layer of the application. Domain module contains the core logic of the application and typically defines the basic functionalities, business rules, and data management. This module represents the core logic of the application and usually communicates with other layers (data, view). Includes domain models, use cases and interface for interaction with data module. This module provides the core functionality of the application and reduces dependencies between other modules. Also, it contains unit test about this structures.

Common-ui Module

The :common-ui module contains common structures used in the feature modules. In the res directory, there are drawable items, font, navigation graph, values (colors, strings) files.

Common-test Module

The :common-test module contains common structures used when writing tests in other modules. There is an object DataPlaceholder used for fake data and a class to create TestDispatcher for rule in coroutine test.

Feature-main Module

The :feature-main module contains the structures related to the main screen of the application. Main screen is the greeting screen when the application is started. Feature-main module contains the following structures related to main: fragment and its xml design, viewmodel and its unit test.

Feature-fav Module

The :feature-fav module contains the structures related to the favorites screen of application. Favorites screen is the screen that lists the movies that have been added as favorites. Feature-fav module contains the following structures related to favorites: fragment and its xml design, viewmodel and its unit test.

Feature-details Module

The :feature-details module contains the structures related to the details screen of the application. The details screen is a screen that can be navigated by clicking on the movie card from the main screen or favorite screens, contains more information about the movie, and allows us to add or remove the movie to favorites. The feature-details module contains the following structures related to details: fragment and its xml design, viewmodel and its unit test.

🏭 Tech Stacks

Mainly on:

  • Kotlin - Kotlin is a modern but already mature programming language designed to make developers happier. It's concise, safe, interoperable with Java and other languages, and provides many ways to reuse code between multiple platforms for productive programming.

  • Gradle Kotlin DSL - Gradle’s Kotlin DSL provides an alternative syntax to the traditional Groovy DSL with an enhanced editing experience in supported IDEs, with superior content assist, refactoring, documentation, and more.

  • KSP - KSP (Kotlin Symbol Processing) is a Kotlin-first alternative to kapt. KSP analyzes Kotlin code directly, which is up to 2x faster.

  • Version Catalog - Gradle version catalogs enable you to add and maintain dependencies and plugins in a scalable way. Using Gradle version catalogs makes managing dependencies and plugins easier when you have multiple modules.

Patterns

  • Repository Pattern - The Repository Pattern is one of the most popular patterns to create an enterprise level application. It restricts us to work directly with the data in the application and creates new layers for database operations, business logic, and the application's UI.

  • UseCase Pattern - This pattern means to convert and pass user actions to inner layers of the application.

  • Observer Pattern - The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.

Dependencies

  • Jetpack :

    • Android KTX - provide concise, idiomatic Kotlin to Jetpack and Android platform APIs.

    • AndroidX - major improvement to the original Android Support Library, which is no longer maintained.

    • Data Binding - allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically.

    • Fragment - represents a segment of a user interface or behavior within an activity, allowing for modularization and reusability of UI components and logic in Android.

    • Lifecycle - perform actions in response to a change in the lifecycle status of another component, such as activities and fragments.

    • ViewModel - designed to store and manage UI-related data in a lifecycle conscious way. The ViewModel class allows data to survive configuration changes such as screen rotations.

    • Hilt - provides a standard way to incorporate Dagger dependency injection into an Android application.

    • Paging3 - helps you load and display pages of data from a larger dataset from local storage or over network.

    • Room - is an Android library that provides an abstraction layer over SQLite to allow for more robust database access while leveraging the power of SQLite database queries.

    • Navigation - is a component and library in Android that simplifies and manages navigation between screens in applications.

  • Retrofit - is a type-safe HTTP client for Android and Java that simplifies the process of making network requests and handling REST APIs by allowing developers to define API interfaces with annotated methods.

  • OkHttp-Logging-Interceptor - is a tool used to intercept, modify, and process HTTP requests and responses, enabling customization of network requests by adding customized behaviors.

  • Gson - makes it easy to parse JSON into Kotlin objects.

  • Coroutines - managing background threads with simplified code and reducing needs for callbacks.

  • Flow - is a cold asynchronous data stream that sequentially emits values and completes normally or with an exception.

  • StateFlow - is a state-holder observable flow that emits the current and new state updates to its collectors.

  • Coil - is an image loading library for Android backed by Kotlin Coroutines.

  • R8 - is a code shrinker and optimizer tool used in Android development to reduce the size of the application's code and improve performance by removing unused code and applying various optimizations during the build process.

  • LeakCanary - is a memory leak detection library for Android.

  • Ktlint - an anti-bikeshedding Kotlin linter with built-in formatter.

  • Detekt - a static code analysis tool for the Kotlin programming language.

  • Test :

    • AndroidX - the androidx test library provides an extensive framework for testing Android apps.

    • JUnit - is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.

    • Mockito - is a most popular Mocking framework for unit tests written in Java.

    • Mockk - provides DSL to mock behavior. Built from zero to fit Kotlin language.

    • Turbine - is a small testing library for kotlinx.coroutines Flow

    • Truth - is a library for performing assertions in tests.