Skip to main content

🧬 Sleeper Health Application Documentation

Project: body.project4.net Version: 1.0 (Initial Release) Focus: Longitudinal, data-driven health and bio-metric tracking platform.


πŸ“„ I. Overview and Purpose​

Sleeper Health is a sophisticated web application designed for the comprehensive, longitudinal monitoring of user physiological metrics. The platform integrates diverse data streamsβ€”from wearable technology readings (Garmin) to clinical bloodwork panels and specialized hormone markers (TRT)β€”into a unified, actionable dashboard.

The core objective is to provide users with a clear, scientifically rigorous visualization of their body composition changes and biomarker trends over time, enabling proactive health management and informed discussions with healthcare providers.

Key Architectural Pillars​

  • Data Integrity: Utilizing PostgreSQL for robust schema management.
  • Security: Implementing Zero Trust principles for maximum data protection.
  • Visualization: Employing D3.js to render complex, publication-grade scientific charts.

πŸ’» II. Technical Architecture Stack​

The application follows a modern decoupled architecture (Client $\leftrightarrow$ API $\leftrightarrow$ Database).

A. Frontend Implementation (The Client Layer)​

The frontend is built for high interactivity, accessibility, and visual fidelity, ensuring that complex data visualizations are presented intuitively.

ComponentTechnologyPurpose & Functionality
UI FrameworkTabler UIProvides a robust, responsive component library (buttons, cards, navigation) ensuring a consistent and professional user experience across all devices.
Visualization EngineD3.js (Data-Driven Documents)The core visualization tool. Used to generate custom, publication-grade anthropometric charts (e.g., body fat percentage curves, circumference changes). D3 allows for granular control over axes, scales, and data transitions necessary for scientific charting.
Mathematical RenderingKaTeXEssential for displaying complex formulas, statistical models, and biomarker calculations (e.g., calculating Free T4 from total T4 measurements) with high accuracy and fast rendering speed.
Theming/UXLight/Dark Mode ToggleImproves user accessibility and reduces eye strain during prolonged data review sessions by allowing users to switch between light and dark color palettes.

B. Backend Implementation (The Engine Layer)​

The backend is responsible for authentication, API routing, business logic execution, and secure data persistence.

ComponentTechnologyPurpose & Functionality
Language/RuntimePHP 8.xChosen for its performance improvements, modern syntax features (e.g., typed properties), and reliability in handling complex API requests and data transformations.
Database / BaaSSupabase PostgreSQLProvides a reliable, scalable relational database structure. Supabase handles schema management, authentication hooks, and real-time data synchronization, simplifying the backend development process while maintaining enterprise-grade stability.
Security ModelZero Trust AuthenticationCrucial Security Feature. The system assumes no user or device is inherently trustworthy. Every API request must be authenticated, authorized, and validated against the principle of least privilege (PoLP). This minimizes the attack surface area, especially critical when handling sensitive health data.

πŸ“Š III. Data Model and Tracked Metrics​

The application tracks three primary categories of highly specialized physiological data, all stored within the structured sleeper PostgreSQL schema.

A. Body Composition Tracking​

These metrics provide a holistic view of physical changes over time, moving beyond simple weight