Skip to content

WeatherApp is a Kotlin Multiplatform (KMP) project that provides a 5-day weather forecast based on the user's location. Built using Jetpack Compose Multiplatform, the app delivers a seamless UI experience on both Android and iOS platforms.

Notifications You must be signed in to change notification settings

KennethMathari/WeatherApp_KMP

Repository files navigation

🌦 Compose Multiplatform Weather App | Android | iOS

WeatherApp is a Kotlin Multiplatform (KMP) project that provides a 5-day weather forecast based on the user's location. Built using Jetpack Compose Multiplatform, the app delivers a seamless UI experience on both Android and iOS platforms.

⚙️ Installation Instructions

  1. Clone the repository:

git clone https://github.com/KennethMathari/WeatherApp_KMP

  1. Open the project in Android Studio.
  2. Sync the project with Gradle.
  3. Add your OPEN_WEATHER_API_KEY from OpenWeatherMap to your local.properties file
  4. Build and run the app on an emulator or physical device in Android & iOS.

🚀 Features

  • 5-Day Weather Forecast: View weather conditions for the next 5 days based on user's current location.
  • Dynamic Backgrounds: The app updates the background image dynamically based on the weather conditions:
    • Sunny: Clear skies with a bright and cheerful background.
    • Cloudy: Calm clouds with a soft-toned background.
    • Rainy: A wet and moody rain-themed background.
  • Cross-Platform: Runs natively on Android and iOS devices using Kotlin Multiplatform.
  • Location-Based Forecast: Automatically fetches the user's location to show accurate weather data.

🧩 Architecture

The app follows Clean Architecture principles with a MVI (Model-View-Intent) pattern to ensure modularity, scalability, and testability:

  • UI Layer: Jetpack Compose (Android & iOS) for building reactive and declarative UIs.
  • Domain Layer: Use cases encapsulating business logic.
  • Data Layer:
    • Network operations handled using Ktor.
    • JSON parsing with Kotlinx Serialization.
  • Dependency injection via Koin.

🛠 Conventions

Code Style

  • Adheres to Kotlin coding standards.
  • Uses ktlint for code linting and formatting.

Naming Conventions

  • ViewModels: Suffix with ViewModel (e.g., WeatherViewModel).
  • Composables: PascalCase, function-based (e.g., WeatherScreen).

API

5 Day Weather Forecast API: https://api.openweathermap.org/data/2.5/forecast?lat={lat}&lon={lon}&appid={APIkey}

🔌 Libraries, Plugins & Tools

  • Jetpack Compose : For building the UI in a declarative manner.
  • Github Actions : Automate CI/CD workflows and manages pipelines.
  • Koin : For dependency injection to manage dependencies efficiently.
  • Ktor : For network operations to fetch data from the API.
  • Kotlinx Serialization : Facilitates data serialization and deserialization in a format-agnostic way.
  • KtLint: creates convenient tasks in your Gradle project that run ktlint checks or do code auto format.
  • Mokkery : For mocking dependencies in tests.
  • Turbine : Specialized library for testing kotlinx.coroutines Flow.
  • Build Konfig : BuildConfig for Kotlin Multiplatform Project.
  • Compass : Kotlin Multiplatform library location toolkit for geocoding and geolocation
  • Assertk : assertions for kotlin tests

Other dependencies are listed in the build.gradle files.

📦 General Considerations

  • Platform-Specific Code: Isolated in androidMain and iosMain folders.
  • Error Handling: Network failures or invalid responses return user-friendly error screens.
  • Permissions: The app requests location permission to fetch weather data.
  • Scalability: The app design ensures it's easy to add new features or weather types.

📜 Additional Notes

  • Performance Optimization: Use of lightweight Ktor client for efficient API calls.
  • Extensibility: Adding more weather types or providers (e.g., AccuWeather) is straightforward.
  • Testing: Unit tests written to ensure correctness.

🚧 Future Improvements

  • Add caching for offline access.
  • Integrate a more detailed UI for hourly forecasts.
  • Improve iOS-specific UI with SwiftUI components.

Android Weather App Screenshots

Android

iOS Weather App Screenshots

iOS

Artifacts

The app artifacts(Android & iOS) can be found from the latest successful action on the GitHub Actions tab

About

WeatherApp is a Kotlin Multiplatform (KMP) project that provides a 5-day weather forecast based on the user's location. Built using Jetpack Compose Multiplatform, the app delivers a seamless UI experience on both Android and iOS platforms.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published