Skip to content

MuhamedFathy/OfflineFirstCRUD

Repository files navigation

OfflineFirstCRUD

A simple Android application created with JSONPlaceholder for demonstrating CRUD operations with offline-first functionality. The app built using Jetpack Compose, Kotlin Coroutines, and implementing a clean architecture approach with the MVVM (Model-View-ViewModel) pattern RoomDB for local storage and WorkManager for synchronizing data with the JSONPlaceholder API.

Table of Contents

Screenshots

Posts List Post Details Create Details

Posts List

Post Details

Create Post

Edit Post Refresh Posts

Edit Post

Refresh Posts

Features

  • Create (POST): Add new posts to the local database. If offline, posts are queued for synchronization when online.
  • Read (GET): Display a list of posts from the API if online or from the local database if offline.
  • Update (PUT): Edit posts locally first. Changes are synchronized with the API when online.
  • Delete (DELETE): Mark posts as deleted locally and sync deletions with the API when online.
  • Synchronization: Automatically sync data between the local database and the JSONPlaceholder API using WorkManager.
  • Offline First: Ensures a seamless user experience even without network connectivity.

Architecture

This project follows Clean Architecture principles for scalability and maintainability. It is implemented using the MVVM (Model-View-ViewModel) pattern. Key layers include:

  1. Presentation Layer: Jetpack Compose for UI and ViewModels for state management.
  2. Domain Layer: Use cases encapsulating business logic.
  3. Data Layer: Repositories interacting with both RoomDB and the JSONPlaceholder API.

Clean Architecture

Technologies Used

  • MVVM Architecture: Implements Model-View-ViewModel pattern for separation of concerns.
  • Kotlin: Official programming language for Android development.
  • Jetpack Compose: Modern toolkit for building native UI.
  • RoomDB: Local database for offline-first functionality.
  • WorkManager: For managing background synchronization tasks.
  • Retrofit: A type-safe HTTP client for API communication.
  • Kotlin Coroutines: Asynchronous programming with structured concurrency.
  • Material3 Design: UI/UX design framework.