Skip to content

🗞 News app built with MVVM pattern using Retrofit, Hilt, Coroutines, LiveData and Room

Notifications You must be signed in to change notification settings

eun-jegal/TopNews

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Top News

🗞 News app displaying daily top headlines and headlines by 7 different categories (general, business, techonology, entertainment, health, sports, science) built with MVVM pattern using Retrofit, Hilt and Room


     


Tech Stack

  • Minumum SDK Level: 21
  • 100% Kotlin
  • Architecture
    • MVVM Pattern: Industry-recognized software architecure pattern supported by Google
  • Jetpack Compose
    • ViewModel: Exposes data streams as a state holder
    • Lifecycle: Observes Android lifecycles and handle operations to a change in the lifecycle status
    • Room: Data Object Mapping library providing an abstract layer over SQLite
    • Navigation: Supports implementing navigation through multiple fragments
    • Hilt: Dependency injection library built on top of Dagger benefit from the compile-time correctness, runtime performance, scalability, and Android Studio support
  • Coroutines: Concurrency design pattern provided by Kotlin
  • Retrofit: Type-safe REST client for Android, Java and Kotlin developed by Square.
  • OkHttp : 3rd party library sending and receive HTTP-based network requests built on top of the Okio library
  • GSON: Java library that can be used to convert Java Objects into their JSON representation
  • Glide: Fast and efficient open source media management and image loading framework

Architecture

Top News app was built with Google's recommended modern app architecture - MVVM pattern. By separating multiple app components into two main layers - UI and Data, the app is scalable, maintainable and testable.

  • Architectural Principles
    • Separations of concerns
    • Drive UI from data models
    • Single source of truth
    • Unidirectional Data Flow

Architecture Overview

Top News is composed with three different layers - UI layer, domain layer and data layer. Each layer has app components which have different responsibilities.

UI Layer

UI layer displays the application data and serves as the primary point for user interactions. Whenever the app data changes, the UI should update to reflect changes made by either user interaction or external input.

  • The main activity and all the fragments - Feed, Browse, Saved, etc are UI elements and they display articles received from network requests and the database
  • NewsViewModel holds state and plays as a bridge between UI elements and the data layer
  • UI elements request actions to ViewModel and observer ViewModel's livedatas to automatically update screens

Data Layer

Data layer is reponsible for containing application data and business logics. The data layer is consisted of repositories and data sources. It is important to keep each repository as a single source of truth.

  • NewsRepository is a single source of truth and requests data from NewsLocalDataSource and NewsRemoteDataSource.
  • NewsLocalDataSource is a class managing the database built with Room library and NewsRemoteDataSource is a class requesting network response to NewsAPI server.

Open APIs

Top News using the NewsAPI for fetching JSON object from the server. News API provides articles and breaking news headlines from news sources and blogs across the web with JSON API.