Skip to Content
FFitDatadraft
Specification

Entity Model & Naming

Uniform domain.noun entity kinds, optional ownership metadata, and distinct version vs revision lifecycles.

FitData describes portable domain entities rather than user-owned database rows. Every top-level record follows one naming convention, one envelope model, and one explicit lifecycle.

Core design principles

1. Entities first, ownership optional

  • kind and id are required on every entity.
  • subject, recordedAt, provenance, links, and extensions are optional on standalone entities.
  • A document can declare a default subject for single-person exports so individual records do not repeat it.
  • Multi-user platforms, clinical stores, and audit pipelines enforce mandatory subject, recordedAt, provenance, or producer through document profiles rather than baking account ownership into core entity schemas.

2. Distinct version and revision lifecycles

Versioning stays separate from ownership:

  • version (string) identifies a release of a reusable entity or catalogue concept (training.routine, nutrition.food, nutrition.nutrient, lab.biomarker, lab.test). Updating a food or routine creates a new version without rewriting historical references.
  • revision (positive integer) identifies a correction to a recorded event or personal state (core.measurement, training.workout, nutrition.intake, lab.result, lab.report).

References pin either { id, version } (definition reference) or { id, revision } (record reference).

3. Uniform domain.noun kind syntax

Every top-level entity kind matches ^[a-z]+\.[a-z]+$:

  • Both <domain> and <noun> are single lowercase English words.
  • No camelCase compounds, no redundant domain prefixes on the noun (lab.labResult is invalid), and no wrapper suffixes (Entry, Definition, Concept, Bundle).
  • Nested discriminated unions inside an entity use short single-word tags such as exact, range, relative, ramp, completed, partial, and skipped.

4. One canonical entity per concept

FitData merges concepts that previously differed only by source dialect or ownership:

  • training.workout covers both wearable activity summaries (metrics, movingSeconds) and structured sessions (steps), or both together.
  • training.routine covers both reusable class blueprints (without subject or scheduled) and coach-assigned sessions (with optional subject and scheduled).
  • core.summary unifies daily summaries, interval aggregates, and meal rollups under one scope (day, interval, meal).
  • Closed lab reports use a standard FitData document with references: "closed" instead of a separate bundle wrapper kind.

Canonical kind catalog

All 18 top-level record kinds implemented in 0.0.0-local:

KindPackageLifecyclePurpose
core.measurement@fitdata/corerevisionPoint-in-time reading (body mass, resting HR, HRV, temperature, soreness)
core.series@fitdata/corerevisionSampled time-series stream (HR, power, cadence, speed, GPS)
core.summary@fitdata/corerevisionRolled-up totals or statistics for a day, meal, or interval
core.tombstone@fitdata/corerevisionDeletion marker for an exact { id, revision }
sleep.sessionfitdatarevisionSleep interval, nap flag, stages, and sleep metrics
training.routine@fitdata/trainingversionReusable or scheduled session blueprint (steps or timed segments, targets, cues)
training.workout@fitdata/trainingrevisionPerformed exercise session (sport, interval, status, summary metrics, optional steps)
training.threshold@fitdata/trainingrevisionReference performance value (FTP, max HR, 1RM)
nutrition.food@fitdata/nutritionversionFood item, servings, and nutrient compositions
nutrition.nutrient@fitdata/nutritionversionNutrient concept, preferred unit, and external codes
nutrition.intake@fitdata/nutritionrevisionLogged consumption of a food snapshot or direct nutrients
nutrition.meal@fitdata/nutritionrevisionNamed group of exact nutrition.intake revisions
nutrition.goal@fitdata/nutritionrevisionTarget nutrient amounts starting on an effective calendar date
lab.biomarker@fitdata/labversionAnalyte or biomarker concept
lab.test@fitdata/labversionMeasurable lab assay (biomarker, specimen, property, scale, method, units, LOINC)
lab.specimen@fitdata/labrevisionBiological sample metadata and collection time
lab.result@fitdata/labrevisionSingle laboratory test result with raw text, typed value, status, review, and ranges
lab.report@fitdata/labrevisionLaboratory report grouping panels, specimens, and results

Versioning boundaries

FitData keeps five version concepts strictly separate:

  1. Package version identifies executable code and public TypeScript APIs.
  2. Schema version identifies the serialized domain contract.
  3. Definition version identifies a specific food, nutrient, routine, biomarker, or lab test definition.
  4. Record revision identifies a correction to a person's recorded event or result.
  5. Mapper / calculation version identifies transformation behavior.

On this page