How oliexdev/openscale works
1. Repository shape
This is primarily an Android/Kotlin application called openScale, with two supporting non-Android areas: arduino_mcu for custom scale firmware/hardware work, and docs/fastlane for product assets, store metadata, and release automation. The runtime architecture is centered on a local-only mobile app; there is no backend service in the repo.
2. Top-level app boundary
The Android app lives under android_app/ and uses a layered structure: UI, facades/use cases, services, database, and Bluetooth scale integrations. The codebase is intentionally split so the UI does not talk directly to Bluetooth or Room; it goes through facades and use cases.
3. Entry points and app shell
OpenScaleApp.kt and MainActivity.kt are the app bootstrap points. AndroidManifest.xml plus the navigation layer define which screens exist and how users move through the app. The UI is organized around Compose-style screens in ui/screen, with shared state and events in ui/shared.
4. User interface subsystem
The UI includes screens for overview, graphs, statistics, tables, settings, Bluetooth setup, and detail dialogs. Reusable components live in ui/screen/components, while modal interactions are grouped in ui/screen/dialog. The app also ships a resizable home-screen widget under ui/widget, which is part of the user-facing surface but updates from local app data.
5. Domain model
Core business objects are in core/data and core/model. These represent users, measurements, measurement types, goals, enriched measurements, trends, insights, and evaluation contexts. This layer is the app’s semantic core: everything else transforms data into or out of these types.
6. Local persistence
All durable state is stored locally through Room in core/database. There are DAOs for measurements, measurement values/types, users, and goals, backed by AppDatabase. Schema version snapshots under app/schemas/ show that this is a long-lived offline database with explicit migrations and compatibility tracking.
7. Bluetooth acquisition pipeline
Bluetooth scale support is the most specialized subsystem. core/bluetooth contains the communication layer and a ScaleFactory, while core/bluetooth/scales contains many device-specific handlers and adapters. The adapters abstract transport differences such as GATT, broadcast, and SPP, and the handlers implement vendor-specific parsing/protocol logic for many scale brands.
8. Measurement processing
Raw scale data is not shown directly to the user. It is normalized and enriched by core/service classes such as MeasurementEnricher, MeasurementEvaluator, and TrendCalculator. This is where derived metrics, body-composition estimations, and range checks are computed before the UI renders charts, tables, or insight summaries.
9. Application use-case layer
The core/usecase package is the main orchestration boundary between UI and the rest of the system. It groups feature-level operations such as CRUD, query/filtering, aggregation, smoothing, evaluation, import/export, backup/restore, reminders, sync hooks, and user goals. This layer keeps feature workflows separate from low-level storage and Bluetooth details.
10. Facade layer
core/facade provides simplified entry points for major domains like Bluetooth, measurement management, settings, and user management. These facades are the likely boundary consumed by ViewModels and screens, reducing UI coupling to the deeper service/use-case graph.
11. Background and lifecycle jobs
core/worker contains BackupWorker, ReminderWorker, and BootReceiver. These handle deferred or lifecycle-triggered tasks such as scheduled backups, notifications/reminders, and restoring periodic behavior after device reboot. This is the app’s background execution boundary outside the foreground UI.
12. External and non-runtime surfaces
The app is designed for privacy: no cloud sync is built into the core repo, and the README explicitly notes that internet access is not required. Optional synchronization is delegated to a separate project. Release and distribution are managed through fastlane, while GitHub Actions under .github/workflows run CI for beta/master branches.
13. Hardware companion area
arduino_mcu/ contains an Arduino-based firmware project and libraries used for a custom scale device ecosystem. This is separate from the Android app but conceptually connected: it supports the “custom made Bluetooth scale” path documented in the README.
14. What to show in an architecture diagram
A clear diagram should show: UI screens and widget at the top; facades/use cases in the middle; Room database and Bluetooth adapters/handlers as the two main data sources; service classes for enrichment/evaluation/trends between raw data and UI; and background workers/boot receiver as asynchronous system actors. The strongest architectural boundary is between device-specific Bluetooth parsing and the generic measurement domain stored locally in Room.
Main entry points: facade Facades · AppNavigation.kt Navigation · usecase Use cases · OverviewScreen.kt Overview
Components 19
Android App
Local-only Kotlin/Compose application
- App shell · Application startup and process wiring
android_app/app/src/main/java/com/health/openscale/OpenScaleApp.kt - Main activity · Primary Android activity hosting the UI
android_app/app/src/main/java/com/health/openscale/MainActivity.kt - Navigation · Screen graph and route definitions
android_app/app/src/main/java/com/health/openscale/ui/navigation/AppNavigation.kt - Shared state · Cross-screen events and top bar/snackbar state
android_app/app/src/main/java/com/health/openscale/ui/shared/SharedViewModel.kt - Overview · Main measurement dashboard and detail entry
android_app/app/src/main/java/com/health/openscale/ui/screen/overview/OverviewScreen.kt - Charts & stats · Graph, statistics, and table views
android_app/app/src/main/java/com/health/openscale/ui/screen/graph/GraphScreen.kt - Settings · Settings, Bluetooth, users, data, and measurement types
android_app/app/src/main/java/com/health/openscale/ui/screen/settings/SettingsScreen.kt - Insights · Derived measurement summaries and evaluations
android_app/app/src/main/java/com/health/openscale/ui/screen/insights/InsightsScreen.kt - Home widget · Resizable widget fed from local measurements
android_app/app/src/main/java/com/health/openscale/ui/widget/MeasurementWidget.kt - Facades · Simplified entry points for UI and view models
android_app/app/src/main/java/com/health/openscale/core/facade - Use cases · Feature workflows for CRUD, query, backup, import/export, and reminders
android_app/app/src/main/java/com/health/openscale/core/usecase - Domain model · Measurements, users, goals, trends, and evaluation models
android_app/app/src/main/java/com/health/openscale/core/model - Room store · Local database, DAOs, converters, and schema history
android_app/app/src/main/java/com/health/openscale/core/database/AppDatabase.kt - Processing · Enrichment, evaluation, trend calculation, BLE connector/scanner
android_app/app/src/main/java/com/health/openscale/core/service - Bluetooth core · Scale factory and transport abstractions
android_app/app/src/main/java/com/health/openscale/core/bluetooth/ScaleFactory.kt - Scale handlers · Device-specific adapters and vendor protocol implementations
android_app/app/src/main/java/com/health/openscale/core/bluetooth/scales - Background jobs · Backup, reminder, and boot-time receivers
android_app/app/src/main/java/com/health/openscale/core/worker
Companion Hardware
Arduino firmware and scale-related support files
- MCU firmware · Arduino-based companion scale firmware
arduino_mcu/openScale_MCU/openScale_MCU.ino
Release & Docs
Store metadata, assets, and release automation
- Release tools · Fastlane metadata, changelogs, and store assets
fastlane/Fastfile
Connections 26
- App shell → Main activity: launches · App bootstrap hands off to the main Android activity
- Main activity → Navigation: hosts · Activity renders the navigation graph
- Navigation → Overview: opens · Routes map to the main overview screen
- Navigation → Charts & stats: opens · Routes map to charts, statistics, and tables
- Navigation → Settings: opens · Routes map to settings and configuration screens
- Navigation → Insights: opens · Routes map to evaluation summaries
- Overview → Shared state: events · Screens exchange snackbar and top-bar state
- Charts & stats → Shared state: events · Analytics views reuse shared UI state
- Settings → Shared state: events · Settings views reuse shared UI state
- Overview → Facades: reads/writes · UI talks to the app through facades
- Charts & stats → Facades: reads/writes · Charts and tables consume facade APIs
- Settings → Facades: reads/writes · Configuration screens use facade APIs
- Insights → Facades: reads/writes · Insight views consume facade APIs
- Facades → Use cases: delegates · Facades route feature work to use cases
- Use cases → Room store: stores · CRUD, query, backup, and import/export persist locally
- Use cases → Processing: computes · Orchestration invokes enrichment and evaluation logic
- Processing → Domain model: produces · Processing turns raw readings into enriched domain objects
- Room store → Domain model: persists · Room stores measurement and user domain records
- Bluetooth core → Scale handlers: dispatches · Factory selects the correct scale implementation
- Scale handlers → Domain model: emits · Device protocols yield measurement-domain data
- Bluetooth core → Processing: feeds · Acquired readings flow into enrichment and evaluation
- Use cases → Background jobs: schedules · Backup and reminder workflows are executed in background
- Background jobs → Room store: uses · Workers operate on the local database
- Home widget → Facades: reads · Home screen widget pulls from app facades
- MCU firmware → Bluetooth core: pairs with · Companion scale firmware supports the custom scale path
- Release tools → App shell: packages · Release automation ships the Android app