Skip to content

A simple app implementing architecture components in android.

Notifications You must be signed in to change notification settings

keronei/mvvm-weather-app

Repository files navigation

Weather App

This is a simple app that implements the following features

  • List Cities - Comes with ~42K cities even without data connection(only 20 displayed).
  • Connect to Internet and fetch data for up to 7 days ahead, with 48 hours of hourly weather updates
  • Temperatures on the listed cities when you have connected to internet in the past 48 hours.
  • Details of city weather with listing up to 7 days ahead
  • Favouriting city from detail view, gets listed on the top
  • Notification of hourly weather update for every favourite city.
  • Ready for extension with inbuilt cities - only top 20 are displayed.

Running

You will need a key.properties file with API_KEY=abckey, you can get the key from openweathermap Configuration for playstore key if need be

Screenshots

Architecture Components Used

  • Work Manager to deliver hourly notifications for favourite cities
  • ViewModel to provide data to UI and preserve data through configuration changes
  • Room to store cities and their forecast data and ensure availability even when offline.
  • Data binding to observe city info directly from the ViewModel
  • Navigation
  • LifeCycle to know when it's sunrise/sunset for hourly notifications

App Architecture Overview

App architecture illustration

Used Layers

1. Domain

The core layer that the app is built around. This is independent of other layers which allows the models and business logic to be independent of other layers. Components of domain layer include:

  • Models: Defines the core structure of the data that will be used within the application.

  • Repositories: Interfaces that are implemented in data access implementations.

2. Data

This is responsible for selecting the proper data source for the domain layer. It contains the implementations of the repositories declared in the domain layer.

Components of data layer include:

  • Models

    • DTO Models: Defines POJO(Data classes) of network responses - e.g. Forecast.

    • Entity Models: Defines the schema of Room(SQLite) database.

  • Repositories: Responsible for exposing data to the domain layer.

  • Mappers: They perform data transformation between domain, dto and entity models.

  • Remote: This is responsible for performing network operations e.g. defining API endpoints using Retrofit.

    • APIService: Provides access to the API endpoints via network.
    • Network Data Source: Provides data from the network, you can also have LocalDataSource for handling data from the local database.
  • Local: This is responsible for performing caching operations using Room.

    • DAO Interfaces: wrappers provided by Room for writing queries on the database.

3. Presentation

The presentation layer contains components involved in showing information to the user. The main part of this layer are the views and viewModels.

Tech-stack

  • Gradle
    • Gradle Kotlin DSL - For reference purposes, here's an article explaining the migration.
    • Plugins
      • Ktlint - creates convenient tasks in your Gradle project that run ktlint checks or do code auto format.
      • Detekt - a static code analysis tool for the Kotlin programming language.
      • Spotless - format java, groovy, markdown and license headers using gradle.
      • Dokka - a documentation engine for Kotlin, performing the same function as javadoc for Java.
      • jacoco - a Code Coverage Library.
      • Gradle Versions - provides a task to determine which dependencies have updates. Additionally, the plugin checks for updates to Gradle itself.

Thanks to SimpleMaps for the comprehensive city data.

About

A simple app implementing architecture components in android.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published