Skip to content

An offline-first mobile app that shows current location weather and 5-day forecast written 100% in Kotlin and Jetpack Compose using Android Jetpack Components.

License

Notifications You must be signed in to change notification settings

daniel-waiguru/WeatherApp

Repository files navigation

An offline-first mobile app that shows current location weather and 5-day forecast written 100% in Kotlin and Jetpack Compose using Android Jetpack Components.

Prerequisites

To use this app, make sure you accept the location permission request to grant the app your location details.

Tech-stack

  • Tech-stack

    • Kotlin - a modern, cross-platform, statically typed, general-purpose programming language with type inference.
    • Coroutines - lightweight threads to perform asynchronous tasks.
    • Flow - a stream of data that emits multiple values sequentially.
    • StateFlow - Flow APIs that enable flows to emit updated state and emit values to multiple consumers optimally.
    • Dagger Hilt - a dependency injection library for Android built on top of Dagger that reduces the boilerplate of doing manual injection.
    • Moshi Converter A JSON serialization converter which uses Moshi
    • Jetpack
      • Jetpack Compose - A modern toolkit for building native Android UI
      • Lifecycle - perform actions in response to a change in the lifecycle state.
      • ViewModel - store and manage UI-related data lifecycle in a conscious manner and survive configuration change.
      • Room - An ORM that provides an abstraction layer over SQLite to allow fluent database access.
    • Chucker An on-device Http inspector for Android and OkHttp.
    • Timber - a highly extensible Android logger.
    • Jacoco - A Gradle plugin that provides code coverage metrics for Java code.
  • Architecture

    • MVVM - Model View ViewModel
  • Tests

    • JUnit - a simple framework for writing repeatable tests.
    • MockK - mocking library for Kotlin
    • Turbine - A testing library for Kotlin Flows
    • Truth - A fluent assertions library for Android and Java.
  • Gradle

    • Gradle Kotlin DSL - An alternative syntax for writing Gradle build scripts using Koltin.
    • Version Catalogs - A scalable way of maintaining dependencies and plugins in a multi-module project.
    • Convention Plugins - A way to encapsulate and reuse common build configuration in Gradle, see here
    • Plugins
      • Ktlint - creates convenient tasks in your Gradle project that run ktlint checks or do code auto format.
      • Spotless - format Java, groovy, markdown, and license headers using gradle.
  • CI/CD

Dependencies

All the dependencies (external libraries) are managed using version catalogs and defined in a single place gradle/libs.versions.toml file. This is a scalable approach to manage dependencies and use the same dependency version across all modules.

Code Analysis

This repo uses ktlint, a Kotlin linter, to analyze the codebase and identify potential code style violations, code quality issues, etc. Before every commit, make sure you run the following bash script:

./codeAnalysis.sh

Before using it for the first time, you must guarantee some running permissions:

chmod +x codeAnalysis.sh

Testing

The screenshots below show test results for tests done on this repo

Unit Tests

UI Tests

App Architecture

A well-planned architecture is extremely important for any Android project; It makes it easier to maintain the app as the codebase grows and the team expands. This repo uses the MVVM pattern with clean architecture to have decoupled, testable, and maintainable code. MVVM separates views (Activities, Fragments, or Composables) from the app's business logic. However, as the codebase grows, ViewModels start bloating, and separation of responsibilities becomes hard hence the need to use MVVM with clean architecture.

Why Clean Architecture and Modularization?

  • Allows the app to scale easily
  • Easier onboarding of new team members
  • Easier to test code
  • Makes it easier to enforce coder ownership This repo uses MVVM with Clean Architecture with the following modules:

Data

Contains repositories, data sources, and model classes. This layer hides the implementation details and data sources from the outside.

Domain

This module encapsulates complex business logic or simple logic that multiple ViewModels reuse. It contains all the use cases of the application and models independent of any framework-specific dependencies and represents the business logic.

Presentation

Contains views (in this app, Composable) and ViewModels. The views post events to the ViewModel and subscribe to the updated state.

Design System

Contains reusable UI components, Color, Typography, and Theme that can be reused across various modules

Testing

This module contains test code, test resources, and test dependencies.

App Screenshots

About

An offline-first mobile app that shows current location weather and 5-day forecast written 100% in Kotlin and Jetpack Compose using Android Jetpack Components.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published