Giter VIP home page Giter VIP logo

sagrawal2418 / newsapp-mvvm-architecture Goto Github PK

View Code? Open in Web Editor NEW
18.0 4.0 3.0 6.82 MB

MVVM Clean Architecture using Jetpack Compose, Kotlin, Retrofit, Coroutines, Flow, StateFlow, Dagger-Hilt, WorkManager, Room, Unit test and etc

Home Page: https://www.linkedin.com/in/sagrawal2418

Kotlin 97.80% CMake 1.03% C++ 1.17%
kotlin android clean-architecture-android hilt-android kotlin-coroutines-mvvm kotlin-dsl livedata-viewmodel mockito mvvm-android-kotlin newsapi

newsapp-mvvm-architecture's Introduction

Clean-MVVM-NewsApp

Architecture

An Android application built using Clean + MVVM architecture.

Major Highlights.

  • MVVM Architecture - For structuring code to separate business logic from UI concerns, promoting a clean app development environment.
  • Offline-First - Approach to app design that prioritizes device-side data management for robust offline usability.
  • StateFlow - Kotlin's state management tool that builds on Flow to make data streams lifecycle-aware.
  • Coroutines - For asynchronous programming, allowing network and heavy computations to be handled smoothly.
  • Unit Testing - For validating each component functions correctly in isolation.
  • UI Testing - For ensuring the user interface works as expected across different devices and configurations.
  • Kotlin - As a programming language.
  • Jetpack Compose - Modern toolkit for building native UI.
  • AndroidX Browser - Library for integrating web content using Chrome Custom Tabs.
  • Paging - For handling large data sets smoothly.
  • Work Manager - For managing background tasks.
  • LiveData - Lifecycle aware Observable data holder class.
  • ViewModel - To manage UI-related data in a lifecycle conscious way.
  • Flow - For handling asynchronous data streams within Android applications.
  • Retrofit - For making network calls.
  • Dagger-Hilt - For dependency injection specifically tailored for Android.
  • Room database - To cache the response for offline access.
  • C++ - Used to securely store and retrieve the base URL and API key, enhancing the security of the app’s configuration.

Description

NewsApp-MVVM-Architecture demonstrates Clean Architecture and MVVM in Android development. This app uses Kotlin, Retrofit2, Room, and Kotlin Flow, and uses C++ for secure configuration management. It’s an ideal resource to improve skills in building secure, robust Android applications.

Architecture

Architecture

Features Implemented.

App Features

  • Fetching News: Utilizes Retrofit to retrieve the latest news updates efficiently.
  • Pagination: Implemented via the Paging library to manage data loading in manageable chunks, enhancing performance.
  • Top Headlines News: Highlights the most important news, making them accessible at a glance.
  • News Based on Source: Allows users to filter news content based on their preferred news outlets.
  • News Based on Country Selection: Enables filtering news by country, catering to geo-specific audiences.
  • News Based on Language Selection: Supports multiple languages, allowing users to receive news in their preferred language.
  • Instant Search: Enhanced by Kotlin Flow operators for real-time search capabilities:
    • Debounce: Minimizes API call overload by pausing for a set time frame before executing the search.
    • Filter: Ensures only relevant results pass through the search query.
    • DistinctUntilChanged: Prevents duplicate results from being shown to the user.
    • FlatMapLatest: Ensures only the latest search inputs are considered for fetching data.
  • Offline Support: Integrates Room database for caching articles, enabling offline reading.
  • WorkManager for Periodic News Fetching: Uses WorkManager to schedule background updates of news data at regular intervals.
  • Testing Frameworks:
    • Unit Tests: Ensures that individual components function correctly, utilizing frameworks like JUnit.
    • Mockito: Facilitates mocking objects in tests to isolate and focus on the component being tested.
    • Espresso: Automates UI tests to ensure the app performs as expected on a device.
    • Turbine: A testing library for Kotlin Flows that simplifies the process of asserting flow emissions.

Complete Project Structure

Project Structure

Screenshots

NewsApp NewsApp NewsApp NewsApp NewsApp

Steps to build the app

  • Create your API key at News API
  • Navigate to the nativelib directory in your project structure.
  • Open the newsapp.cpp file.
  • Locate the getData method:
    static std::string getData(bool debugMode) {
        std::string app_secret = "Null";
        if (debugMode) {
            app_secret = "ba07a65dfd724ffd8481044578ae0cb8"; // Local API
        } else {
            app_secret = "ba07a65dfd724ffd8481044578ae0cb8"; // Live API
        }
        return app_secret;
    }
    
  • Replace the placeholder API key (ba07a65dfd724ffd8481044578ae0cb8) with your actual API key for both the local and live environments as needed.
  • Build and run the app.

Donation

If this project help you reduce time to develop, you can buy me a cup of coffee :)

Buy Me A Coffee

Thank you!

newsapp-mvvm-architecture's People

Contributors

sagrawal2418 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.