A sophisticated, enterprise-grade fitness tracking platform built with modern local-first architecture. GradientPeak delivers seamless offline-first experiences with intelligent cloud synchronization, real-time analytics, and cross-platform consistency.
- Turborepo + npm - High-performance monorepo build system with fast package manager
- TypeScript 5.9 - Full type safety with strict mode and modern features
- ESLint + Prettier - Consistent code formatting and linting across all packages
- tRPC v11 - End-to-end type-safe API layer with React Query integration
- Zustand - Lightweight state management with persistence middleware
- Hot Reloading - Instant updates across mobile and web during development
- Shared Tooling - Consistent ESLint, TypeScript, and Prettier configurations
- Parallel Execution - Turborepo caching for fast build and test runs
- Type Safety - Full-stack type sharing between frontend and backend
- Expo EAS Build - Cloud builds for iOS and Android with over-the-air updates
- Vercel Deployment - Automatic deployments for web dashboard
- Turborepo Pipelines - Optimized build and test execution
- Environment Management - Consistent environments across development and production
A sophisticated, enterprise-grade fitness tracking platform built with modern local-first architecture. GradientPeak delivers seamless offline-first experiences with intelligent cloud synchronization, real-time analytics, and cross-platform consistency.
GradientPeak is organized as a Turborepo monorepo with modular packages:
The heart of GradientPeak, shared across web, mobile, and backend apps. Completely independent of database or ORM dependencies.
Responsibilities:
- Type Definitions & Schemas β Zod validation for profiles, activities, activities, and flexible JSON structures
- Calculations & Analytics β Training zones, TSS, normalized power, compliance scoring, CTL/ATL/TSB
- Business Logic β Activity plan validation, progression, and adaptive algorithms
- Utilities β Time/duration helpers, unit conversions, constants
- Platform Agnostic β Pure TypeScript with no database, ORM, or platform-specific dependencies
Key Benefit: Single source of truth ensures consistent calculations, type safety, and validation across all applications while remaining completely portable and testable in isolation.
A shared TypeScript configuration used across all apps and packages in the GradientPeak monorepo.
Responsibilities:
- Centralized TS Configuration β Base
tsconfigdefines compiler options, strict type checking, and module resolution - Standardized Paths & Aliases β Ensures consistent
@/*imports across apps - Extensible per App β Apps can extend the base config for Next.js, Expo, or library-specific overrides
- Version Control β Single source of truth for TypeScript settings to reduce discrepancies and errors
Key Benefit: All apps and packages share a consistent TypeScript environment, simplifying cross-package type safety and refactoring.
A shared ESLint configuration used across all apps and packages in the GradientPeak monorepo.
Responsibilities:
- Centralized Linting Rules β Base ESLint rules and plugins (
@eslint/js,typescript-eslint,eslint-config-prettier) applied across all apps - Next.js & React Support β Optional per-app overrides for Next.js or React library requirements
- Custom Plugins β Turbo-specific rules,
eslint-plugin-only-warn, and other shared rules enforced consistently - Ignored Paths β Standard exclusions for
dist,.next, and build artifacts
Key Benefit: Provides uniform code quality standards across all apps and packages, making maintenance and onboarding simpler.
- Expo SDK 54 + React Native 0.81.4 - Modern React Native development with new architecture
- Expo Router v6 - File-based routing with fully typed routes and deep linking
- NativeWind v4 - Tailwind CSS for React Native with dark mode support
- tRPC + React Query - Type-safe API calls with caching and optimistic updates
- Zustand + AsyncStorage - Persistent local state management
- Expo SQLite + FileSystem - Offline-first data persistence
- React Native BLE PLX - Bluetooth Low Energy device integration
- React Native Reanimated - Smooth 60fps animations and gestures
Developer Experience Features:
- Hot reloading with Fast Refresh
- Native module development with Expo Dev Client
- Comprehensive debugging tools (Flipper, React DevTools)
- Type-safe navigation with Expo Router
- Shared business logic with
@repo/corepackage
- Expo + React Native
- Local-first storage with SQLite for offline recording
- Powered by
@gradientpeak/corefor validation and calculations (database-independent) - Cloud sync handled via API endpoints
- Next.js 15 + React 19 - Modern React framework with App Router
- tRPC + React Query - Type-safe API layer with server-side rendering
- Tailwind CSS - Utility-first CSS framework with dark mode
- Shadcn/ui - Accessible component library built on Radix UI
- Zod - Schema validation with TypeScript integration
- Supabase - Real-time database and authentication
Developer Experience Features:
- Instant hot reloading with Next.js
- API route handlers with tRPC integration
- Automatic code splitting and optimization
- Type-safe data fetching with React Query
- Shared validation schemas from
@repo/core
- Next.js + React
- Real-time analytics and dashboards
- Powered by
@gradientpeak/corefor calculations and validation
- Database Independent - Pure TypeScript with no external dependencies
- Zod Schemas - Comprehensive validation for all data structures
- Performance Calculations - TSS, normalized power, training zones, CTL/ATL/TSB
- Type Definitions - Shared interfaces across mobile and web
- Test Utilities - Mock data generators and test helpers
- tRPC Routers - Type-safe API endpoints for all data operations
- Shared Procedures - Authentication, activities, profiles, analytics
- Error Handling - Consistent error types and handling patterns
- Middleware - Authentication, logging, and rate limiting
- Base Configuration - Shared ESLint rules across all projects
- TypeScript Support - Comprehensive type-aware linting rules
- React Hooks - Complete React hooks linting configuration
- Import Sorting - Consistent import organization
- Base tsconfig - Shared compiler options and strict settings
- Path Mapping - Consistent import aliases (
@/*,@repo/*) - Module Resolution - Standardized module resolution strategy
- Target Environments - Appropriate settings for Node.js, React Native, and browsers
- Turborepo + Bun - High-performance monorepo management
- TypeScript Throughout - End-to-end type safety from database to UI
- Shared Core Package - Database-independent business logic and calculations
- tRPC API Layer - Type-safe client-server communication
- Local-First Architecture - Offline recording with intelligent sync
- Consistent Tooling - Unified ESLint, Prettier, and TypeScript configurations
- Parallel Development - Fast iteration with Turborepo caching
User-centric design anchors the system around profiles extended from auth.users. The core package provides enhanced profile interfaces and validation schemas for athlete-specific metrics:
| Field | Description |
|---|---|
id |
Primary key, UUID, FK β auth.users.id |
threshold_hr |
Threshold heart rate (bpm); nullable for new users |
ftp |
Functional Threshold Power (watts); nullable |
weight_kg |
Athlete's weight for power-to-weight calculations |
gender |
Used in predictive models and analytics |
dob |
Date of birth; calculates age-based zones & targets |
username |
Unique public-facing handle |
language |
Preferred UI language/locale |
preferred_units |
Metric vs imperial |
avatar_url |
Optional profile picture/avatar |
bio |
Optional short biography |
The core package handles profile validation, training zone calculations, and unit conversions for personalized experiences.
profile_plans stores personalized training plans generated from library templates. The core package provides plan validation, progression algorithms, and adaptation logic.
planned_activities contains scheduled activities with flexible JSON structures validated by the core package:
structureβ Complex JSON objects defining activity stepsstructure_versionβ Version tracked by core packagerequires_threshold_hr/requires_ftpβ Validated against core profile requirements- Performance estimates calculated by core algorithms
Activity Structure Features:
- Nested repetitions and complex step sequences
- Multiple intensity target types with validation
- Duration units (time, distance, repetition)
- Intensity classes with core classification logic
- Portable format compatible with major training platforms
The core package ensures valid activity structures, calculates estimated durations and training stress, and provides compliance scoring algorithms.
GradientPeak uses a JSON-first approach where all activity data is stored as the single source of truth:
- Primary Storage β Complete activity data stored as JSON in Supabase Storage
- Local Recording β Activities initially captured locally in SQLite as JSON
- Cloud Sync β JSON objects uploaded to Supabase Storage when network available
- Metadata Generation β Activity records created locally and synced after JSON storage
- Stream Processing β Activity streams generated from JSON after successful upload
Data Flow:
- Record β Local SQLite stores complete activity as JSON
- Upload β JSON object uploaded to Supabase Storage (source of truth)
- Process β Activity metadata record generated locally and inserted
- Streams β Activity streams generated and inserted after JSON processing
- Analytics β Core package processes JSON for performance calculations
Activity data flows through the core package for consistent analysis:
- Performance Metrics β TSS, normalized power, intensity factors calculated from JSON
- Training Load Analytics β CTL, ATL, TSB derived from activity metadata
- Compliance Scoring β Activity matching algorithms using JSON activity structure
- Zone Analysis β Training zone calculations using core package algorithms
Time-series data processed from JSON source through core package utilities:
- Generated from JSON β All streams derived from primary JSON activity data
- Standardized Metrics β Core package ensures consistent metric types and validation
- Performance Curves β Power/HR curves calculated from JSON streams
- Real-time Processing β Stream aggregation during activity recording
- Record Locally β Expo-SQLite captures complete activities as JSON with core package validation
- JSON Source of Truth β All activity data stored primarily as JSON objects
- Background Sync β Core package ensures data integrity during upload process
- Metadata Derivation β Activity records and streams generated from JSON post-upload
- Conflict Resolution β Smart merging using JSON timestamps and core validation
- Database Independent β Core package has zero database dependencies
- Consistent Calculations β Same algorithms across platforms
- Unified Validation β JSON schema validation using Zod
- Type Safety β Full TypeScript support without ORM coupling
- Client-side Performance β Instant calculations without API calls
- JSON-Derived Metrics β All analytics calculated from JSON source data
- Training Load Models β CTL/ATL/TSB from activity metadata
- Performance Analytics β Power curves, trends from JSON streams
- Compliance Tracking β Plan adherence using JSON activity structures
- Zone Analysis β Heart rate and power zones from core calculations
- Validated Data Integrity β Core package schemas ensure data quality
- Row Level Security β Database-level access control
- Encrypted Storage β Secure local and cloud storage
- Audit Logging β Complete activity history preservation
- Independent Core Package β Pure TypeScript, fully testable in isolation
- End-to-end Type Safety β From JSON validation to UI components
- Hot Reloading β Fast development iteration
- Consistent Behavior β Same business logic across all platforms
| Layer | Mobile | Web | Shared Packages |
|---|---|---|---|
| Framework | Expo 54, React Native 0.81.4 | Next.js 15, React 19 | - |
| Business Logic | @repo/core |
@repo/core |
Core calculations & validation |
| API Layer | @repo/trpc + React Query |
@repo/trpc + React Query |
Type-safe API procedures |
| State Management | Zustand + AsyncStorage | Zustand + React Query | Persistent state patterns |
| Local Storage | Expo SQLite + FileSystem | - | JSON data structures |
| Cloud Services | Supabase Auth + Storage | Supabase Auth + PostgreSQL | Real-time capabilities |
| Styling | NativeWind v4 + Reusables | Tailwind CSS + Shadcn/ui | Design system consistency |
| Navigation | Expo Router v6 | Next.js App Router | Type-safe routing |
| Development | Turborepo + npm | Turborepo + npm | Monorepo tooling |
| Type Safety | TypeScript 5.9 + @repo/config |
TypeScript 5.9 + @repo/config |
Shared configurations |
gradientpeak/
βββ apps/
β βββ mobile/ # Mobile app (Expo + React Native)
β βββ web/ # Web dashboard (Next.js)
βββ packages/
β βββ core/ # π Database-independent business logic, types, calculations
The @repo/core package is designed for maximum portability and testability:
// Example usage - completely database independent
import { calculateHrZones, validateActivity } from '@repo/core';
// Zone calculations using pure functions
const zones = calculateHrZones(threshold_hr, maxHr);
// JSON validation with Zod schemas
const validation = validateActivity(activityJson);Key Development Benefits:
- π Zero Dependencies - No database, ORM, or platform-specific code
- π§ͺ Easy Testing - Pure functions require no mocks or setup
- π Consistent Behavior - Same results across all platforms
- π¦ Tree Shakable - Only include what you use in final bundles
- β‘ Fast Execution - No async operations or I/O delays
packages/core/
βββ types/ # Platform-agnostic types and interfaces
βββ schemas/ # Zod validation schemas for JSON data
βββ calculations/ # Performance and training calculations
βββ validators/ # Data validation utilities
βββ utils/ # Shared utilities and constants
Root level:
npm dev # Start all development servers
npm build # Build all applications including core package
npm lint # Lint all code
npm test # Run all tests including core package testsCore package development:
cd packages/core
npm build # Build core package
npm test # Test core package (no database dependencies)
npm dev # Watch mode for core package development- Supabase authentication with JWT tokens
- Profile enhancement using core package type extensions
- Data validation through core package schemas
- Secure sync with core package integrity checks
- JSON-First Storage β Single source of truth for all activity data
- Real-time Validation β Core package schemas ensure data quality
- Client-side Analytics β Performance calculations without server dependencies
- Consistent Training Zones β Core package algorithms across platforms
- Intelligent Offline-first Sync β JSON-based conflict resolution
Testing Strategy & Developer Experience
Core Package Testing:
- π§ͺ Pure Function Testing - No database mocking required
- π Algorithm Validation - Mathematical correctness of calculations
- π― Schema Testing - JSON validation and type safety
- π Cross-platform Consistency - Same results across mobile and web
- β‘ Performance Testing - Benchmark critical calculation functions
Development Workflow:
# Start all development servers
npm dev
# Run core package tests in watch mode
npm test --filter=core
# Lint all code with shared configuration
npm lint
# Build all packages with Turborepo caching
npm build
# Type check entire monorepo
npm check-typesQuality Assurance:
- β Pre-commit Hooks - Automatic linting and type checking
- π Code Reviews - Consistent patterns across all packages
- π¦ CI/CD Pipeline - Automated testing on every commit
- π Coverage Reports - Comprehensive test coverage requirements
- π Static Analysis - Advanced ESLint rules and type checking
- Algorithm Validation β Mathematical correctness of calculations
- Schema Testing β JSON validation and type safety
- Pure Function Testing β No database mocking required
- Cross-platform Consistency β Same results across mobile and web
Application Testing & Debugging:
Mobile App Testing:
- π± Component Testing - React Native component validation
- π Integration Tests - JSON storage and retrieval workflows
- π― E2E User Journeys - Complete activity recording flows
- π Performance Tests - Large JSON processing and analytics
- πΆ Network Testing - Offline/online scenario testing
Web Dashboard Testing:
- π Component Testing - Next.js component validation
- π API Testing - tRPC procedure integration tests
- π¨ UI Testing - Visual regression and accessibility testing
- β‘ Performance Testing - Page load and analytics performance
Debugging Tools:
- π React DevTools - Component hierarchy and state inspection
- π± Flipper - Native debugging for React Native
- π Next.js DevTools - Performance and bundle analysis
- π React Query DevTools - API call inspection and caching
- π TypeScript Debugging - Real-time type error reporting
- Integration Tests β JSON storage and retrieval workflows
- E2E User Journeys β Complete activity recording and analysis flows
- Performance Tests β Large JSON processing and analytics
Mobile App Deployment (Expo EAS):
# Production builds for both platforms
eas build --platform all --profile production
# Over-the-air updates without app store review
eas update --branch production --message "Feature update"
# Submit to app stores
eas submit --platform ios --profile productionWeb Dashboard Deployment (Vercel):
# Automatic deployment on push to main
git push origin main
# Preview deployments for PRs
vercel --prod
# Environment-specific configuration
vercel env add VARIABLE_NAMECI/CD Pipeline:
- β Automated Testing - Runs on every pull request
- π¦ Build Verification - Ensures all packages compile correctly
- π§ͺ Test Coverage - Minimum coverage requirements enforced
- π Security Scanning - Dependency vulnerability checks
- π Preview Deployments - Automatic staging environments for PRs
Environment Management:
- π§ Turborepo Remote Caching - Shared build cache across team
- π Multi-environment Support - Development, staging, production
- π Configuration Management - Environment-specific variables
- π Monitoring & Logging - Application performance monitoring
- π Analytics Integration - Usage tracking and error reporting
Mobile App (Expo/EAS):
# Production builds
eas build --platform all --profile production
# Over-the-air updates
eas update --branch production --message "Feature update"Web Dashboard (Vercel):
# Automatic deployment on push to main
git push origin main
# Manual deployment
vercel --prod- Fork the repository and create a feature branch
- Make your changes with tests and documentation
- Run quality checks:
npm lint && npm test - Submit a pull request with clear description
This project is licensed under the MIT License.
Built with modern tools and technologies:
- Expo β Cross-platform mobile development
- Next.js β React web framework
- Supabase β Backend-as-a-service
- Turborepo β Monorepo build system
GradientPeak β Enterprise-grade fitness tracking with JSON-first, local-first architecture π