Skip to content

islamelhady/movie-night-v2

Repository files navigation

Movie Night - Clean Architecture & MVI

Movie Night is an Android application developed using Kotlin and follows the MVI (Model-View-Intent) architectural pattern. This app offers a variety of features for movie enthusiasts, including movie search, ratings, reviews, trailer viewing, and user authentication, providing a seamless user experience. The app makes use of powerful libraries and tools such as Room, Retrofit, Dagger Hilt, Kotlin Coroutines, and Flow.

This repository contains the source code for the app and its various components, which follow modern Android development practices.

Features

  • User Authentication: Handles user sign-in and account-related functionalities.
  • Browse Movies and Series: Users can explore movies and series categorized by genre, rating, release date, and more.
  • Actor Profiles: Users can browse actors' profiles and view their past works.
  • Search for Movies, Series, or Actors: Allows users to search for specific movies, series, or actors with predictive search suggestions.
  • Reviews and Comments: Users can add and view reviews and comments on movies and series.
  • Create Custom Lists: Users can create custom lists like "Watch Later" or "Favorites".
  • Watch Trailers: Users can watch trailers of movies and series before deciding to watch them.
  • Light/Dark Theme: The app supports both light and dark themes to match user preferences.

Architecture

The app is based on the recommended architecture and the Repository pattern, with dependency inversion following Google's official architecture guidance. It follows a Clean Architecture approach, which separates the app into different layers:

Architecture Diagram:

architecture

UI (Presentation)

The UI layer handles the app's user interface and interactions. It includes activities, fragments, and XML layouts responsible for displaying information to the user and receiving user input.

View Model (Presentation)

The ViewModel layer connects the UI with the domain layer. It holds the app's UI-related data using StateFlow or SharedFlow and exposes methods for the UI to interact with. This allows the UI to respond to state changes while maintaining a clean separation between the UI and business logic.

Use Cases (Domain)

The Domain layer contains the business logic of the app. It defines the use cases and operations that the app can perform, such as searching for movies, getting movie details, managing the watchlist, and handling user reviews.

Repository (Data)

The Repository layer acts as an intermediary between the domain layer and the data sources. It fetches data from remote and local sources, such as APIs or databases, and provides the data to the domain layer. This layer abstracts the data sources and ensures that the domain layer doesn't need to know about how the data is retrieved.

Remote (Data)

The Remote data source handles data retrieval from remote servers or APIs. For example, the app fetches movie details, trailers, and reviews from the TMDB API. It is responsible for making network requests and parsing responses from the server.

Local (Data)

The Local data source manages data storage and retrieval from local databases, such as Room. It handles tasks like saving user ratings, caching movie details, storing watch history, and managing favorites. This ensures offline functionality and improves app performance by reducing the number of network requests.

StateFlow and SharedFlow

In the Presentation Layer, StateFlow and SharedFlow are used to manage the app's state and event flows efficiently.

  • StateFlow is used to represent the current state of the UI. It allows us to observe changes in the UI state in a lifecycle-safe manner, ensuring that the UI reflects the most recent data.
  • SharedFlow is used for one-off events or actions that don't represent the app’s state but are still important, such as navigation events or showing error messages.

MVI Architecture Diagram

The following diagram illustrates the flow of data in the MVI architecture:

MVI Architecture

Tech Stack

  • Kotlin The primary programming language used for Android development.
  • Material 3 Used for the latest UI components based on Google’s Material Design guidelines.
  • Jetpack Libraries
    • ViewModel Manages UI-related data lifecycle-consciously.
    • Lifecycle - "Lifecycle-aware components react to lifecycle changes in activities and fragments, helping create cleaner, more maintainable, and efficient code.
    • Room A local database for storing user ratings, movie details, watch history, etc.
    • Data Store A key-value store for storing user preferences and settings.
    • DataBinding -Binds UI components in your layouts to data sources in your app using a declarative format rather than programmatically.
    • Navigation Manages navigation between screens within the app.
    • Paging 3: Efficiently loads and displays large datasets.
  • Kotlin Coroutines Simplifies background operations and asynchronous tasks.
  • Kotlin Flow A reactive stream library to handle data and states in the app.
  • Retrofit Fetches data from the network and interacts with the TMDB API.
  • Dagger Hilt A dependency injection library for managing dependencies in the app.
  • Logging Interceptor - logs HTTP request and response data.
  • Coil - An image-loading library for Android backed by Kotlin Coroutines.

Getting Started

Follow these steps to set up and run the Movie Night V2 app locally in your Android development environment.

Prerequisites

Before running the app, make sure you have the following installed:

  • Android Studio: The official IDE for Android development.
  • Kotlin: The app is built using Kotlin.
  • Gradle: To manage dependencies.

Installation

  1. Clone the repository to your local machine:

    git clone https://github.com/islamelhady/movie-night-v2.git
  2. Open the project in Android Studio.

  3. Sync the project with Gradle by clicking Sync Now in Android Studio.

  4. Configure your TMDB API Key:

    • Create an account on TMDB and get an API key.
    • Add the key to your project’s local.properties file or as an environment variable.
  5. Build and run the app on an emulator or physical device.

Running the App

Once the project is set up, you can run it directly from Android Studio. Select your target device or emulator and click Run.


Light and Dark Theme

The app supports both Light and Dark themes, which can be toggled based on system preferences.

Light Theme

Dark Theme


About

Modern Clean Architecture made using MVI with Kotlin Coroutines, Shared Flow, State Flow, Navigation Component, Hilt, Retrofit2, Room, Use Cases, Coroutine, Pagination and Datastore Preference.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages