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
kindandidare required on every entity.subject,recordedAt,provenance,links, andextensionsare optional on standalone entities.- A document can declare a default
subjectfor single-person exports so individual records do not repeat it. - Multi-user platforms, clinical stores, and audit pipelines enforce mandatory
subject,recordedAt,provenance, orproducerthrough 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.labResultis 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, andskipped.
4. One canonical entity per concept
FitData merges concepts that previously differed only by source dialect or ownership:
training.workoutcovers both wearable activity summaries (metrics,movingSeconds) and structured sessions (steps), or both together.training.routinecovers both reusable class blueprints (withoutsubjectorscheduled) and coach-assigned sessions (with optionalsubjectandscheduled).core.summaryunifies daily summaries, interval aggregates, and meal rollups under onescope(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:
| Kind | Package | Lifecycle | Purpose |
|---|---|---|---|
core.measurement | @fitdata/core | revision | Point-in-time reading (body mass, resting HR, HRV, temperature, soreness) |
core.series | @fitdata/core | revision | Sampled time-series stream (HR, power, cadence, speed, GPS) |
core.summary | @fitdata/core | revision | Rolled-up totals or statistics for a day, meal, or interval |
core.tombstone | @fitdata/core | revision | Deletion marker for an exact { id, revision } |
sleep.session | fitdata | revision | Sleep interval, nap flag, stages, and sleep metrics |
training.routine | @fitdata/training | version | Reusable or scheduled session blueprint (steps or timed segments, targets, cues) |
training.workout | @fitdata/training | revision | Performed exercise session (sport, interval, status, summary metrics, optional steps) |
training.threshold | @fitdata/training | revision | Reference performance value (FTP, max HR, 1RM) |
nutrition.food | @fitdata/nutrition | version | Food item, servings, and nutrient compositions |
nutrition.nutrient | @fitdata/nutrition | version | Nutrient concept, preferred unit, and external codes |
nutrition.intake | @fitdata/nutrition | revision | Logged consumption of a food snapshot or direct nutrients |
nutrition.meal | @fitdata/nutrition | revision | Named group of exact nutrition.intake revisions |
nutrition.goal | @fitdata/nutrition | revision | Target nutrient amounts starting on an effective calendar date |
lab.biomarker | @fitdata/lab | version | Analyte or biomarker concept |
lab.test | @fitdata/lab | version | Measurable lab assay (biomarker, specimen, property, scale, method, units, LOINC) |
lab.specimen | @fitdata/lab | revision | Biological sample metadata and collection time |
lab.result | @fitdata/lab | revision | Single laboratory test result with raw text, typed value, status, review, and ranges |
lab.report | @fitdata/lab | revision | Laboratory report grouping panels, specimens, and results |
Versioning boundaries
FitData keeps five version concepts strictly separate:
- Package version identifies executable code and public TypeScript APIs.
- Schema version identifies the serialized domain contract.
- Definition version identifies a specific food, nutrient, routine, biomarker, or lab test definition.
- Record revision identifies a correction to a person's recorded event or result.
- Mapper / calculation version identifies transformation behavior.