How emanuelmath/xplore works
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: repositories Repositories · XploreNavHost.kt Nav Host · screens Feature Screens · MainViewModel.kt Main VM
Components 18
Presentation
Compose UI, navigation, and feature screens.
- MainActivity · Android entry point that boots the app UI.
app/src/main/java/com/example/xplore/MainActivity.kt - Nav Host · App navigation boundary and screen routing.
app/src/main/java/com/example/xplore/ui/navigation/XploreNavHost.kt - Screen Routes · Defines the app's screen destinations.
app/src/main/java/com/example/xplore/ui/navigation/Screen.kt - Bottom Bar · Persistent navigation shell for feature switching.
app/src/main/java/com/example/xplore/ui/components/XploreBottomBar.kt - Feature 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 · Primary UI state owner for the main experience.
app/src/main/java/com/example/xplore/ui/viewmodels/MainViewModel.kt - Splash VM · Startup state and splash flow logic.
app/src/main/java/com/example/xplore/ui/viewmodels/SplashViewModel.kt - Config VM · Configuration and onboarding state logic.
app/src/main/java/com/example/xplore/ui/viewmodels/ConfigurationViewModel.kt - UI States · Explicit state containers for rendering screens.
app/src/main/java/com/example/xplore/ui/viewmodels
Domain
App models and mapping contracts.
- Feature Models · Compass, light, proximity, and weather contracts.
app/src/main/java/com/example/xplore/domain/models - Weather 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 · Feature repositories that mediate between UI, hardware, and network.
app/src/main/java/com/example/xplore/data/repositories - User Store · DataStore-backed user preferences and app settings.
app/src/main/java/com/example/xplore/data/local/UserPreferencesDataStore.kt - Weather API · Retrofit API layer for weather and geocoding.
app/src/main/java/com/example/xplore/data/api
Hardware
Device sensor providers.
- Compass Sensor · Compass/orientation hardware abstraction.
app/src/main/java/com/example/xplore/hardware/compass - Light Sensor · Ambient light hardware abstraction.
app/src/main/java/com/example/xplore/hardware/light - Proximity Sensor · Distance/proximity hardware abstraction.
app/src/main/java/com/example/xplore/hardware/proximity - Weather Sensor · Local weather-sensing abstraction used when available.
app/src/main/java/com/example/xplore/hardware/weather
Connections 21
- 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.