How hide-your-code/weather_compose_clean_architecture works
1. This is a single-module Android app (app) built with Kotlin, Jetpack Compose, MVVM, and a Clean Architecture layering split into data, domain, and presentation. The app’s purpose is to show weather for a chosen location, with current weather, hourly forecast, and 7-day forecast screens.
2. The top-level runtime entry is WeatherApplication and MainActivity, which host the Compose UI tree. Navigation/state is organized in the presentation layer via WeatherApp, WeatherAppState, and screen-specific Compose views and ViewModels for splash, home/current weather, information, search-by-text, search-by-map, settings, and seven-days weather.
3. The presentation boundary is UI-centric: Compose screens render view data, ViewModels own screen state, and BaseViewModel/ViewState provide shared state handling. Presentation models such as CurrentWeatherViewData, DayWeatherViewData, and SearchAddressViewData are distinct from domain/data models, with mapping handled by DataModelMapper and factory classes.
4. The domain layer contains the application rules and use cases. Reusable operations such as getting current location, resolving addresses, fetching current/hourly/7-day weather, and managing search history are exposed as use cases. Repository interfaces live here too, so the domain depends on abstractions rather than concrete storage/network code.
5. The data layer implements those repository interfaces. It combines remote API access, local persistence, and model/error translation. Concrete repositories are WeatherRepositoryImpl, LocationRepositoryImpl, and UserRepositoryImpl.
6. Remote weather data comes from OpenWeatherMap through Retrofit-based services: CurrentWeatherApiService and OneCallApiService. Networking is customized with an OkHttp HeaderInterceptor and a custom FlowCallAdapter/factory, which suggests API calls are adapted into Kotlin Flow for reactive streams rather than plain suspend-only responses.
7. Local persistence is split into two stores with different responsibilities: Room is used for weather search history (HistorySearchAddressDao, HistorySearchAddressEntity, WeatherDatabase), and DataStore is used for user preferences (PreferenceStorage, DataStorePreferenceStorage), including settings like dark mode / Google Map style. These are wired through dedicated DI modules.
8. Error handling is a deliberate cross-layer boundary. Remote/data failures are converted into ResponseException in the data layer, then translated into domain/presentation-friendly WeatherException via WeatherExceptionMapper and domain/exception. This keeps UI error handling decoupled from server/network specifics.
9. The app also integrates Google services for location and place search. The feature set and module naming indicate Google Maps/Places usage for selecting a location on a map and searching locations by text/address, with map style JSON assets for light/dark mode.
10. Dependency injection is organized by feature/infrastructure modules under data/di and presentation/di (NetworkModule, RoomModule, DataStoreModule, RepositoryModule, etc.). This is the main wiring boundary that connects infrastructure implementations to domain interfaces and UI consumers.
11. Supporting infrastructure includes localization and theme resources, with English/Vietnamese strings, light/dark assets, dynamic color support, and a locale change broadcast helper. The presence of raw JSON animation and Google Map style files shows the UI has some branded, custom presentation assets.
12. Quality and delivery tooling are part of the architecture: GitHub Actions handle build/lint/unit-test and internal testing deployment, Fastlane is set up for Play Store publishing, and tests live under app/src/test and androidTest. Build-time secret injection via local.properties is required for BASE_URL, API_KEY, and MAPS_API_KEY, so external service configuration is an explicit deployment dependency.
Main entry points: di DI modules · WeatherApp.kt WeatherApp · DataModelMapper.kt Data mapper · WeatherRepositoryImpl.kt WeatherRepositoryImpl
Components 34
App runtime
Android entrypoint and app-level Compose host
- WeatherApplication · Application class that initializes app-wide runtime
app/src/main/java/com/minhdtm/example/weapose/presentation/WeatherApplication.kt - MainActivity · Android activity that hosts the Compose tree
app/src/main/java/com/minhdtm/example/weapose/presentation/ui/MainActivity.kt
Presentation
Compose UI, screens, state holders, and UI models
- WeatherApp · Top-level Compose navigation and app shell
app/src/main/java/com/minhdtm/example/weapose/presentation/ui/WeatherApp.kt - App state · Coordinates screen selection and app-level state
app/src/main/java/com/minhdtm/example/weapose/presentation/ui/WeatherAppState.kt - BaseViewModel · Shared ViewModel behavior and state plumbing
app/src/main/java/com/minhdtm/example/weapose/presentation/base/BaseViewModel.kt - ViewState · Common state wrapper used across presentation
app/src/main/java/com/minhdtm/example/weapose/presentation/base/ViewState.kt - Data mapper · Maps domain/data models into presentation models
app/src/main/java/com/minhdtm/example/weapose/presentation/model/DataModelMapper.kt - Current weather · Presentation model for current weather screens
app/src/main/java/com/minhdtm/example/weapose/presentation/model/CurrentWeatherViewData.kt - Day weather · Presentation model for daily forecast content
app/src/main/java/com/minhdtm/example/weapose/presentation/model/DayWeatherViewData.kt - Search address · Presentation model for search results and history
app/src/main/java/com/minhdtm/example/weapose/presentation/model/SearchAddressViewData.kt - Splash VM · Bootstraps initial app flow
app/src/main/java/com/minhdtm/example/weapose/presentation/ui/splash/SplashViewModel.kt - Home VM · Drives current weather and hourly forecast UI
app/src/main/java/com/minhdtm/example/weapose/presentation/ui/home/CurrentWeatherViewModel.kt - Map search VM · Handles location picking from map and Google services
app/src/main/java/com/minhdtm/example/weapose/presentation/ui/search/map/SearchByMapViewModel.kt - Text search VM · Handles address search and selection from text
app/src/main/java/com/minhdtm/example/weapose/presentation/ui/search/text/SearchByTextViewModel.kt - Settings VM · Controls user preferences such as theme and map style
app/src/main/java/com/minhdtm/example/weapose/presentation/ui/settings/SettingsViewModel.kt - 7-day VM · Coordinates seven-day forecast presentation
app/src/main/java/com/minhdtm/example/weapose/presentation/ui/sevendaysweather/SevenDaysWeatherViewModel.kt - Info VM · Supplies weather information/details screen state
app/src/main/java/com/minhdtm/example/weapose/presentation/ui/infomation/InformationViewModel.kt
Domain
Use cases, repository abstractions, and business rules
- Weather repo · Abstraction for weather retrieval and search history
app/src/main/java/com/minhdtm/example/weapose/domain/repositories/WeatherRepository.kt - Location repo · Abstraction for geocoding and current location
app/src/main/java/com/minhdtm/example/weapose/domain/repositories/LocationRepository.kt - User repo · Abstraction for user preferences and app settings
app/src/main/java/com/minhdtm/example/weapose/domain/repositories/UserRepository.kt - Weather use cases · Current, hourly, and seven-day weather workflows
app/src/main/java/com/minhdtm/example/weapose/domain/usecase - Location use cases · Current location, geocoding, and text lookup workflows
app/src/main/java/com/minhdtm/example/weapose/domain/usecase - User use cases · Search history and preference management workflows
app/src/main/java/com/minhdtm/example/weapose/domain/usecase
Data
Network, local storage, repositories, and data mapping
- WeatherRepositoryImpl · Combines remote weather APIs and local translation
app/src/main/java/com/minhdtm/example/weapose/data/repositories/WeatherRepositoryImpl.kt - LocationRepositoryImpl · Implements location resolution and related data access
app/src/main/java/com/minhdtm/example/weapose/data/repositories/LocationRepositoryImpl.kt - UserRepositoryImpl · Implements preference and search-history persistence
app/src/main/java/com/minhdtm/example/weapose/data/repositories/UserRepositoryImpl.kt - Weather APIs · OpenWeatherMap API surfaces for current and One Call data
app/src/main/java/com/minhdtm/example/weapose/data/remote/apiservice - Networking · OkHttp interceptor and Flow call adapter factory
app/src/main/java/com/minhdtm/example/weapose/data/remote - Room store · Database and DAO for weather search history
app/src/main/java/com/minhdtm/example/weapose/data/local/room - DataStore · Persistent user preferences and map style settings
app/src/main/java/com/minhdtm/example/weapose/data/local/datastore - Weather exception · Converts data-layer failures into domain-friendly errors
app/src/main/java/com/minhdtm/example/weapose/data/mapper/WeatherExceptionMapper.kt
Support
Resources, build/deployment tooling, and test infrastructure
- Resources · Strings, theme assets, raw map styles, and animation
app/src/main/res - DI modules · Dependency injection modules for network, storage, repositories, and UI dispatchers
app/src/main/java/com/minhdtm/example/weapose/data/di - CI/CD · GitHub Actions and Fastlane automation for build, test, and release
.github
Connections 48
- WeatherApplication → MainActivity: launches · Application starts the activity host
- MainActivity → WeatherApp: hosts · Activity sets up the Compose app root
- WeatherApp → App state: uses · Root UI delegates navigation and app state
- WeatherApp → Splash VM: shows · Initial screen flow uses splash state
- WeatherApp → Home VM: shows · Main content is driven by home weather state
- WeatherApp → Map search VM: shows · Map-based search screen is part of app flow
- WeatherApp → Text search VM: shows · Text search screen is part of app flow
- WeatherApp → Settings VM: shows · Settings screen is part of app flow
- WeatherApp → 7-day VM: shows · Seven-day forecast screen is part of app flow
- WeatherApp → Info VM: shows · Information/details screen is part of app flow
- Home VM → Weather use cases: calls · Screen logic requests forecast data through use cases
- Map search VM → Location use cases: calls · Map search resolves location and addresses through use cases
- Text search VM → Location use cases: calls · Text search resolves locations and addresses through use cases
- Settings VM → User use cases: calls · Settings screen reads and writes user preferences
- 7-day VM → Weather use cases: calls · Forecast screen requests seven-day weather data
- Info VM → Weather use cases: calls · Information screen consumes weather-related workflows
- Weather use cases → Weather repo: depends on · Weather workflows depend on repository abstraction
- Location use cases → Location repo: depends on · Location workflows depend on repository abstraction
- User use cases → User repo: depends on · User workflows depend on repository abstraction
- WeatherRepositoryImpl → Weather APIs: fetches from · Weather repository implementation calls Retrofit services
- WeatherRepositoryImpl → Room store: reads/writes · Weather repository uses local history storage
- WeatherRepositoryImpl → Weather exception: translates errors · Repository maps transport and server failures
- LocationRepositoryImpl → Networking: uses · Location repository relies on networking/Google service integration
- UserRepositoryImpl → DataStore: persists · User repository reads and stores preferences
- UserRepositoryImpl → Room store: persists · User repository manages search history records
- Weather APIs → Networking: runs on · API services are built on custom HTTP wiring
- Room store → Resources: configured by · Room-backed features are surfaced through app resources and assets
- DataStore → Resources: drives · Preference-driven UI behavior relies on bundled resources and theme assets
- Data mapper → Current weather: builds · Maps data into current-weather presentation models
- Data mapper → Day weather: builds · Maps data into daily forecast presentation models
- Data mapper → Search address: builds · Maps data into search-address presentation models
- Home VM → Data mapper: maps via · Home UI converts domain/data models for Compose
- Map search VM → Data mapper: maps via · Map search UI converts models for rendering
- Text search VM → Data mapper: maps via · Text search UI converts models for rendering
- Settings VM → Data mapper: maps via · Settings UI may consume shared presentation mappings
- App state → BaseViewModel: shares state model · App state is consistent with common ViewModel patterns
- BaseViewModel → ViewState: emits · ViewModels expose standardized UI state
- DI modules → Weather APIs: wires · Network module constructs Retrofit services
- DI modules → Room store: wires · Room module provides database and DAO instances
- DI modules → DataStore: wires · DataStore module provides preference storage
- DI modules → WeatherRepositoryImpl: binds · Repository module connects interface to implementation
- DI modules → LocationRepositoryImpl: binds · Repository module connects interface to implementation
- DI modules → UserRepositoryImpl: binds · Repository module connects interface to implementation
- DI modules → Home VM: injects · Presentation DI supplies screen ViewModels
- DI modules → Map search VM: injects · Presentation DI supplies screen ViewModels
- DI modules → Text search VM: injects · Presentation DI supplies screen ViewModels
- DI modules → Settings VM: injects · Presentation DI supplies screen ViewModels
- DI modules → 7-day VM: injects · Presentation DI supplies screen ViewModels