MOBILE MACHINE LEARNING & EDGE ARCHITECTURE

GAIN: Gym App with On-Device AI Intelligence. Even Offline.

An Arabic and English strength-training application that computes deterministic progression and runs on-device XGBoost model inference directly inside the mobile runtime without cloud latency.

< 5 msLocal Inference Latency
0 KBNetwork Dependency (Offline)
Float32TypeScript Tree Traversal
100%Local SQLite Persistence

The Engineering Challenge

Most fitness applications rely on remote cloud APIs to generate workout recommendations. This introduces severe friction in real gym environments with poor reception, causes noticeable latency, and prevents workout tracking when offline.

GAIN was engineered around a core invariant: the smartphone is the sole source of truth. All core algorithms—from set-to-set adaptation to workout history persistence and Arabic right-to-left layout rendering—execute entirely on the device.

Three-Tier Architecture

01 / INTELLIGENCE

On-Device Model Interpretation

Rather than embedding heavy C++ runtimes or making network requests, a bundled XGBoost model is interpreted directly in TypeScript with strict float32 precision and missing-value traversal logic. Progression engine algorithms set baseline target ranges, while the model dynamically adapts the next set based on fatigue signals.

02 / PERSISTENCE

Offline-First SQLite State

Expo SQLite persists all workout sessions, rep records, and equipment increments locally. Client-generated UUIDs, monotonic timestamps, and deletion markers support optional delta sync with Cloudflare Workers and D1 database instances.

03 / SAFETY BOUNDS

Deterministic Guardrails

The decision engine enforces discrete gym equipment increments (e.g., 2.5 kg plates or dumbell steps). The recommendation requires explicit user confirmation and immediately falls back to deterministic rule-based progression if inputs diverge from acceptable bounds.

04 / LOCALIZATION

Full Arabic & English Parity

Engineered with full bidirectional support (LTR and RTL), direction-aware UI components, localized muscle group terminologies, and Arabic text rendering tested across iOS and Android viewports.

Mobile User Interface

Clean, high-contrast dark interface designed for fast set logging between exercises, available in native Arabic and English:

GAIN English Today screen
English · Today Session View
GAIN Arabic Today screen
العربية · Localized Arabic Dashboard
GAIN workout logger
Workout Logger with Increments