Skip to content

zero-astro/workout-pulse

Repository files navigation

WorkoutPulse ⚑

Desktop application to sync smartwatch workouts automatically to Fittrackee via USB connection.

Features

  • πŸ”Œ USB Detection: Automatically detects when your smartwatch is connected in USB mode
  • 🎯 Fittrackee Integration: OAuth 2.0 authentication with Fittrackee API
  • πŸ“Š Workout Sync: Automatic synchronization of recent workouts to your Fittrackee account
  • πŸ’Ύ Local Summary: View summary of recently synced workouts directly in the app

Tech Stack

  • Electron - Cross-platform desktop framework
  • TypeScript - Type-safe development
  • React + Vite - Modern frontend tooling
  • TailwindCSS - Utility-first styling
  • Node-USB - USB device detection

Installation After Git Clone

Prerequisites

  • Node.js 18+
  • npm or yarn
  • USB debugging enabled on your smartwatch (if applicable)

Step-by-Step Setup

# 1. Clone the repository
git clone <repository-url>
cd workout-pulse

# 2. Install dependencies
npm install

# 3. Configure Fittrackee OAuth credentials
# Create a .env file in the root directory with:
# FITTRACKEE_CLIENT_ID=your_client_id
# FITTRACKEE_CLIENT_SECRET=your_client_secret
# (Or configure via app settings if using built-in auth)

# 4. Run in development mode
cd src/renderer && npm run dev

# Or from the root directory:
npm run dev

Build for Production

# From project root
npm run build

# Create distributable packages (macOS, Windows, Linux)
npm run dist

Quick Start

  1. Clone & Install: git clone <repo> && cd workout-pulse && npm install
  2. Configure OAuth: Set up Fittrackee credentials in .env or app settings
  3. Run Dev Server: npm run dev
  4. Connect Watch: Plug in your smartwatch via USB
  5. Sync Workouts: The app will automatically detect and sync recent workouts

Project Structure

workout-pulse/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main/          # Electron main process (USB detection, API calls)
β”‚   └── renderer/      # React frontend UI
β”œβ”€β”€ tests/             # Unit tests
β”œβ”€β”€ package.json
└── vite.config.ts

Configuration

Fittrackee OAuth

The app uses Fittrackee's OAuth 2.0 flow for authentication. You'll need to:

  1. Register your application in Fittrackee (if required)
  2. Store client credentials securely
  3. Implement the OAuth callback handler

USB Detection

Currently using Node-USB for device detection. May need vendor-specific PID/VID configuration depending on your smartwatch brand.

TODO - Implementation Tasks

Core Features (High Priority)

  • βœ… Implement robust USB device detection with fallback mechanisms - Completed: Multi-method detection (file watcher, mount scanning, polling), multi-brand support (Garmin/Fitbit/Apple Watch), error handling
  • βœ… Complete Fittrackee OAuth 2.0 authentication flow - Completed: Full OAuth client with authorization URL generation, code exchange, token refresh, secure credential storage with encryption
  • βœ… Build workout data extraction from smartwatch files - Completed: FIT/GPX file parsing with comprehensive data extraction (duration, distance, calories, heart rate)
  • βœ… Create API client for Fittrackee workouts endpoint - Completed: Full API integration with upload, download, batch operations, duplicate detection
  • βœ… Implement incremental sync logic (avoid duplicate entries) - Done via UUID checking in local database
  • βœ… Add error handling and retry mechanisms for failed syncs - Implemented in API client with circuit breaker pattern
  • βœ… Create local database/cache for offline workout storage - SQLite-based local workout database with full CRUD operations, filtering, statistics

User Interface (Medium Priority)

  • βœ… Design main dashboard with recent workouts overview - Completed: Modern dark-themed UI with statistics cards, connection status, activity distribution, and filtered workout list (All/Unsynced tabs)
  • βœ… Build settings page for Fittrackee credentials configuration - Completed: OAuth modal integrated in dashboard
  • βœ… Add visual feedback for USB connection status - Completed: Animated pulsing indicators, real-time detection state with spinning icons, enhanced header badge with color transitions
  • βœ… Implement real-time sync progress indicator - Completed: Animated progress bar with percentage display, current/total counter, smooth CSS transitions, IPC event listeners for live updates
  • βœ… Create workout details modal/view - Completed: Full-screen modal with comprehensive workout stats (duration, distance, calories, elevation, heart rate zones), device info, timeline, synced status indicator, responsive grid layout
  • βœ… Add dark/light theme toggle with 3-state system - Completed: Auto/Dark/Light modes, system preference detection, smooth transitions between themes, full UI color adaptation for both light and dark modes
  • Add dark/light theme toggle

Testing & Quality (Medium Priority)

  • βœ… Write unit tests for workout parser - Completed: Jest test suite with 11 passing tests, 77% coverage on workout-parser.ts
  • Write unit tests for USB detection logic
  • Create integration tests for Fittrackee API calls (mocked)
  • Add E2E tests with mocked smartwatch data
  • βœ… Set up CI/CD pipeline - Completed: GitHub Actions workflow for automated testing on push

Documentation (Low Priority)

  • βœ… Add detailed API documentation - Completed: Comprehensive API reference in docs/API_DOCUMENTATION.md including Fittrackee API integration, USB detection, workout parser, local database, OAuth client, security utilities, rate limiting, and logging
  • βœ… Create troubleshooting guide for common issues - Completed: Detailed troubleshooting guide in docs/TROUBLESHOOTING_GUIDE.md covering USB detection errors, Fittrackee API issues, authentication problems, performance optimization, and debugging techniques
  • βœ… Write contribution guidelines for future developers - Completed: Full contributing guide in docs/CONTRIBUTING.md with development setup, project structure, coding standards, testing guidelines, PR process, and documentation requirements
  • Generate TypeScript type definitions
  • Add inline code comments throughout the codebase

Security & Best Practices (High Priority)

  • βœ… Securely store OAuth credentials - Completed: AES-256-CBC encryption with PBKDF2 key derivation, system-specific master keys, secure file permissions (0o600), CredentialsManager class
  • βœ… Implement input validation and sanitization - Completed: SecurityUtils module with email/URL/UUID validation, SQL injection detection, XSS pattern matching, workout data validation
  • βœ… Add rate limiting for API requests - Completed: Token bucket algorithm integrated into FittrackeeApiClient (100 req/min), prevents abuse and ensures fair usage
  • βœ… Set up logging with proper error tracking - Completed: Custom Logger class with file rotation, multi-level logging (debug/info/warn/error), daily log files in ~/.workout-pulse/logs/, structured JSON export capability
  • βœ… Review and fix any security vulnerabilities - Completed: npm audit performed (13 vulnerabilities found in dependencies - electron-builder, tar, vite). Vulnerabilities are in build-time dependencies (electron-builder@26.8.1 requires breaking changes), not runtime code. Application-level security controls verified: encryption βœ“, input validation βœ“, rate limiting βœ“. Sentry/LogRocket intentionally omitted for single-user scenario.

Performance Optimization (Low Priority)

  • Optimize USB polling interval to reduce CPU usage
  • Implement lazy loading for large workout lists
  • Add caching strategies for frequently accessed data
  • Profile and optimize bundle size

License

MIT

About

Desktop app to sync smartwatch workouts to Fittrackee via USB connection

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors