𧬠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.
| Component | Technology | Purpose & Functionality |
|---|---|---|
| UI Framework | Tabler UI | Provides a robust, responsive component library (buttons, cards, navigation) ensuring a consistent and professional user experience across all devices. |
| Visualization Engine | D3.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 Rendering | KaTeX | Essential 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/UX | Light/Dark Mode Toggle | Improves 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.
| Component | Technology | Purpose & Functionality |
|---|---|---|
| Language/Runtime | PHP 8.x | Chosen for its performance improvements, modern syntax features (e.g., typed properties), and reliability in handling complex API requests and data transformations. |
| Database / BaaS | Supabase PostgreSQL | Provides 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 Model | Zero Trust Authentication | Crucial 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