# emanuelmath/xplore architecture

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

- Interactive diagram: https://gitdiagram.com/emanuelmath/xplore
- Repository: https://github.com/emanuelmath/xplore

## Overview

1. **What this app is**
   - Xplore is an Android app in Kotlin whose purpose is to expose multiple phone sensors in one “explorer toolkit” experience.
   - The architecture is centered on four user-facing capabilities: weather, compass, proximity, and ambient light, plus onboarding/configuration flows.

2. **Top-level runtime boundary**
   - The app starts from `MainActivity` and then enters a Compose-style UI/navigation layer.
   - `XploreNavHost` and `Screen` define the navigation boundary between screens such as home, tutorial, configuration, and each sensor feature screen.

3. **Presentation layer**
   - UI lives under `ui/screens` and `ui/components`, with a shared bottom bar component and a theme package.
   - Screens are split by feature: `BrujulaScreen`, `EstacionScreen`, `LuzScreen`, `AproximacionScreen`, plus `HomeScreen`, `PantallaInicialScreen`, `TutorialScreen`, and `ConfiguracionScreen`.
   - This layer is responsible for rendering sensor state and switching between feature views, not for directly reading hardware or calling APIs.

4. **State management**
   - ViewModels (`MainViewModel`, `SplashViewModel`, `ConfigurationViewModel`) sit between UI and data sources.
   - Their UI state classes (`MainUiState`, `SplashUiState`, `ConfigurationUiState`) indicate the app uses explicit state containers to drive screen rendering and lifecycle-safe updates.
   - Factory classes are present for dependency creation, which suggests manual wiring rather than a full DI framework.

5. **Core domain model**
   - The `domain/models` package defines feature-level models such as `Compass`, `Light`, `Proximity`, and `Weather`.
   - `domain/mappers/WeatherMapper` separates raw weather data from the app’s internal weather model, which is important because weather can come either from local sensors or a remote API.
   - This domain layer is the conceptual contract used by the UI and ViewModels.

6. **Hardware abstraction boundary**
   - Actual device sensor access is isolated under `hardware/*`.
   - There are separate sensor interfaces and implementations for compass, light, proximity, and weather.
   - This indicates the app abstracts Android sensor APIs behind feature-specific sensor providers, so the rest of the app does not depend on raw hardware APIs directly.

7. **Data/repository layer**
   - Repositories under `data/repositories` are the main integration point between hardware, network, and persistence.
   - Each capability has its own repository interface and implementation pair: compass, light, proximity, user, weather sensor, and weather API.
   - This layer acts as the orchestration boundary: it chooses where data comes from and converts it into something the UI/domain can consume.

8. **Weather data flow is the most complex**
   - Weather has two paths: local hardware via `WeatherSensorRepository` / `WeatherSensorImpl`, and remote fallback via `WeatherApiRepository` / `WeatherApiService`.
   - API-related DTOs (`CurrentWeather`, `WeatherResponse`, `ReverseGeocodingResponse`, `Address`) and `WeatherMapper` show that remote responses are mapped before reaching the app model.
   - `ApiConstants` and `RetrofitBuilder` indicate Retrofit-based network access for external weather/geocoding services.

9. **Local persistence**
   - `UserPreferencesDataStore` is the app’s local storage boundary.
   - It is likely used to preserve user settings or onboarding/configuration decisions across launches, feeding the configuration-related ViewModel and screens.
   - This is the only explicit persistence mechanism visible in the tree.

10. **Feature behavior by subsystem**
   - **Compass** combines orientation-related hardware data to show north.
   - **Proximity** updates UI state when an object is near the device.
   - **Light** drives adaptive visual mode based on ambient illumination.
   - **Weather** combines on-device sensor data when available, or network weather data when sensors are missing or insufficient.

11. **Navigation and app flow**
   - The presence of splash, tutorial, and configuration screens suggests a startup flow before the main feature hub.
   - A likely high-level flow is: splash/onboarding → configuration/tutorial → home → feature screens.
   - The bottom bar component implies the main sensor features are reachable through a persistent navigation shell.

12. **Testing and build structure**
   - The repo is a standard Android Gradle project with `app` as the application module.
   - There are both unit and instrumented tests, which means the architecture is intended to support testable boundaries between UI, repository logic, and sensor/API integrations.
   - Resources and manifests are conventional Android packaging, with no evidence of additional backend services or multi-module decomposition.

13. **How to draw the architecture diagram**
   - A clear diagram should show: UI screens at the top, ViewModels in the middle, repositories underneath, and then two kinds of providers at the bottom: device hardware sensors and external APIs/local DataStore.
   - Weather should be drawn as the only subsystem with both hardware and network inputs.
   - Compass, light, and proximity should be drawn as direct hardware-driven feature pipelines.

