# abhayy143/horizon-compass_app architecture

> Architecture diagram of the GitHub repository abhayy143/horizon-compass_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhayy143/horizon-compass_app
- Repository: https://github.com/abhayy143/horizon-compass_app

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Device Hardware Layer
    subgraph "Device Hardware"
        direction TB
        ACC["Accelerometer"]:::hardware
        GYR["Gyroscope"]:::hardware
        MAG["Magnetometer"]:::hardware
    end

    %% Android OS Layer
    subgraph "Android OS & Framework"
        direction TB
        SM["SensorManager"]:::os
        LC["Lifecycle Framework"]:::os
    end

    %% App Module
    subgraph "App Module" 
        direction TB
        subgraph "Data Source"
            direction TB
            SS["SensorService"]:::app
        end
        subgraph "Domain / ViewModel"
            direction TB
            VM["SensorViewModel"]:::app
        end
        subgraph "Presentation"
            direction TB
            UI["Compose UI"]:::app
            MA["MainActivity"]:::app
        end
    end

    %% Build, Config & Tests
    subgraph "Build & Configuration"
        direction TB
        BG["build.gradle.kts"]:::config
        PR["proguard-rules.pro"]:::config
        SG["settings.gradle.kts"]:::config
        LV["gradle/libs.versions.toml"]:::config
        MN["AndroidManifest.xml"]:::config
        BR["backup_rules.xml"]:::config
        DR["data_extraction_rules.xml"]:::config
    end

    subgraph "Tests"
        direction TB
        UT["ExampleUnitTest"]:::config
        IT["ExampleInstrumentedTest"]:::config
    end

    %% Data Flow
    ACC --> SM
    GYR --> SM
    MAG --> SM
    SM --> SS
    LC --> VM
    SS --> VM
    VM --> UI
    MA --> UI
    MA --> VM

    %% Config/Test Relationships
    MN -.-> MA
    BR -.-> MN
    DR -.-> MN
    BG -.-> MA
    PR -.-> MA
    SG -.-> BG
    LV -.-> SG
    UT -.-> VM
    UT -.-> UI
    IT -.-> MA
    IT -.-> SS

    %% Click Events
    click MA "https://github.com/abhayy143/horizon-compass_app/blob/master/app/src/main/java/com/example/horizon/MainActivity.kt"
    click VM "https://github.com/abhayy143/horizon-compass_app/blob/master/app/src/main/java/com/example/horizon/SensorViewModel.kt"
    click UI "https://github.com/abhayy143/horizon-compass_app/tree/master/app/src/main/java/com/example/horizon/ui/"
    click UI "https://github.com/abhayy143/horizon-compass_app/blob/master/app/src/main/java/com/example/horizon/ui/theme/Color.kt"
    click UI "https://github.com/abhayy143/horizon-compass_app/blob/master/app/src/main/java/com/example/horizon/ui/theme/Theme.kt"
    click UI "https://github.com/abhayy143/horizon-compass_app/blob/master/app/src/main/java/com/example/horizon/ui/theme/Type.kt"
    click MN "https://github.com/abhayy143/horizon-compass_app/blob/master/app/src/main/AndroidManifest.xml"
    click BR "https://github.com/abhayy143/horizon-compass_app/blob/master/app/src/main/res/xml/backup_rules.xml"
    click DR "https://github.com/abhayy143/horizon-compass_app/blob/master/app/src/main/res/xml/data_extraction_rules.xml"
    click BG "https://github.com/abhayy143/horizon-compass_app/blob/master/app/build.gradle.kts"
    click PR "https://github.com/abhayy143/horizon-compass_app/blob/master/app/proguard-rules.pro"
    click SG "https://github.com/abhayy143/horizon-compass_app/blob/master/settings.gradle.kts"
    click LV "https://github.com/abhayy143/horizon-compass_app/blob/master/gradle/libs.versions.toml"
    click UT "https://github.com/abhayy143/horizon-compass_app/blob/master/app/src/test/java/com/example/horizon/ExampleUnitTest.kt"
    click IT "https://github.com/abhayy143/horizon-compass_app/blob/master/app/src/androidTest/java/com/example/horizon/ExampleInstrumentedTest.kt"

    %% Styles
    classDef hardware fill:#8FBC8F,stroke:#333,stroke-width:1px
    classDef os fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef app fill:#D8BFD8,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
```
