# jiajunhuang-unimelb/uvapp architecture

> Architecture diagram of the GitHub repository jiajunhuang-unimelb/uvapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jiajunhuang-unimelb/uvapp
- Repository: https://github.com/jiajunhuang-unimelb/uvapp

## Overview

UVApp is an Android app for location-specific UV forecasts, place search, sun-protection guidance, and personal exposure tracking. Users view a current forecast, search or use a location, inspect hourly and daily forecasts, configure skin/SPF and notification preferences, and review saved exposure history. The documented architecture runs Compose screens through ViewModels into repository contracts, with Open-Meteo/Nominatim networking, Room caches and history, and DataStore preferences. Exposure calculation and environment classification are separate domain/platform responsibilities; source excerpts were not provided, so edges reflect README statements only.

Main entry points: [`app/src/main/java/com/example/uvapp/viewmodel/MainViewModel.kt`](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/viewmodel/MainViewModel.kt) (Main ViewModel), [`app/src/main/java/com/example/uvapp/ui/UVAppRoot.kt`](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/UVAppRoot.kt) (UI composition root), [`app/src/main/java/com/example/uvapp/data/repository/DefaultUvRepository.kt`](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/repository/DefaultUvRepository.kt) (UV repository), [`app/src/main/java/com/example/uvapp/domain/repository/ExposureHistoryRepository.kt`](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/repository/ExposureHistoryRepository.kt) (Exposure history contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Compose UI"]
  node_home["Home screen<br/>[HomeScreen.kt]"]
  node_forecast_ui["Forecast screen<br/>[ForecastScreen.kt]"]
  node_settings_ui["Settings screen<br/>[SettingsScreen.kt]"]
  node_search_ui["Search dialog<br/>[SearchDialog.kt]"]
  node_sunlog_ui["SunLog screen<br/>[SunLogScreen.kt]"]
end

subgraph group_coord["App coordination"]
  node_root["UI composition root<br/>[UVAppRoot.kt]"]
  node_main_vm["Main ViewModel<br/>[MainViewModel.kt]"]
  node_forecast_vm["Forecast ViewModel"]
  node_settings_vm["Settings ViewModel"]
end

subgraph group_domain["Domain logic"]
  node_uv_domain["UV forecast contract<br/>[UvRepository.kt]"]
  node_place_domain["Place search contract<br/>[PlaceRepository.kt]"]
  node_history_domain["Exposure history contract"]
  node_prefs_domain["Preferences contract"]
  node_exposure["Exposure calculation"]
  node_environment["Environment sensing"]
end

subgraph group_data["Data and persistence"]
  node_uv_data["UV repository"]
  node_place_data["Place repository"]
  node_room[("Room storage<br/>[AppDatabase.kt]")]
  node_history_data["History repository"]
  node_prefs_data["DataStore preferences"]
end

subgraph group_platform["Android platform"]
end

node_user(("App user"))
node_openmeteo["Open-Meteo"]
node_nominatim["Nominatim"]
node_android_sensors["Android sensors"]

node_user -->|"views"| node_home
node_user -->|"selects forecast"| node_forecast_ui
node_user -->|"configures"| node_settings_ui
node_user -->|"submits search"| node_search_ui
node_user -->|"reviews history"| node_sunlog_ui
node_root -->|"injects repositories"| node_main_vm
node_root -->|"injects repositories"| node_forecast_vm
node_root -->|"injects repositories"| node_settings_vm
node_main_vm -->|"uses forecast contract"| node_uv_domain
node_main_vm -->|"uses place contract"| node_place_domain
node_main_vm -->|"saves history"| node_history_domain
node_settings_vm -->|"persists settings"| node_prefs_domain
node_forecast_vm -->|"shares forecast state"| node_main_vm
node_uv_data -->|"fetches UV data"| node_openmeteo
node_uv_data -->|"caches readings"| node_room
node_place_data -->|"searches places"| node_nominatim
node_history_data -->|"stores history"| node_room
node_prefs_data -->|"implements contract"| node_prefs_domain
node_uv_domain -->|"implemented by"| node_uv_data
node_place_domain -->|"implemented by"| node_place_data
node_history_domain -->|"implemented by"| node_history_data
node_exposure -.->|"records exposure"| node_history_domain
node_android_sensors -.->|"provides context"| node_environment

click node_home "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/screens/HomeScreen.kt"
click node_forecast_ui "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/screens/ForecastScreen.kt"
click node_settings_ui "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/screens/SettingsScreen.kt"
click node_search_ui "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/components/SearchDialog.kt"
click node_sunlog_ui "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/screens/SunLogScreen.kt"
click node_root "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/UVAppRoot.kt"
click node_main_vm "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/viewmodel/MainViewModel.kt"
click node_forecast_vm "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/viewmodel/ForecastViewModel.kt"
click node_settings_vm "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/viewmodel/SettingsViewModel.kt"
click node_uv_domain "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/repository/UvRepository.kt"
click node_place_domain "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/repository/PlaceRepository.kt"
click node_history_domain "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/repository/ExposureHistoryRepository.kt"
click node_prefs_domain "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/repository/UserPreferencesRepository.kt"
click node_exposure "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/exposure/ExposureCalculator.kt"
click node_environment "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/environment/ExposureMonitoringController.kt"
click node_uv_data "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/repository/DefaultUvRepository.kt"
click node_place_data "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/nominatim/DefaultPlaceRepository.kt"
click node_room "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/db/AppDatabase.kt"
click node_history_data "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/history/RoomExposureHistoryRepository.kt"
click node_prefs_data "https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/preferences/DataStoreUserPreferencesRepository.kt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_home,node_forecast_ui,node_settings_ui,node_search_ui,node_sunlog_ui,node_user toneBlue
class node_root,node_main_vm,node_forecast_vm,node_settings_vm toneAmber
class node_uv_domain,node_place_domain,node_history_domain,node_prefs_domain,node_exposure,node_environment toneMint
class node_uv_data,node_place_data,node_room,node_history_data,node_prefs_data toneRose
class node_openmeteo,node_nominatim,node_android_sensors toneIndigo
```

## Components

### Compose UI

- [Home screen](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/screens/HomeScreen.kt): `app/src/main/java/com/example/uvapp/ui/screens/HomeScreen.kt`
- [Forecast screen](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/screens/ForecastScreen.kt): `app/src/main/java/com/example/uvapp/ui/screens/ForecastScreen.kt`
- [Settings screen](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/screens/SettingsScreen.kt): `app/src/main/java/com/example/uvapp/ui/screens/SettingsScreen.kt`
- [Search dialog](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/components/SearchDialog.kt): `app/src/main/java/com/example/uvapp/ui/components/SearchDialog.kt`
- [SunLog screen](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/screens/SunLogScreen.kt): `app/src/main/java/com/example/uvapp/ui/screens/SunLogScreen.kt`

### App coordination

- [UI composition root](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/ui/UVAppRoot.kt): `app/src/main/java/com/example/uvapp/ui/UVAppRoot.kt`
- [Main ViewModel](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/viewmodel/MainViewModel.kt): `app/src/main/java/com/example/uvapp/viewmodel/MainViewModel.kt`
- [Forecast ViewModel](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/viewmodel/ForecastViewModel.kt): `app/src/main/java/com/example/uvapp/viewmodel/ForecastViewModel.kt`
- [Settings ViewModel](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/viewmodel/SettingsViewModel.kt): `app/src/main/java/com/example/uvapp/viewmodel/SettingsViewModel.kt`

### Domain logic

- [UV forecast contract](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/repository/UvRepository.kt): `app/src/main/java/com/example/uvapp/domain/repository/UvRepository.kt`
- [Place search contract](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/repository/PlaceRepository.kt): `app/src/main/java/com/example/uvapp/domain/repository/PlaceRepository.kt`
- [Exposure history contract](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/repository/ExposureHistoryRepository.kt): `app/src/main/java/com/example/uvapp/domain/repository/ExposureHistoryRepository.kt`
- [Preferences contract](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/repository/UserPreferencesRepository.kt): `app/src/main/java/com/example/uvapp/domain/repository/UserPreferencesRepository.kt`
- [Exposure calculation](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/exposure/ExposureCalculator.kt): `app/src/main/java/com/example/uvapp/domain/exposure/ExposureCalculator.kt`
- [Environment sensing](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/domain/environment/ExposureMonitoringController.kt): `app/src/main/java/com/example/uvapp/domain/environment/ExposureMonitoringController.kt`

### Data and persistence

- [UV repository](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/repository/DefaultUvRepository.kt): `app/src/main/java/com/example/uvapp/data/repository/DefaultUvRepository.kt`
- [Place repository](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/nominatim/DefaultPlaceRepository.kt): `app/src/main/java/com/example/uvapp/data/nominatim/DefaultPlaceRepository.kt`
- [Room storage](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/db/AppDatabase.kt): `app/src/main/java/com/example/uvapp/data/db/AppDatabase.kt`
- [History repository](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/history/RoomExposureHistoryRepository.kt): `app/src/main/java/com/example/uvapp/data/history/RoomExposureHistoryRepository.kt`
- [DataStore preferences](https://github.com/jiajunhuang-unimelb/uvapp/blob/main/app/src/main/java/com/example/uvapp/data/preferences/DataStoreUserPreferencesRepository.kt): `app/src/main/java/com/example/uvapp/data/preferences/DataStoreUserPreferencesRepository.kt`

### Other components

- **App user**
- **Open-Meteo**
- **Nominatim**
- **Android sensors**

## Connections

- App user → Home screen: views (evidence: `README.md`)
- App user → Forecast screen: selects forecast (evidence: `README.md`)
- App user → Settings screen: configures (evidence: `README.md`)
- App user → Search dialog: submits search (evidence: `README.md`)
- App user → SunLog screen: reviews history (evidence: `README.md`)
- UI composition root → Main ViewModel: injects repositories (evidence: `README.md`)
- UI composition root → Forecast ViewModel: injects repositories (evidence: `README.md`)
- UI composition root → Settings ViewModel: injects repositories (evidence: `README.md`)
- Main ViewModel → UV forecast contract: uses forecast contract (evidence: `README.md`)
- Main ViewModel → Place search contract: uses place contract (evidence: `README.md`)
- Main ViewModel → Exposure history contract: saves history (evidence: `README.md`)
- Settings ViewModel → Preferences contract: persists settings (evidence: `README.md`)
- Forecast ViewModel → Main ViewModel: shares forecast state (evidence: `README.md`)
- UV repository → Open-Meteo: fetches UV data (evidence: `README.md`)
- UV repository → Room storage: caches readings (evidence: `README.md`)
- Place repository → Nominatim: searches places (evidence: `README.md`)
- History repository → Room storage: stores history (evidence: `README.md`)
- DataStore preferences → Preferences contract: implements contract (evidence: `README.md`)
- UV forecast contract → UV repository: implemented by (evidence: `README.md`)
- Place search contract → Place repository: implemented by (evidence: `README.md`)
- Exposure history contract → History repository: implemented by (evidence: `README.md`)
- Exposure calculation → Exposure history contract: records exposure
- Android sensors → Environment sensing: provides context
