
# FightRate (HealthTracking)
**Continuous heart-rate capture for combat-sport training from a BLE chest strap — a bare React Native
app (no Expo) with a native Android foreground service, local SQLite storage and metrics computed only from
real timestamped BPM.**



[Features](#features) · [How it works](#how-it-works) · [Run locally](#run-locally) · [Known limitations](#known-limitations)
> [!NOTE]
> **Project status:** work in progress (`package.json` is `0.0.1`, Android `versionName` `1.0`). The
> `applicationId` is `com.healthtracking.fightrate`. The latest commits (2026-06-16) ship the
> "Instrumento Forte" UI refinement (v2): tabular JetBrains Mono numerics, animated live indicators and
> a zoomable chart. The record in [`.impeccable.md`](.impeccable.md) lists `npm run typecheck` with 0
> errors and `npm test -- --runInBand` with 74/74 passing for that release.
> [!IMPORTANT]
> **Real data only, Android only.** Every number on screen is computed from BPM samples received from a
> real sensor; with no samples the app shows an empty state instead of inventing a peak, zone, load or
> HRV. The BLE capture module is written in Kotlin (`android/…/capture/`); the `ios/` project has no
> native capture module.
## Features
| Tab | What it does |
|---|---|
| **Capture** | Live BPM, average / peak / sample-count tiles, BLE, battery and background status, and the training chart. Start/stop marks a **training window** inside the continuous stream — monitoring keeps storing samples either way |
| **History** | Saved training windows and continuous-usage blocks (split by gaps), each with average / peak / min BPM; open one to inspect the timestamped data; custom time range |
| **Sensor** | BLE scan, device list, connect, connection phase, signal (RSSI), battery level, BLE services/characteristics diagnostics and a shortcut to Android battery-optimization settings |
| **Insights** | Calculation matrix: current/average BPM, range, variability, time in zones, load, heart-rate drift, post-session recovery, HRmax/HRR (marked as needing a profile) and HRV (only when the strap sends RR intervals) |
- **Zoomable chart** (`TrainingChart`): pinch zoom, pan and a tap-to-pin marker, with tick granularity that
follows the visible span (half-second up to one-minute steps).
- **Zones** by fixed BPM thresholds: `BASE <150`, `PRESSÃO 150–169`, `REDLINE 170+`.
- Samples outside 30–240 bpm, or reported without skin contact, are discarded from metrics; a sample is
considered fresh for 12 s.
- UI copy is PT-BR; code identifiers are English.
> [!WARNING]
> **Grant the permissions and exempt the app from battery optimization.** The manifest requests Bluetooth
> scan/connect, fine location, notifications and a foreground service of type `connectedDevice`. Capture
> runs in that service; the **Bateria** button on the Sensor tab opens Android's battery-optimization
> settings (`REQUEST_IGNORE_BATTERY_OPTIMIZATIONS` is declared) so the background capture isn't
> throttled.
## How it works
```mermaid
flowchart LR
A["Chest strap (BLE)