/OfflineFirstAppMechanism

Developed offline first app mechanism using android architecture(Room, WorkManager, Navigation, View Binding, View Model,etc), Dagger-Hilt, Firestore Cloud DB, Coroutines, Clean Architecture using MVVM, Multi-Module Setup and foundation(Android KTX) components.

Primary LanguageKotlin

OfflineFirstAppMechanism

Developed offline first app mechanism using android architecture(Room, WorkManager, Navigation, View Binding, View Model,etc), Dagger-Hilt, Firestore Cloud DB, Coroutines, Clean Architecture using MVVM, Multi-Module Setup and foundation(Android KTX) components.

Libraries Used

  • Database

    • Room DB for local caching
    • Firestore for cloud DB storage
  • Foreground and Background Sync Handling

    • WorkManager -> Workmanager used along with coroutine (CoroutineWorker) and Dagger-Hilt (HiltWorker)
  • Dependency Injection

    • Dagger Hilt
  • Routing

    • Navigation
    • Arguments passed between screens using navigation
  • Communication between app layers

    • Kotlin Coroutines for interacting between ViewModel, UseCases and Room DB
    • Broadcast receiver for receiving updates when work manager finishes syncing a job
    • WorkManager with live data in viewmodel to show updates on ui

Other

  • ViewBinding
  • Clean Architecture using MVVM
  • Multi-Module Setup -> Network and Core module are completely independent of each other. App module depends on Network and Core module
  • Kotlin Coroutines
  • Android KTX

Single Source of Truth

I have used two ways to handle scenario when syncing of a comment fails (can use either of below by uncommenting the commented way).

  1. Delete comment from local db directly if syncing fails to maintain data integrity between local and remote DB.
  2. Change status of isSync variable (0 -> not synced, 1 -> synced, 2 -> failed to sync) which will change color of comment text to red and also add a strike over the text.

Architecture Used

architecture

Offline Sync Scenarios

Note :- Green Color -> Comment is synced, Grey Color -> Comment is yet to be synced, Red Color with strike -> Comment failed to sync

  • App running, no sync failure, internet available
Screen.Recording.2022-05-27.at.12.29.00.AM.mov
  • App running, no sync failure, at first network is disconnected and later its connected to sync
Screen.Recording.2022-05-27.at.12.35.41.AM.mov
  • App not running, no sync failure, network connected later to sync jobs when app is not running/killed.
    • Step 1 :- At first network will be disconnected and will add jobs to sync
    • Step 2 :- Kill (not even in background/recently opened apps) app and then connect to network to sync jobs.
    • Step 3 :- Disconnect network again and open app to check if jobs were synced when app was not running.
Scenario.3.mp4
  • App running, firebase rules changed to simulate sync failure, internet available
Screen.Recording.2022-05-27.at.12.53.21.AM.mov

App Screenshots

Screenshot 2022-05-27 at 12 18 36 AM

Screenshot 2022-05-27 at 12 18 49 AM

Screenshot 2022-05-27 at 12 19 00 AM