LAFYA Wellness+Wholeness to Wellness
Back
Internal Spec · v1.0

LAFYA Intelligence Engine Specification

The system of formulas, thresholds, and adaptive logic that powers every score, recommendation, and insight in the LAFYA experience.

1 · Scoring Formulas

Product Safety Score (0–100)

S = 100 − (Wc·Cn + Wa·An + Ws·Sn + Wp·Pn)
  • Cn contaminant load · weight Wc = 0.40
  • An additive risk · weight Wa = 0.25
  • Sn sodium / sugar load · weight Ws = 0.20
  • Pn packaging concern · weight Wp = 0.15

Daily Wellness Index (DWI)

DWI = 0.35·Nutrition + 0.25·Hydration + 0.25·Sleep + 0.15·Movement

Each input is normalized 0–100 from the prior 24h of logged + inferred signals. DWI drives the home dashboard tone and morning prompt.

2 · Grading Rules

A
85–100Excellent
B
70–84Good
C
55–69Moderate
D
40–54Caution
F
0–39Avoid

Any single contaminant exceeding its safe threshold caps the grade at C regardless of overall score. Two or more exceedances cap at D.

3 · Ingredient Database Structure

Ingredient {
  id:            UUID
  name:          string
  aliases:       string[]
  category:      enum
  risk_level:    safe | caution | risk
  evidence_tier: A | B | C
  thresholds: {
    safe_ppb:     number
    concern_ppb:  number
  }
  flags:         string[]   // bpa, gmo, organic…
  sources:       Citation[]
}

Database currently tracks 12,400 ingredients with 3,800 contaminant profiles. Refreshed weekly from peer-reviewed + regulatory sources.

4 · Recommendation Thresholds

Suggest as alternative

Score ≥ 80 · 0 risk flags

Allow

Show with advisory

Score 55–79 · ≤1 caution flag

Advise

Suppress recommendation

Score < 55 OR any risk flag

Block

Nutrient Gap Trigger

A nutrient is flagged as a gap when intake falls below 70% of the user's adjusted RDI for ≥ 4 of 7 rolling days, with confidence scaled by data completeness.

5 · AI Prompt Templates

Insight Summary

You are LAFYA, a calm wellness guide.
Given {scan_result} and {user_profile},
write a 2-sentence summary that names the
primary concern and one supportive action.
No medical claims. No alarmist tone.

Recommendation

Given gaps={nutrient_gaps} and
preferences={diet_prefs}, suggest 3 products
ranked by score. Format: name · why · score.

Daily Nudge

Based on {behavioral_state}, write one
short, encouraging nudge (≤ 18 words)
matching the user's current energy level.

6 · Behavioral States

Onboarding

First 7 days · educational tone

Engaged

≥ 4 sessions/week · adaptive depth

Drifting

< 2 sessions/week · gentle re-entry

Recovering

Sleep DWI < 50 · restorative cues

Calm UIRe-engageRecovery mode

7 · Adaptive Logic

if DWI < 60 for 3+ days:
  → surface Restore + Sleep Restore
  → switch tone to "supportive"

if hydration < 55%:
  → prioritize Hydration Restore card
  → morning nudge at +0h wake

if scan_streak ≥ 5:
  → unlock weekly Insight digest
  → upgrade education depth tier

Adaptive rules re-evaluate every 6 hours and on each scan. All transitions are logged for transparency and user-visible in Profile → Activity.

LAFYA Intelligence Engine · Specification v1.0
Trust-first wellness · No medical claims