Technical Deep Dive

Ryval

A fitness tracking platform built for real athletes. React Native, BLE heart rate, offline-first architecture.

React Native Expo SDK 54 TypeScript BLE HR
v3.1.0  ·  March 2026  ·  iOS + Android
01 / 11
Overview

Your toughest opponent is
yesterday's you

An offline-first fitness tracker with real-time heart rate monitoring, intelligent workout comparison, and social competition.

150+
Exercises
11
Muscle Groups
1000
Fitness Score
Live HR Tracking
BLE heart rate with background capture via native foreground service
You vs You
Compete against your last session, personal best, or average of last 5
Smart Analytics
Fitness Score (0-1000), muscle heatmaps, body comp charts
Social Competition
Friend codes, shared workouts, challenges, activity feed
Offline-First
SQLite local DB, auto-backup — cloud is optional
02 / 11
Architecture

System Overview

Expo Router React Query SQLite Firebase
UI Layer — Expo Router
Tab Navigator
5 screens
Workout Engine
[id].tsx
Social Screens
Friends / Feed / Challenges
Stats & Progress
Charts / Heatmap / Records
queries
mutations
cache
State & Data Layer
React Query
+ Persisted Client
Zustand
Preferences
SQLite
12 versions / 30+ tables
AsyncStorage
Cache
native APIs
REST / SDK
Native Layer
BLE Manager
HR Monitor
Foreground Service
Android Kotlin
GPS Engine
Kalman Filter
Health Connect
Android
Cloud — Firebase
Auth
Magic Link
Firestore
Profiles / Friends
Storage
Avatars
OneSignal
Push
03 / 11
Navigation

File-Based
Routing

Expo Router provides file-system routing with deep linking. Tab navigator with 5 main screens and modal stacks.

// Route structure app/ ├── (tabs)/ │ ├── index // Home │ ├── workouts // Library │ ├── history // Sessions │ ├── progress // Analytics │ └── friends // Social ├── workout/[id] // Live ├── session/[id] // Detail ├── stats/* // Premium └── settings // Config
Home
Weekly goals, Fitness Score, You vs You streak
Workouts
Library with search, filter, schedule, create
History
Session list, bookmarks, HR chart overlay
Progress
Body comp, muscle heatmap, personal records
Friends
Friend list, activity feed, challenges
Session Detail
Scorecard, effort breakdown, HR timeline
Settings
HR monitor, backup, units, notifications
Quick Start
Pinned workouts, one-tap autostart
04 / 11
Core Feature

You vs You
Competition Engine

Every workout is scored against a chosen opponent — your last session, personal best, or a friend's shared workout.

Opponent Types
Last Session Personal Best Avg of 5 Any Workout Friend's Workout
Scoring Flow
Workout Complete
Detect Type
Apply Weights
Compare
Win / Loss
Scoring Weights by Type
Weights
5 metrics
Volume
35%
Calories
20%
Duration
15%
Sets
15%
Reps
15%
Cardio
2 metrics
Calories
60%
Time
40%
Mixed
5 metrics
Calories
30%
Volume
25%
Duration
20%
Sets
15%
Reps
10%
05 / 11
Critical Pipeline

Heart Rate Capture

BLE to chart — foreground and background paths with native Android service bridge

BLE Layer
BLE Scan
UUID: 0x180D
GATT Connect
Foreground · JS
useHRMonitor
React State
useHRLogger
1s cadence
SQLite
session_heart_rate
FixedHRChart
Skia SVG
Background · Native
Foreground Service
Kotlin GATT
SharedPreferences
HR samples
On Resume
consumeHR()
SQLite
Chart
Constraint #1
startForegroundService() must be called while app is in foreground.
Constraint #2
Service runs for entire workout. Must NOT stop on foreground resume.
Constraint #3
useHRLogger gates on isAppActive.
06 / 11
Data Layer

Offline-First
Architecture

All workout data lives in local SQLite. React Query with AsyncStorage persistence provides the caching layer. Firebase handles social features only.

React Component
React Query
queryFn + mutations
social only
SQLite
30+ tables
AsyncStorage
Persisted Client
Firestore
REST fallback
Auto Backup
JSON export
AsyncStorage
Profile Cache
Core Tables
TablePurposeScale
exercisesExercise library150+
sessionsCompleted workoutsunbounded
session_setsSet/rep/weight logsunbounded
session_heart_rate1s HR samplesunbounded
health_connect_logBody compositiondaily
youvsyou_resultsWin/loss recordsunbounded
JSON-Safe Persistence
// Set/Map/Date crash on restore // JSON.stringify(new Set(['a'])) → "{}" return ids.filter(...) // string[] // NOT: new Set(ids)
Schema Version 12
Idempotent migrations with CREATE TABLE IF NOT EXISTS
07 / 11
Analytics

Fitness Score
& Insights

A composite 0-1000 score that rewards volume, cardio effort, consistency, and competitive engagement.

Volume
250
Cardio
250
Consistency
250
Competition
250
1000
Max Fitness Score
Calorie Formulas
Polar energy expendedPriority 1
Keytel HR-based formulaPriority 2
MET fallback (weight × intensity)Fallback
Muscle Heatmap
Time-decay volume tracking with 48-hour half-life across 11 muscle groups
Body Composition
Dual-axis bezier chart from Health Connect or manual entry
Weight Body Fat %
Personal Records
Max Weight
Max Reps
Fastest Time
Longest Distance
08 / 11
Social Layer

Friends &
Competition

Firebase-powered social features — friend codes, shared workouts, challenges, and activity feed. Auth via email magic links.

Firebase Auth
Anonymous → Magic Link
Friend Codes
QR + share link
Firestore Profile
users/{uid}
Friend Requests
uidA_uidB
Friends List
Shared Workouts
→ Activity Feed
Challenges
Head-to-head
Firestore Collections
users/{uid} Profile, friends list, blocked IDs
public_profiles Friend-accessible statistics
friend_requests Pending / accepted state
shared_workouts Templates shared to feed
challenges Head-to-head competitions
Auth Flow
Anonymous Sign-In
Auto-created on first launch
Email Magic Link
No password required
UID Sync
Anonymous UID linked, data preserved
Social Unlocked
Friends, sharing, challenges, push
09 / 11
Tech Stack

Built With

React Native
0.81.5
Expo
SDK 54
TypeScript
5.9.2
Firebase
23.8.6
SQLite
expo-sqlite
React Query
5.90.20
Zustand
5.0.10
OneSignal
5.3.1
BLE (ble-plx)
3.5.0
Health Connect
3.5.0
Skia
2.2.12
Reanimated
4.1.1
GPS + Kalman
expo-location
Sentry
8.0.0
EAS Build
Expo
NativeWind
4.2.1
10 / 11
Current State

v3.1.0 — Ship It

Completed
Flat tile redesign (v3.0)
Background HR pipeline
You vs You scoring engine
Social MVP (friends, feed)
Health Connect integration
Push notifications (OneSignal)
Skia HR chart migration
In Progress
iOS App Store submission
Store metadata & screenshots
Google Sign-In on EAS build
Friend request polling
Next Up
Play Store submission
Apple review compliance
Performance audit
Achievement system
Workout AI generation
30+
SQLite Tables
20+
Screens
50+
Dependencies
2
Platforms
3.1.0
Version
11 / 11