A sophisticated, enterprise-grade fitness tracking platform built with modern local-first architecture. TurboFit delivers seamless offline-first experiences with intelligent cloud synchronization, real-time analytics, and cross-platform consistency.
TurboFit is organized as a Turborepo monorepo with modular packages:
The heart of TurboFit, 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 centralized backend layer providing type-safe database interactions.
Responsibilities:
- Schema Definition β Table structures and relations managed via Drizzle
- Migrations β Database versioning and schema updates fully controlled
- Queries & Transactions β Type-safe interactions with PostgreSQL
- Integration β Powers both web and mobile apps with a single database interface
Key Benefit: Decouples applications from direct database dependencies while providing type-safe data operations.
A shared TypeScript configuration used across all apps and packages in the TurboFit monorepo.
Responsibilities:
- Centralized TS Configuration β Base
tsconfig
defines 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 TurboFit 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 + React Native
- Local-first storage with SQLite for offline recording
- Powered by
@turbofit/core
for validation and calculations (database-independent) - Cloud sync handled via API endpoints
- Next.js + React
- Real-time analytics and dashboards
- Powered by
@turbofit/core
for calculations and validation - Database access via Drizzle-powered API endpoints
- Turborepo + TypeScript throughout
- Core package for shared business logic (database-independent)
- Drizzle package for centralized database operations
- Local-first recording + intelligent sync ensures offline usability and data integrity
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.
TurboFit 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 |
---|---|---|---|
Business Logic | @turbofit/core |
@turbofit/core |
Core Package |
Frontend | Expo 53, React Native | Next.js 15, React 19 | - |
Local Storage | Expo-SQLite (SQLite) | - | - |
Cloud Storage | Supabase Storage | Supabase Storage | JSON Files |
Cloud Database | API β Drizzle | API β Drizzle | PostgreSQL |
Styling | NativeWind 4.1 | Tailwind CSS | - |
State | SQLite + React Query | React Query + Zustand | - |
turbofit/
βββ apps/
β βββ mobile/ # Mobile app (Expo + React Native)
β βββ web/ # Web dashboard (Next.js)
βββ packages/
β βββ core/ # π Database-independent business logic, types, calculations
β βββ drizzle/ # Database schema, migrations, queries
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:
bun dev # Start all development servers
bun build # Build all applications including core package
bun lint # Lint all code
bun test # Run all tests including core package tests
Core package development:
cd packages/core
bun build # Build core package
bun test # Test core package (no database dependencies)
bun 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
Core Package Testing:
- 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:
- 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 (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:
bun lint && bun 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
TurboFit β Enterprise-grade fitness tracking with JSON-first, local-first architecture π