Build GlucoseIQ into the premier headless CGM TypeScript framework:
UI-agnostic, protocol-first, and capable of powering independent dashboards
and large product platforms. The diabetic-utils package remains the
compatibility bridge for existing projects.
The strategy is not to ship a full vertical platform; it is to ship a world-class headless core that any product team can compose into their own experience.
- Core first:
coreis the main course and must be exceptional. - Composable ecosystem: optional packages make adoption easier across app stacks.
- Enterprise-capable without enterprise bloat: robust enough for large deployments, lean enough for modern frontend/backend teams.
The current codebase already includes essential building blocks for a headless CGM system:
- Canonical glucose models and utility conversions.
- Vendor normalization adapters (Dexcom, Libre, Nightscout).
- Broad analytics coverage (TIR, AGP, risk/variability metrics).
- Interop builders (FHIR/Open mHealth).
- Strong automated testing and modular functions.
-
Domain contract layering is incomplete
- Need strict contracts for each stage:
- source payload,
- normalized event,
- aligned timeline,
- computed analytics snapshot,
- presentation-ready derivative series.
- Need strict contracts for each stage:
-
Connector model lacks capability metadata
- Add explicit connector capability descriptors:
- update frequency and freshness,
- trend vocabulary coverage,
- source clock behavior,
- supported history depth,
- quality/reliability flags.
- Add explicit connector capability descriptors:
-
Feature orchestration is manual
- Add first-class pipelines for common workflows:
- ingest -> normalize -> align -> aggregate -> export.
- Add first-class pipelines for common workflows:
-
Validation ergonomics need opt-in tiers
- Keep core lean and fast.
- Provide optional runtime schema adapters (Zod/standard schema) as add-ons.
-
Framework entrypoints are not yet productized
- Create headless app-integration helpers for Next.js and TanStack ecosystems without coupling to UI frameworks.
Why this fits a lightweight, library-first project:
- Minimal ceremony and fast local feedback loops.
- Great DX for multiple publishable packages.
- Strong cache/task orchestration without heavyweight abstractions.
Suggested package layout:
packages/corepackages/connectorspackages/pipelinespackages/interoppackages/schemas(optional)packages/query(optional)examples/*(Next.js, TanStack Start, MUI X dashboards)
Use only if you need deep enterprise governance features (complex dependency graph policy, large team guardrails, advanced generators).
For this project’s current size and speed goals, Nx likely adds unnecessary operational complexity.
Treat connectors as capability-driven modules with explicit profiles.
- Dexcom
- Libre
Requirements:
- full trend mapping coverage,
- high-resolution timestamp handling,
- robust de-duplication and backfill support,
- deterministic normalization with strict error unions.
- Nightscout and other relay sources.
Requirements:
- provenance metadata,
- source-quality scoring,
- replay/clock-skew guardrails.
Some devices expose narrower operating/alert ranges or reduced telemetry semantics compared with full-fidelity CGM streams.
Plan:
- represent device constraints explicitly in connector capabilities,
- mark unsupported metrics as
notComputablerather than silently guessing, - provide policy helpers so consumers choose strict vs permissive behavior.
Note: regulatory and labeling differences vary by market and can change; treat these as external policy inputs, not hardcoded assumptions.
- Purity by default: deterministic transforms, no hidden side effects.
- Typed error unions: parse/transport/domain errors are explicit and discriminated.
- Time semantics are explicit: timezone, ordering, and gap policy are configurable.
- Stable contracts: additive evolution first; deprecate with migration guides.
- Performance budget: avoid heavy runtime deps in core path.
For each new feature (including each connector), require the same structured lifecycle:
-
Problem definition
- clinical/analytics intent,
- data prerequisites,
- failure modes.
-
Contract design
- input/output type contracts,
- capability and error model,
- invariants and edge-case semantics.
-
Implementation
- pure normalization/computation,
- no framework coupling,
- benchmark against performance budget.
-
Verification
- golden fixtures,
- edge-case tests,
- compatibility tests across package boundaries.
-
Documentation + examples
- reference docs,
- example integration (Next.js / TanStack Start / MUI X),
- migration notes if behavior changed.
- Introduce capability descriptors and strict connector error unions.
- Add aligned timeline contract and gap/collision policies.
- Keep existing exports stable; add new APIs additively.
- Ship reusable orchestration pipelines and snapshot envelopes.
- Add deterministic series builders for dashboards.
- Publish optional
schemasandquerypackages. - Add transport-agnostic fetch/retry helpers and cache key utilities.
- Ship polished examples + starter kits.
- Publish interoperability playbooks and migration guides.
- Track onboarding time and production success metrics.
- <30 minutes from install to first working dashboard.
- Tier-1 connectors pass exhaustive fixture suites.
- Core package remains dependency-light and framework-agnostic.
- Optional packages improve adoption without burdening minimal users.
- Clear semver and migration confidence for long-term trust.