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.
- Clone the repository:
- Open the project in Android Studio.
- Sync the project with Gradle.
- Add your
OPEN_WEATHER_API_KEY
from OpenWeatherMap to yourlocal.properties
file - Build and run the app on an emulator or physical device in Android & iOS.
- 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.
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.
- Adheres to Kotlin coding standards.
- Uses
ktlint
for code linting and formatting.
- ViewModels: Suffix with
ViewModel
(e.g.,WeatherViewModel
). - Composables: PascalCase, function-based (e.g.,
WeatherScreen
).
5 Day Weather Forecast API: https://api.openweathermap.org/data/2.5/forecast?lat={lat}&lon={lon}&appid={APIkey}
- 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.
- Platform-Specific Code: Isolated in
androidMain
andiosMain
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.
- 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.
- Add caching for offline access.
- Integrate a more detailed UI for hourly forecasts.
- Improve iOS-specific UI with SwiftUI components.
The app artifacts(Android & iOS) can be found from the latest successful action on the GitHub Actions tab