Git Product home page Git Product logo

kweather's Introduction

Weather

Kotlin Gradle License
Weather is an Android app for Weather with Jetpack Compose. It uses openweathermap API. It is single screen app which displays weather data for a city. There is a search function in the top app bar to search for any city and display its weather data.

πŸ“βœοΈ Architecture

The app is built with the Model-View-ViewModel (MVVM) architecture with Repository pattern which is used to separate the app's user interface, logic, and data.

  • Model: Represents the data and the business logic of the app. It's the actual data and data sources, like databases or network requests.
  • View: Represents the UI of the app. In your app, it would be the Jetpack Compose components that display the weather data to the user.
  • ViewModel: It holds the data that the View needs, exposing this data through StateFlow.
  • Repository: This is an additional layer between the ViewModel and the data source (in this case, the OpenWeatherMap API). The Repository centralizes the data fetching mechanism, so if in the future we decide to add another data source, such as a local database for offline caching, the ViewModel wouldn't need to know where the data is coming from. The Repository will handle data retrieval, whether it's from the API, local database, or other sources.

To visualize the flow:

  • User opens the app and sees the main weather screen with weather details of the default city - Munich.
  • User types a city name into the search bar.
  • The app's ViewModel, through the Repository, makes a call to the OpenWeatherMap API.
  • The API returns the weather data for the requested city.
  • The Repository passes this data to the ViewModel.
  • The ViewModel updates the View (the screen) with the fetched weather data, displaying it to the user.

In essence, this architecture ensures a separation of concerns, promoting a more scalable and maintainable codebase. It decouples the UI from the data and business logic, allowing each component to evolve independently.

πŸ›  Tech Stack

  • Kotlin - Most of the Android community uses Kotlin as their preferred choice of language.
  • Jetpack:
    • Jetpack Compose - Jetpack Compose is Android’s modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.
    • Android KTX - Android KTX is a set of Kotlin extensions that are included with Android Jetpack and other Android libraries. KTX extensions provide concise, idiomatic Kotlin to Jetpack, Android platform, and other APIs.
    • AndroidX - The androidx namespace comprises the Android Jetpack libraries. It's a major improvement to the original Android Support Library, which is no longer maintained.
    • Lifecycle - Lifecycle-aware components perform actions in response to a change in the lifecycle status of another component, such as activities and fragments. These components help you produce better-organized, and often lighter-weight code, that is easier to maintain.
    • ViewModel - The ViewModel class is a business logic or screen level state holder. It exposes state to the UI and encapsulates related business logic. Its principal advantage is that it caches state and persists it through configuration changes.
  • Dagger Hilt - A dependency injection library for Android that reduces the boilerplate of doing manual dependency injection in your project.
  • Kotlin Coroutines - A concurrency design pattern that you can use on Android to simplify code that executes asynchronously and it's the recommended way for asynchronous programming on Android.
  • Kotlin Flow - In coroutines, a flow is a type that can emit multiple values sequentially, as opposed to suspend functions that return only a single value.
  • Retrofit - Retrofit is a REST client for Java/ Kotlin and Android by Square. Its a simple network library that is used for network transactions.
  • OkHttp - OkHttp is an HTTP client. It perseveres when the network is troublesome as it will silently recover from common connection problems.
  • GSON - JSON Parser, used to parse requests on the data layer for Entities and understands Kotlin non-nullable and default parameters.
  • Logging Interceptor - An OkHttp interceptor which logs HTTP request and response data.
  • Coil- An image loading library for Android backed by Kotlin Coroutines.
  • Timber- A logger with a small, extensible API which provides utility on top of Android's normal Log class.
  • Mockk- A mocking library for Kotlin
  • Turbine- A small testing library for kotlinx.coroutines Flow

πŸ“± Screenshots

Demo

Loading.state.mp4
Demo.video.mp4
Error.state.mp4
Demo.mp4

kweather's People

Contributors

aishwarya-kamal 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.