Data Pipeline
getActiveData() in js/data.js is the central data pipeline. Every view — dashboard, category charts, compare, correlations, AI context — calls it to get processed data. It is a pure function with no side effects; it reads from state and returns a fresh data object each time.
Pipeline flowchart
data:
Marker key convention
Markers are always referenced as"category.markerKey":
UNIT_CONVERSIONSkeysOPTIMAL_RANGESkeysPHASE_RANGESkeysimportedData.entries[].markers— each entry stores its values keyed this wayimportedData.customMarkers— custom marker definitions- AI prompt references in
buildMarkerReference()
Entry storage format
importedData.entries is an array of lab snapshots. Each entry has a date and a flat markers object:
Object.assign) into a single lookup slot. The pipeline builds entryLookup: { "2025-03-15": { "biochemistry.glucose": 5.2, ... } } before populating values arrays.
Values arrays — aligned with dates
Every marker in the output has avalues array aligned with data.dates:
null means the marker was not measured on that date. Charts use spanGaps: true to draw lines across gaps. Status functions check for null before evaluating.
singlePoint categories
ThefattyAcids category has singlePoint: true in the schema. These markers typically come from a single test, not a time series. The pipeline handles them differently:
- Only the latest entry date is used, stored as
cat.singleDate - Each marker gets
marker.singlePoint = trueand a single-elementmarker.valuesarray - Views render grid cards instead of trend charts for these categories
Custom markers
Markers not inMARKER_SCHEMA are auto-imported from PDFs. The pipeline merges them into data.categories at runtime:
marker.custom = true and are treated identically to schema markers in all views.
Calculated markers
These are computed in-pipeline and stored in thecalculatedRatios category:
| Marker key | Formula |
|---|---|
tgHdlRatio | Triglycerides / HDL |
ldlHdlRatio | LDL / HDL |
apoBapoAIRatio | ApoB / ApoAI |
nlr | Neutrophils / Lymphocytes |
plr | Platelets / Lymphocytes |
deRitisRatio | AST / ALT |
copperZincRatio | Copper / Zinc |
bunCreatinineRatio | (urea × 2.801) / (creatinine × 0.01131) — computed in US units from SI-stored values, ref 10–20 |
freeWaterDeficit | TBW × (Na / 140 − 1) — assumes 70 kg body weight |
phenoAge | Levine 2018 — 9 biomarkers + chronological age from DOB |
null if any of its 9 required inputs is missing or if DOB is not set.
The data parameter pattern
getActiveData() deep-clones the full schema on every call — it is not free. Views accept an optional data parameter so a single pipeline run can feed multiple renders:
data as an optional parameter and call getActiveData() only when it is not provided.