How abhayy143/horizon-compass_app works
Project type and purpose
• This is a single-module Android mobile application (“app” folder) written in Kotlin, using Jetpack Compose to deliver a real-time, offline, 3D compass + level interface.
• Its core function is to read hardware sensors (accelerometer, gyroscope, magnetometer), fuse that data, and render a holographic UI.
File structure
• Top level: Gradle build files (build.gradle.kts, settings.gradle.kts), version catalog (gradle/libs.versions.toml), ProGuard rules.
• app/src/main/java/com/example/horizon/ contains:
• MainActivity.kt – hosts the Compose UI
• SensorViewModel.kt – MVVM ViewModel that handles sensor initialization, data fusion, state
• app/src/main/res/ holds UI assets, backup and data‐extraction rules (xml/backup_rules.xml, xml/data_extraction_rules.xml).
• app/src/androidTest & app/src/test contain instrumentation and unit tests.
README for additional insights
• Architecture: “Modern Android Architecture Components” implying MVVM + unidirectional data flow.
• Tech stack: Kotlin, Jetpack Compose, Android sensors, no external network dependencies.
a. Main components
• Hardware Layer: Accelerometer, Gyroscope, Magnetometer
• Android OS Layer: SensorManager & Lifecycle framework
• App Layer:
– Data Source / SensorService (wraps SensorManager callbacks)
– Domain / SensorViewModel (processes raw sensor events, fuses into tilt & heading)
– Presentation / Compose UI (Liquid Horizon orb, compass ring, MainActivity host)
• Build & Config: Gradle build pipeline, ProGuard, resource rules (backup/data extraction)
• Tests: Unit & Instrumentation (separate, can be shown as side branches)
b. Relationships & interactions
1. Hardware sensors send data → Android SensorManager
2. SensorManager events → SensorService / Data Source layer
3. Raw data → SensorViewModel (applies any filtering, fusion algorithms)
4. ViewModel maintains UI state (Compose State<T>) → Compose UI composables
5. MainActivity sets up Compose host, observes ViewModel → updates on screen
6. Manifest & XML rules govern backup, theming, permissions
c. Architectural patterns / design principles
• MVVM: clear separation between UI (View), state & logic (ViewModel), and data access (SensorService).
• Unidirectional Data Flow: sensor data flows in one direction—> state → UI.
• Dependency Injection (if used—it can be depicted or noted for future extensions).
d. Key technologies / frameworks
• Kotlin coroutines / Flow or LiveData in SensorViewModel
• Jetpack Compose for UI
• Android Architecture Components (ViewModel, Lifecycle)
• Gradle/Kotlin DSL for build