Main entry points: [`app/src/main/java/com/example/xplore/data/repositories`](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/data/repositories) (Repositories), [`app/src/main/java/com/example/xplore/ui/navigation/XploreNavHost.kt`](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/navigation/XploreNavHost.kt) (Nav Host), [`app/src/main/java/com/example/xplore/ui/screens`](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/ui/screens) (Feature Screens), [`app/src/main/java/com/example/xplore/ui/viewmodels/MainViewModel.kt`](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/viewmodels/MainViewModel.kt) (Main VM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_main_activity["MainActivity<br/>activity entry<br/>[MainActivity.kt]"]
  node_nav_host["Nav Host<br/>navigation<br/>[XploreNavHost.kt]"]
  node_screen_routes["Screen Routes<br/>route map<br/>[Screen.kt]"]
  node_bottom_bar["Bottom Bar<br/>shell ui<br/>[XploreBottomBar.kt]"]
  node_feature_screens["Feature Screens"]
end

subgraph group_state["State"]
  node_main_vm["Main VM<br/>viewmodel<br/>[MainViewModel.kt]"]
  node_splash_vm["Splash VM<br/>viewmodel<br/>[SplashViewModel.kt]"]
  node_config_vm["Config VM<br/>viewmodel"]
  node_ui_states["UI States<br/>state models"]
end

subgraph group_domain["Domain"]
  node_models["Feature Models<br/>domain models"]
  node_weather_mapper["Weather Mapper<br/>[WeatherMapper.kt]"]
end

subgraph group_data["Data"]
  node_repositories["Repositories<br/>data orchestration"]
  node_user_store[("User Store<br/>local storage")]
  node_weather_api["Weather API<br/>network service"]
end

subgraph group_hardware["Hardware"]
  node_compass_sensor["Compass Sensor<br/>hardware sensor"]
  node_light_sensor["Light Sensor<br/>hardware sensor"]
  node_proximity_sensor["Proximity Sensor<br/>hardware sensor"]
  node_weather_sensor["Weather Sensor<br/>hardware sensor"]
end

node_main_activity -->|"starts"| node_nav_host
node_nav_host -->|"uses"| node_screen_routes
node_nav_host -->|"shell"| node_bottom_bar
node_nav_host -->|"shows"| node_feature_screens
node_feature_screens -->|"reads state"| node_main_vm
node_feature_screens -->|"reads state"| node_splash_vm
node_feature_screens -->|"reads state"| node_config_vm
node_main_vm -->|"emits"| node_ui_states
node_splash_vm -->|"emits"| node_ui_states
node_config_vm -->|"emits"| node_ui_states
node_main_vm -->|"loads"| node_repositories
node_splash_vm -->|"reads"| node_user_store
node_config_vm -->|"saves"| node_user_store
node_repositories -->|"returns"| node_models
node_repositories -->|"maps weather"| node_weather_mapper
node_repositories -->|"uses"| node_compass_sensor
node_repositories -->|"uses"| node_light_sensor
node_repositories -->|"uses"| node_proximity_sensor
node_repositories -->|"uses"| node_weather_sensor
node_repositories -->|"uses"| node_weather_api
node_weather_api -->|"maps"| node_weather_mapper

click node_main_activity "https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/MainActivity.kt"
click node_nav_host "https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/navigation/XploreNavHost.kt"
click node_screen_routes "https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/navigation/Screen.kt"
click node_bottom_bar "https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/components/XploreBottomBar.kt"
click node_feature_screens "https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/ui/screens"
click node_main_vm "https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/viewmodels/MainViewModel.kt"
click node_splash_vm "https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/viewmodels/SplashViewModel.kt"
click node_config_vm "https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/viewmodels/ConfigurationViewModel.kt"
click node_ui_states "https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/ui/viewmodels"
click node_models "https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/domain/models"
click node_weather_mapper "https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/domain/mappers/WeatherMapper.kt"
click node_repositories "https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/data/repositories"
click node_user_store "https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/data/local/UserPreferencesDataStore.kt"
click node_weather_api "https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/data/api"
click node_compass_sensor "https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/hardware/compass"
click node_light_sensor "https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/hardware/light"
click node_proximity_sensor "https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/hardware/proximity"
click node_weather_sensor "https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/hardware/weather"

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_main_activity,node_nav_host,node_screen_routes,node_bottom_bar,node_feature_screens toneBlue
class node_main_vm,node_splash_vm,node_config_vm,node_ui_states toneAmber
class node_models,node_weather_mapper toneMint
class node_repositories,node_user_store,node_weather_api toneRose
class node_compass_sensor,node_light_sensor,node_proximity_sensor,node_weather_sensor toneIndigo
```

## Components

### Presentation

Compose UI, navigation, and feature screens.

- [MainActivity](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/MainActivity.kt): activity entry · Android entry point that boots the app UI. · `app/src/main/java/com/example/xplore/MainActivity.kt`
- [Nav Host](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/navigation/XploreNavHost.kt): navigation · App navigation boundary and screen routing. · `app/src/main/java/com/example/xplore/ui/navigation/XploreNavHost.kt`
- [Screen Routes](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/navigation/Screen.kt): route map · Defines the app's screen destinations. · `app/src/main/java/com/example/xplore/ui/navigation/Screen.kt`
- [Bottom Bar](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/components/XploreBottomBar.kt): shell ui · Persistent navigation shell for feature switching. · `app/src/main/java/com/example/xplore/ui/components/XploreBottomBar.kt`
- [Feature Screens](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/ui/screens): screens · Home, onboarding, configuration, and sensor feature views. · `app/src/main/java/com/example/xplore/ui/screens`

### State

ViewModels and UI state containers.

- [Main VM](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/viewmodels/MainViewModel.kt): viewmodel · Primary UI state owner for the main experience. · `app/src/main/java/com/example/xplore/ui/viewmodels/MainViewModel.kt`
- [Splash VM](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/viewmodels/SplashViewModel.kt): viewmodel · Startup state and splash flow logic. · `app/src/main/java/com/example/xplore/ui/viewmodels/SplashViewModel.kt`
- [Config VM](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/ui/viewmodels/ConfigurationViewModel.kt): viewmodel · Configuration and onboarding state logic. · `app/src/main/java/com/example/xplore/ui/viewmodels/ConfigurationViewModel.kt`
- [UI States](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/ui/viewmodels): state models · Explicit state containers for rendering screens. · `app/src/main/java/com/example/xplore/ui/viewmodels`

### Domain

App models and mapping contracts.

- [Feature Models](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/domain/models): domain models · Compass, light, proximity, and weather contracts. · `app/src/main/java/com/example/xplore/domain/models`
- [Weather Mapper](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/domain/mappers/WeatherMapper.kt): mapper · Converts remote weather payloads into app weather models. · `app/src/main/java/com/example/xplore/domain/mappers/WeatherMapper.kt`

### Data

Repositories, persistence, and network integration.

- [Repositories](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/data/repositories): data orchestration · Feature repositories that mediate between UI, hardware, and network. · `app/src/main/java/com/example/xplore/data/repositories`
- [User Store](https://github.com/emanuelmath/xplore/blob/main/app/src/main/java/com/example/xplore/data/local/UserPreferencesDataStore.kt): local storage · DataStore-backed user preferences and app settings. · `app/src/main/java/com/example/xplore/data/local/UserPreferencesDataStore.kt`
- [Weather API](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/data/api): network service · Retrofit API layer for weather and geocoding. · `app/src/main/java/com/example/xplore/data/api`

### Hardware

Device sensor providers.

- [Compass Sensor](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/hardware/compass): hardware sensor · Compass/orientation hardware abstraction. · `app/src/main/java/com/example/xplore/hardware/compass`
- [Light Sensor](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/hardware/light): hardware sensor · Ambient light hardware abstraction. · `app/src/main/java/com/example/xplore/hardware/light`
- [Proximity Sensor](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/hardware/proximity): hardware sensor · Distance/proximity hardware abstraction. · `app/src/main/java/com/example/xplore/hardware/proximity`
- [Weather Sensor](https://github.com/emanuelmath/xplore/tree/main/app/src/main/java/com/example/xplore/hardware/weather): hardware sensor · Local weather-sensing abstraction used when available. · `app/src/main/java/com/example/xplore/hardware/weather`

## Connections

- MainActivity → Nav Host: starts · Activity launches the Compose navigation host.
- Nav Host → Screen Routes: uses · Navigation host resolves destination routes.
- Nav Host → Bottom Bar: shell · Navigation is wrapped by a persistent bottom bar.
- Nav Host → Feature Screens: shows · Routes render the app's screens.
- Feature Screens → Main VM: reads state · Screens observe main feature state.
- Feature Screens → Splash VM: reads state · Splash/onboarding screens observe startup state.
- Feature Screens → Config VM: reads state · Configuration screens observe configuration state.
- Main VM → UI States: emits · ViewModel drives the UI state containers.
- Splash VM → UI States: emits · Splash ViewModel exposes state for rendering.
- Config VM → UI States: emits · Configuration ViewModel exposes state for rendering.
- Main VM → Repositories: loads · Main feature logic pulls sensor/domain data from repositories.
- Splash VM → User Store: reads · Startup flow may consult persisted preferences.
- Config VM → User Store: saves · Configuration flow persists user choices.
- Repositories → Feature Models: returns · Repositories surface app domain models.
- Repositories → Weather Mapper: maps weather · Weather repository uses mapping before exposing app models.
- Repositories → Compass Sensor: uses · Compass repository depends on compass hardware.
- Repositories → Light Sensor: uses · Light repository depends on ambient light hardware.
- Repositories → Proximity Sensor: uses · Proximity repository depends on proximity hardware.
- Repositories → Weather Sensor: uses · Weather sensor repository depends on local weather hardware.
- Repositories → Weather API: uses · Weather API repository depends on network services.
- Weather API → Weather Mapper: maps · Remote weather payloads are transformed into domain models.
