# madhavraj2004/demoapp architecture

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

- Interactive diagram: https://gitdiagram.com/madhavraj2004/demoapp
- Repository: https://github.com/madhavraj2004/demoapp

## Overview

##### Project Type and Purpose
- This is an Android mobile application (“demoapp”) written in Java, organized as a single Gradle-based Android Studio module (`app/`).
- Purpose: Provide three main features on the device—Bluetooth communication, map‐based location interaction, and audio playback/recording.

##### High-Level File Structure Analysis
- Top‐level: Gradle build files (`build.gradle`, `settings.gradle`), wrapper.
- `app/`: Android module
- `src/main/java/com/example/demoapp/`: Application code, following an MVVM‐style structure:
– `ui/Audio`: `AudioFragment`, `AudioViewModel`
– `ui/Bluetooth`: `BluetoothFragment`, `BluetoothViewModel`, `DeviceAdapter`
– `ui/Map`: `MapFragment`, `MapViewModel`
– `MainActivity.java` as host for navigation
- `src/main/res/`: layouts, drawables, navigation graphs, XML configs
- `src/androidTest` & `src/test`: instrumentation & unit tests
- `proguard-rules.pro`: code obfuscation
- No backend/service code—this is a standalone client that interfaces with external hardware (Bluetooth), external services (Map APIs), and device hardware (microphone/speaker).

##### Key Components
- Client UI Layer
- MainActivity & Navigation Component (bottom nav menu)
- Three Fragments: Audio, Bluetooth, Map
- ViewModel Layer
- One ViewModel per feature screen
- Binds UI ↔ business logic
- Data/Service Layer
- BluetoothService: wraps Android BluetoothAdapter, BluetoothDevice scanning/linking
- AudioService: wraps MediaRecorder/MediaPlayer for recording/playback
- MapService: interfaces with Google Maps SDK for Android, LocationManager or FusedLocationProvider
- External Dependencies
- Google Play Services (Maps + Location API)
- Android Bluetooth API
- Android Media APIs
- Resources
- Tests
- Unit tests for ViewModel logic
- Instrumented tests for UI flows

##### Relationships & Data Flows
- User taps bottom nav → MainActivity triggers Navigation Component → target Fragment
- Fragment observes its ViewModel → displays LiveData
- ViewModel calls out to appropriate Service (BluetoothService, AudioService, MapService)
- Services access hardware or external SDKs → return results/callbacks to ViewModel
- ViewModel processes data → updates LiveData → UI re‐renders
- Error/permission flows: show dialogs or error states in Fragment

##### Architectural Patterns & Design Principles
- MVVM (Model–View–ViewModel)
- Single Activity + Jetpack Navigation for modular screen flows
- Separation of concerns: UI in Fragments, state in ViewModels, hardware logic in Services
- Dependency inversion: ViewModels depend on abstractions (service interfaces)
- Reactive data flow with LiveData (or other observable)

##### Technologies / Frameworks
- AndroidX libraries: AppCompat, Lifecycle, Navigation, RecyclerView
- Google Play Services (Maps & Location)
- Android Bluetooth API
- Android MediaRecorder / MediaPlayer
- Gradle for build management

##### Putting It All Together
- Layers vertically: top is UI, next is ViewModel, then Services, bottom is External/HW.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        MA["MainActivity"]:::ui
        NavGraph["Navigation Graph"]:::ui
        BN["Bottom Navigation Menu"]:::ui
        AF["AudioFragment"]:::ui
        BF["BluetoothFragment"]:::ui
        MF["MapFragment"]:::ui
        AML["activity_main.xml"]:::ui
        AFL["fragment_audio.xml"]:::ui
        BFL["fragment_bluetooth.xml"]:::ui
        MFL["fragment_map.xml"]:::ui
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer"
        AVM["AudioViewModel"]:::vm
        BVM["BluetoothViewModel"]:::vm
        MVM["MapViewModel"]:::vm
    end

    %% Service Layer
    subgraph "Service Layer"
        AS["AudioService"]:::service
        BS["BluetoothService"]:::service
        MS["MapService"]:::service
        DA["DeviceAdapter"]:::service
    end

    %% External Systems
    subgraph "External Systems"
        GP["Google Maps SDK (Play Services)"]:::external
        BL["Android Bluetooth API"]:::external
        MD["Android Media APIs"]:::external
        HW["Device Hardware (Mic/Speaker)"]:::external
    end

    %% Configuration & Tests
    subgraph "Configuration"
        Build["App Module Build File"]:::config
        Pro["ProGuard Rules"]:::config
    end
    subgraph "Tests"
        UT["Unit Tests"]:::test
        IT["Instrumented Tests"]:::test
    end

    %% Connections
    MA --> NavGraph
    MA --> BN
    NavGraph --> AF
    NavGraph --> BF
    NavGraph --> MF

    AF --> AVM
    BF --> BVM
    MF --> MVM

    AVM --> AS
    BVM --> BS
    MVM --> MS

    BF --> DA
    DA --> BS

    AS --> MD
    AS --> HW
    BS --> BL
    MS --> GP

    %% Click Events
    click MA "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/java/com/example/demoapp/MainActivity.java"
    click AF "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/java/com/example/demoapp/ui/Audio/AudioFragment.java"
    click BF "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/java/com/example/demoapp/ui/Bluetooth/BluetoothFragment.java"
    click MF "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/java/com/example/demoapp/ui/Map/MapFragment.java"
    click AVM "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/java/com/example/demoapp/ui/Audio/AudioViewModel.java"
    click BVM "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/java/com/example/demoapp/ui/Bluetooth/BluetoothViewModel.java"
    click MVM "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/java/com/example/demoapp/ui/Map/MapViewModel.java"
    click DA "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/java/com/example/demoapp/ui/Bluetooth/DeviceAdapter.java"
    click NavGraph "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/res/navigation/mobile_navigation.xml"
    click AML "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/res/layout/activity_main.xml"
    click AFL "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/res/layout/fragment_audio.xml"
    click BFL "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/res/layout/fragment_bluetooth.xml"
    click MFL "https://github.com/madhavraj2004/demoapp/blob/master/app/src/main/res/layout/fragment_map.xml"
    click Build "https://github.com/madhavraj2004/demoapp/blob/master/app/build.gradle"
    click Pro "https://github.com/madhavraj2004/demoapp/blob/master/app/proguard-rules.pro"
    click UT "https://github.com/madhavraj2004/demoapp/blob/master/app/src/test/java/com/example/demoapp/ExampleUnitTest.java"
    click IT "https://github.com/madhavraj2004/demoapp/blob/master/app/src/androidTest/java/com/example/demoapp/ExampleInstrumentedTest.java"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0366d6
    classDef vm fill:#DFF7D0,stroke:#1f7d12
    classDef service fill:#FFE2B3,stroke:#d66f00
    classDef external fill:#EEEEEE,stroke:#888888
    classDef config fill:#F0F0F0,stroke:#333333
    classDef test fill:#F9D5CD,stroke:#d14a02
```
