How manas8114/shmt works
Step 1: Identify Project Type and Purpose
• This is a multi-module Android project comprising two Gradle modules:
• “hanheld” – the phone (handheld) app
• “wearable” – the Wear OS app
• Purpose: Fitness tracking (“FitWatch”) on a wearable device, synchronizing data to a companion phone app.
Step 2: Analyze the File Structure
• Top-level folders:
• hanheld/ – Android phone application
• wearable/ – Wear OS application
• Each module follows standard Android project layout:
• src/main/java/.../presentation or ui (UI layer)
• src/main/java/.../ViewModel (MVVM)
• src/main/java/.../service (DataLayerListenerService in hanheld)
• src/main/res – drawables, themes, strings
• Gradle build scripts at root and per-module define dependencies and packaging.
Step 3: Examine README (empty)
• No additional architecture details, so we infer from code:
• Both apps use MVVM (ViewModel + Compose-based UI/theme packages).
• Data synchronization uses Google’s Wearable Data Layer API (DataLayerListenerService in the phone module and ClientDataViewModel in both).
a. Main Components
1. Wearable App
– Presentation Layer (Jetpack Compose UI, navigation host, screens/components)
– Wearable ViewModel (ClientDataViewModel)
– Device Sensor Inputs (heart rate, steps, etc.)
– Wear OS Tile (FitWatchTile)
2. Handheld App
– UI Layer (Compose-based MainActivity/ViewModel-driven UI)
– Handheld ViewModel (ClientDataViewModel)
– DataLayerListenerService (listens for data events from wearable)
3. Wearable Data Layer API
– Communication channel between wearable & phone
4. Device Hardware
– Wearable sensors (accelerometer, heart-rate sensor, etc.)
b. Relationships & Interactions
1. Sensors → Wearable ViewModel
• ViewModel collects sensor data
2. Wearable ViewModel → Wearable Data Layer API
• DataItems or Messages sent to phone
3. Wearable Data Layer API ↔ Handheld DataLayerListenerService
• Data layer sync
4. DataLayerListenerService → Handheld ViewModel
• Forwards received data to UI
5. Handheld ViewModel → Handheld UI
• Renders data in phone app
c. Architectural Patterns
• MVVM in both modules
• Single Responsibility: Services for comms, ViewModels for state, Compose for UI
• Decoupled communication via Wearable Data Layer
d. Key Technologies
• Kotlin
• Android Jetpack Compose (ui/theme packages)
• Wear OS Tile API
• Google Play Services Wearable Data Layer
• Gradle multi-module build
Step 5: Tailoring to This Project
• Dual-app nature: two frontends (wearable & handheld) + shared comms layer.
• Sensor → UI flow on the watch, and comms → UI flow on the phone.
• No remote server—system is entirely peer-to-peer via Wearable Data Layer.
• Rectangles (components): Wearable App, Handheld App, Data Layer API, Sensors
– Sensor data flow → Wearable ViewModel → Data Layer
– Data Layer → Handheld Service → ViewModel → UI
– Blue for Wearable components
– Green for Handheld components
– Orange for shared comms layer
• Labels:
– Component names, interface/API names (e.g., DataClient.sendDataItem)
– Data types (heart rate, step count)
Step 7: Level of Detail
• Break apps into:
• UI (screens, tiles)
• ViewModel
• Communication/service
• Hardware/sensors
• Data flow and dependencies clearly.
• Avoid unnecessary detail—focus on runtime interactions and module boundaries.