How mario-mancia/navigate-app works
1. Repository shape
- This is a single-module Android app (app/) written in Kotlin and built with Jetpack Compose.
- The code is organized as a layered architecture with clear boundaries: UI, ViewModels, domain, data, and a separate hardware/sensors area.
2. App entry and navigation
- MainActivity is the Android entry point.
- Navigation is centralized in ui/navigation/AppNavHost.kt, with screen routes defined in Screen.kt.
- The app flows through dedicated screens for Splash, Guide, Home, Session, and History.
3. Presentation layer
- Each screen has its own composable and state holder: SplashScreen, GuideScreen, HomeScreen, SessionScreen, HistoryScreen, plus matching *UiState classes.
- Shared UI is split into reusable components: cards for weather/compass/proximity/ambient light, top bars for guest vs. authenticated users, and dialogs for profile/settings.
- This suggests a Compose-first design where the screen renders from state and delegates actions upward.
4. ViewModel layer
- Each major screen has a dedicated ViewModel and factory: SplashViewModel, GuideViewModel, HomeViewModel, SessionViewModel, HistoryViewModel, and MainViewModel.
- The presence of factories indicates manual dependency construction rather than a DI framework.
- ViewModels are the orchestration point between UI events and domain use cases/repositories.
5. Domain layer
- Business entities are modeled separately from storage/network schemas in domain/models: User, Session, Weather, and WeatherRecord.
- Mappers convert between layers: entity/DTO models and domain models are isolated in domain/mappers.
- Use cases define the app’s core operations, such as registering/logging in users, handling sessions, reading/clearing weather history, checking/marking the guide as seen, and fetching weather.
6. Local persistence
- Room is used for structured local storage via AppDatabase, DAOs, and entities.
- The database stores at least three main data sets: UserEntity, SessionEntity, and WeatherHistoryEntity.
- DAOs (UserDao, SessionDao, WeatherHistoryDao) provide the persistence boundary for repositories and use cases.
7. Preferences / app settings
- data/local/datastore/ThemeSetting.kt and ThemeRepository indicate DataStore-backed preference storage.
- This is used for app-level settings such as theme mode, likely supporting the dynamic light/dark behavior described in the README.
- GuideRepository likely uses the same style of lightweight persistence for onboarding completion.
8. Remote weather integration
- Weather data comes from a Retrofit-based remote layer: RetrofitClient, WeatherApi, and WeatherResponse.
- WeatherRepository and FetchAndSaveWeatherUseCase suggest the app fetches current weather from the network and then persists selected results locally for history.
- This creates a clear sync flow between external API data and local weather records.
9. Location and context inputs
- LocationProvider is a separate data source, likely supplying coordinates for weather requests.
- This means weather is not hardcoded; it depends on device location, which becomes an input to the remote weather flow.
- The architecture therefore combines sensor/device context and network weather data.
10. Hardware and sensor subsystem
- A dedicated hardware package manages device sensors: compass, humidity, light, pressure, proximity, and temperature.
- SensorAvailabilityManager and SensorStatus provide capability/availability handling around those sensors.
- These managers support the app’s exploration features directly in the UI cards, especially compass guidance, proximity detection, and ambient-light-driven behavior.
11. Main feature flows
- Guide flow: splash/guide screens check whether the user has already seen the onboarding guide, then mark it as seen.
- Session/user flow: registration, login, active session retrieval, and logout-all-sessions are handled through session/user repositories and use cases.
- Weather flow: locate device → call weather API → map response to domain model → show in UI → save history locally.
- History flow: read stored weather records from Room and allow clearing them.
12. Overall architectural boundary
- The app cleanly separates:
- UI rendering in Compose,
- state and orchestration in ViewModels,
- business rules in use cases,
- data access through repositories,
- persistence/network through Room, DataStore, Retrofit, and location/sensor providers.
- That separation is the key structure to reflect in an architecture diagram: multiple input sources feed the domain layer, and the UI consumes only screen state emitted by ViewModels.
Main entry points: AppNavHost.kt NavHost · HomeScreen.kt Home · WeatherRepository.kt Repositories · MainUiState.kt UI states
Components 23
Entry
Android entry point and app shell
- MainActivity · App entry point that bootstraps the Compose UI
app/src/main/java/com/example/navigate/MainActivity.kt
Presentation
Navigation, screens, state, and reusable Compose UI
- NavHost · Centralized app navigation host
app/src/main/java/com/example/navigate/ui/navigation/AppNavHost.kt - Routes · Screen route definitions used by navigation
app/src/main/java/com/example/navigate/ui/navigation/Screen.kt - Main VM · Top-level app state and orchestration
app/src/main/java/com/example/navigate/ui/viewmodels/main/MainViewModel.kt - Splash · Startup screen and onboarding gate
app/src/main/java/com/example/navigate/ui/screens/splash/SplashScreen.kt - Guide · Onboarding guide screen
app/src/main/java/com/example/navigate/ui/screens/guide/GuideScreen.kt - Home · Primary dashboard screen
app/src/main/java/com/example/navigate/ui/screens/home/HomeScreen.kt - Session · Login and session management screen
app/src/main/java/com/example/navigate/ui/screens/session/SessionScreen.kt - History · Stored weather history screen
app/src/main/java/com/example/navigate/ui/screens/history/HistoryScreen.kt - Cards · Reusable weather and sensor cards
app/src/main/java/com/example/navigate/ui/components/card/WeatherStationCard.kt - Top bars · Guest and authenticated top bars
app/src/main/java/com/example/navigate/ui/components/topbar/GuestTopBar.kt - Dialogs · Profile and settings dialogs
app/src/main/java/com/example/navigate/ui/components/dialog/ProfileDialog.kt - UI states · Screen state holders for Compose rendering
app/src/main/java/com/example/navigate/ui/classes/MainUiState.kt
Domain
Business models, mappings, and use cases
- Use cases · Core app operations for guide, session, and weather flows
app/src/main/java/com/example/navigate/domain/usecases/FetchAndSaveWeatherUseCase.kt - Models · User, session, weather, and weather history models
app/src/main/java/com/example/navigate/domain/models/Weather.kt - Mappers · Conversions between entities, DTOs, and domain models
app/src/main/java/com/example/navigate/domain/mappers/WeatherMapper.kt
Data
Local, remote, and repository boundaries
- Repositories · Repository layer for guide, user, session, theme, and weather data
app/src/main/java/com/example/navigate/data/repositories/WeatherRepository.kt - Room DB · Database, DAOs, and entities for structured persistence
app/src/main/java/com/example/navigate/data/local/database/AppDatabase.kt - DataStore · Theme and guide-related lightweight persistence
app/src/main/java/com/example/navigate/data/local/datastore/ThemeSetting.kt - Weather API · Retrofit weather service and response model
app/src/main/java/com/example/navigate/data/remote/api/WeatherApi.kt - Location · Device location source for weather requests
app/src/main/java/com/example/navigate/data/location/LocationProvider.kt
Hardware
Device sensor and availability subsystem
- Sensors · Compass, humidity, light, pressure, proximity, and temperature sensors
app/src/main/java/com/example/navigate/hardware/sensors/CompassSensorManager.kt - Sensor status · Sensor availability and status handling
app/src/main/java/com/example/navigate/hardware/SensorAvailabilityManager.kt
Connections 28
- MainActivity → NavHost: hosts · Main activity sets up the Compose navigation shell
- NavHost → Routes: uses · Navigation host resolves route definitions
- NavHost → Splash: starts · App flow begins at splash
- NavHost → Guide: routes · Navigates to onboarding guide
- NavHost → Home: routes · Navigates to home dashboard
- NavHost → Session: routes · Navigates to session screen
- NavHost → History: routes · Navigates to history screen
- Splash → Main VM: observes · Splash screen consumes top-level app state
- Guide → UI states: renders · Guide screen renders from state holders
- Home → UI states: renders · Home screen renders from state holders
- Session → UI states: renders · Session screen renders from state holders
- History → UI states: renders · History screen renders from state holders
- Home → Cards: composes · Home screen uses sensor and weather cards
- Home → Top bars: composes · Home screen uses guest/auth top bars
- Home → Dialogs: opens · Home screen can show profile and settings dialogs
- Use cases → Repositories: depends on · Use cases orchestrate repository operations
- Use cases → Models: returns · Use cases operate on domain entities
- Repositories → Room DB: persists · Repositories read and write Room data
- Repositories → DataStore: stores prefs · Repositories access lightweight preference storage
- Repositories → Weather API: fetches · Weather repository calls remote API layer
- Repositories → Location: uses · Weather flow depends on device location
- Mappers → Models: maps to · Mappers convert storage and network data into domain models
- Room DB → Mappers: transforms · Room entities are mapped for domain use
- Weather API → Mappers: transforms · Remote weather response is mapped into domain weather
- Sensors → Sensor status: reports · Sensor subsystem exposes availability and status
- Home → Sensors: displays · Home UI surfaces sensor readings through cards
- Home → Weather API: triggers · Weather-related actions start the fetch/save flow through state orchestration
- Main VM → Use cases: coordinates · Top-level state coordinator invokes core use cases