How aries0d0f/web-ble-heart-rate-zone-monitor works
Main Components
• User Interface (Frontend): Represented by the Vue components (e.g., App.vue, Controller.vue, Monitor.vue, HeartRateZone.vue, Preference.vue). This layer is responsible for displaying data and user interactions.
• Bluetooth Module: Found under src/modules/bluetooth (bluetooth.model.ts and bluetooth.service.ts). This component handles communication with the Bluetooth hardware using the Web Bluetooth API.
• PWA Module: Under src/modules/pwa (pwa.service.ts) which manages offline capabilities, caching, and service worker-related functionalities for offline support.
• Utility & Shared Modules: Includes src/modules/utils (context, context service, module-factory.ts) and src/shared (signal.ts, timer.ts). These handle contextual data, cross-cutting utilities, and timing functions that support the core functionalities.
• Data Models: For example, src/model/preference.model.ts defines the structure for user preferences which are used to preserve settings locally.
• Assets & Styling: While not “logical” components, the assets (CSS/SCSS files) support the UI presentation, enhancing user experience.
• Build & Configuration Infrastructure: Shown via several configuration files (vite.config.ts, package.json, various tsconfig.*) and CI/CD pipelines (.github/workflows) that ensure continuous integration and deployment.
Relationships and Interactions
• The UI interacts directly with various modules:
• It retrieves heart rate and zone data by interacting with the Bluetooth service.
• It saves and retrieves user preferences via the model and related context services.
• The PWA module ensures service workers are active for offline capabilities.
• The UI layer (Vue components) makes calls to the Bluetooth and PWA services, which in turn might use shared utilities (signals, timers) to process and propagate data.
• Configuration and build files support the entire application lifecycle but are not part of runtime interactions.
Architectural Patterns and Design Principles
• Layered Architecture: The system is well-organized into distinct layers—presentation (UI components), business logic (Bluetooth/PWA modules, utilities), and data (models, shared resources).
• Modularity: Functionality is split into modules (bluetooth, pwa, utils), making the app extensible and maintainable.
• Separation of Concerns: UI components, BLE communication, and service worker management are isolated, allowing for easier modifications and testing.
Relevant Technologies and Frameworks
• Vue.js: Building the user interface (components are .vue files).
• TypeScript: All source code files (with .ts extensions) indicate a strongly typed implementation.
• Vite: Used as a build tool (vite.config.ts), which is geared towards modern web development.
• Web Bluetooth API: Central to interacting with BLE devices.
• Progressive Web App (PWA) Techniques: For offline support and caching.
• SCSS: For styling, with modular and library styles under the assets folder.
• GitHub Actions: For CI/CD automation (see .github/workflows).