Page map, data flow, and external integrations
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#0f766e', 'primaryTextColor': '#e2e8f0', 'lineColor': '#475569', 'secondaryColor': '#1e293b', 'tertiaryColor': '#1e293b' }}}%%
flowchart TB
subgraph SHOPIFY["☁️ Shopify Store — renuebyscience.com"]
direction TB
S_LANDING["📄 /pages/research\nResearch Landing"]
S_NAD["📄 /pages/research-nad-complete-sleep-study\nNAD+ Sleep Study"]
S_SERUM["📄 /pages/research-renue-blue-serum-28-day-study\nRenue Blue Serum Study"]
S_APIGENIN["📄 /pages/research-liposomal-apigenin-deep-sleep-study\nApigenin Deep Sleep Study"]
S_WAITLIST["📄 /pages/research-join-waitlist\nJoin Waitlist (Form)"]
S_PRIVACY["📄 /pages/research-privacy\nPrivacy Policy"]
S_CONSENT["📄 /pages/research-consent\nInformed Consent"]
end
subgraph WORKERS["⚡ Cloudflare Workers — renue-research.rod-1b4.workers.dev"]
direction TB
subgraph PORTAL["Participant Portal (22 pages)"]
W_HOME["🏠 / Landing"]
W_LOGIN["🔐 /login"]
W_DASH["📊 /dashboard"]
W_PROFILE["👤 /profile"]
W_ADMIN["🛡️ /admin"]
W_DOCS["📚 /docs/* (6 pages)"]
W_SURVEYS["📝 /survey/* (2 pages)"]
W_OTHER["📄 /active, /complete,\n/onboarding, /support,\n/resources, /index"]
end
subgraph API["REST API (21 endpoints)"]
A_AUTH["🔑 Auth API\nPOST /api/auth/send-link\nGET /auth/verify\nPOST /api/auth/logout\nGET /api/auth/me\nGET /review-access"]
A_PART["👥 Participant API\nGET /api/dashboard\nPOST /api/daily-notes\nPOST /api/survey/submit\nGET /api/survey/status\nPOST /api/support/message"]
A_ADMIN["🛡️ Admin API\n7 endpoints"]
A_WAITLIST["📋 POST /api/waitlist\n(CORS: public)"]
A_OURA["💍 Oura OAuth\nGET /oura/connect\nGET /oura/callback"]
A_HEALTH["💚 GET /api/health"]
end
W_CRON["⏰ Cron: checkPhases\nDaily 19:00 UTC"]
end
subgraph D1["💾 Cloudflare D1 — renue-research"]
DB_PART["participants"]
DB_ENROLL["study_enrollments"]
DB_NOTES["daily_notes"]
DB_SESSIONS["sessions + magic_links"]
DB_WAITLIST["waitlist"]
DB_OURA["oura_data + oura_tokens"]
DB_OTHER["studies, auth_log,\nsurvey_responses,\nsupport_messages"]
end
subgraph EXTERNAL["🌐 External Services"]
EXT_RESEND["📧 Resend API\nMagic link emails"]
EXT_OURA["💍 Oura Cloud API\nOAuth2 + sleep data"]
EXT_SHOPIFY_API["🛒 Shopify Admin API\nPage deployment"]
end
%% Shopify → Workers links
S_WAITLIST -->|"POST /api/waitlist\n(cross-origin fetch)"| A_WAITLIST
S_LANDING -->|"POST /api/waitlist\n(subscribe form)"| A_WAITLIST
S_LANDING -.->|"href links"| W_LOGIN
S_NAD -.->|"href links"| W_LOGIN
%% Shopify internal links
S_LANDING --> S_NAD
S_LANDING --> S_SERUM
S_LANDING --> S_APIGENIN
S_LANDING --> S_WAITLIST
S_NAD --> S_WAITLIST
S_PRIVACY --> S_LANDING
S_CONSENT --> S_LANDING
S_NAD --> S_PRIVACY
S_NAD --> S_CONSENT
%% Workers API → D1
A_AUTH --> DB_SESSIONS
A_PART --> DB_ENROLL
A_PART --> DB_NOTES
A_ADMIN --> DB_PART
A_WAITLIST --> DB_WAITLIST
A_OURA --> DB_OURA
W_CRON --> DB_ENROLL
%% Workers → External
A_AUTH -->|"Send magic link"| EXT_RESEND
A_OURA -->|"OAuth2 flow"| EXT_OURA
%% Deploy pipeline
EXT_SHOPIFY_API -.->|"create_shopify_pages.py\n(deploys mockup HTML)"| SHOPIFY
style SHOPIFY fill:#1e3a5f,stroke:#60a5fa,stroke-width:2px,color:#e2e8f0
style WORKERS fill:#0f3b35,stroke:#5eead4,stroke-width:2px,color:#e2e8f0
style D1 fill:#2e1065,stroke:#a78bfa,stroke-width:2px,color:#e2e8f0
style EXTERNAL fill:#3b2408,stroke:#fb923c,stroke-width:2px,color:#e2e8f0
style PORTAL fill:#0f3b35,stroke:#5eead4,stroke-width:1px,color:#e2e8f0
style API fill:#0f3b35,stroke:#5eead4,stroke-width:1px,color:#e2e8f0
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#0f766e', 'primaryTextColor': '#e2e8f0', 'lineColor': '#475569' }}}%%
sequenceDiagram
participant V as Visitor
participant S as Shopify Pages
participant W as Workers API
participant D as D1 Database
participant R as Resend Email
participant O as Oura API
Note over V,S: Discovery (Public)
V->>S: Browse /pages/research
V->>S: Read study details
V->>S: Fill waitlist form
S->>W: POST /api/waitlist (cross-origin)
W->>D: INSERT into waitlist
W-->>S: 200 OK
S-->>V: Success animation
Note over V,W: Enrollment (Staff approves)
W->>D: Admin approves waitlist entry
W->>D: INSERT participant + enrollment
Note over V,W: Authentication
V->>W: POST /api/auth/send-link
W->>D: Check participant exists
W->>D: INSERT magic_link (15min TTL)
W->>R: Send email with link
R-->>V: Email with magic link
V->>W: GET /auth/verify?token=...
W->>D: Consume token, CREATE session
W-->>V: Set cookie, redirect /dashboard
Note over V,W: Study Participation
V->>W: GET /api/dashboard
W->>D: SELECT enrollment + phase
W-->>V: Dashboard with study phase
V->>W: POST /api/daily-notes
W->>D: INSERT daily_notes
V->>W: POST /api/survey/submit
W->>D: INSERT survey_responses
Note over W,O: Oura Integration (Phase 8)
V->>W: GET /oura/connect
W->>O: OAuth2 authorize redirect
O-->>V: Auth code callback
V->>W: GET /oura/callback
W->>O: Exchange code for tokens
W->>D: STORE oura_tokens
Note over W,D: Automated Phase Transitions
W->>W: Cron: checkPhases (daily 19:00 UTC)
W->>D: SELECT active enrollments
W->>D: UPDATE phase if days elapsed
| Handle | Title | Source File | Page ID |
|---|---|---|---|
research | Research Landing | mockup-research-landing.html | 131477340418 |
research-nad-complete-sleep-study | NAD+ Sleep Study | renue-research-study.html | 131505946882 |
research-renue-blue-serum-28-day-study | Renue Blue Serum Study | renue-research-face-serum-study.html | 132213899522 |
research-liposomal-apigenin-deep-sleep-study | Apigenin Deep Sleep Study | renue-research-apigenin-sleep-study.html | 132213932290 |
research-join-waitlist | Join Waitlist | renue-research-waitlist.html | 131503685890 |
research-privacy | Privacy Policy | renue-research-doc-privacy.html | 131503456514 |
research-consent | Informed Consent | renue-research-doc-consent.html | 131503489282 |
Deployed via python3 create_shopify_pages.py --update → Shopify Admin API. CSS extracted & scoped to .research-portal-content. Theme template: page.research-portal.json.
| Route | File | Auth |
|---|---|---|
/ | renue-research.html | Public |
/login | login.html | Public |
/study | renue-research-study.html | Public |
/waitlist | renue-research-waitlist.html | Public |
/dashboard | dashboard.html | Session (JS-gated) |
/onboarding | renue-research-onboarding.html | Session |
/active | renue-research-active.html | Session |
/complete | complete.html | Session |
/profile | profile.html | Session |
/support | support.html | Session |
/resources | resources.html | Session |
/admin | renue-research-admin.html | Staff |
/docs/* | 6 doc pages | Public |
/survey/* | 2 survey pages | Session |
| Method | Route | Auth | Purpose |
|---|---|---|---|
| POST | /api/auth/send-link | Public | Send magic link email (3/hr rate limit) |
| GET | /auth/verify | Public | Verify token → create session → redirect |
| POST | /api/auth/logout | Session | Destroy session, clear cookie |
| GET | /api/auth/me | Public | Auth state check (200 or 401) |
| GET | /review-access | Secret | Staff auto-login for design review |
| POST | /api/waitlist | CORS | Add to waitlist (called from Shopify) |
| GET | /api/dashboard | Session | Participant dashboard + phase |
| POST | /api/daily-notes | Session | Submit daily health survey |
| POST | /api/survey/submit | Session | Submit phase survey |
| GET | /api/survey/status | Session | Check survey status |
| POST | /api/support/message | Session | Submit support message |
| POST | /api/admin/override-phase | Staff | Manual phase change |
| GET | /api/admin/participants | Staff | List all participants |
| POST | /api/admin/approve-waitlist | Staff | Approve waitlist → create participant |
| GET | /api/admin/participant/:id | Staff | Detailed participant profile |
| GET | /api/admin/activity | Staff | 24h activity feed |
| GET | /api/admin/waitlist | Staff | List waitlist entries |
| GET | /api/admin/stats | Staff | KPI stats + sparklines |
| GET | /oura/connect | Session | Redirect to Oura OAuth |
| GET | /oura/callback | Session | Handle OAuth callback |
| GET | /api/health | Public | Status heartbeat |
| Table | Key Columns | Purpose |
|---|---|---|
participants | id, email (unique), full_name, oura_confirmed | Registered study participants |
studies | id, name, duration_days, baseline_days, status | Study definitions |
study_enrollments | id, participant_id, study_id, phase, phase_started_at | Participant-study enrollment + phase tracking |
daily_notes | id, enrollment_id, date, caffeine, alcohol, energy, clarity | Daily health survey responses |
oura_data | id, enrollment_id, date, deep_sleep_pct, hrv | Imported Oura sleep/biometric data |
oura_tokens | id, participant_id, access_token, refresh_token, expires_at | Oura OAuth2 credentials |
sessions | token (PK), participant_id, expires_at, is_staff | Active login sessions (7-day TTL) |
magic_links | token (PK), email, expires_at, used | Passwordless login tokens (15-min TTL) |
waitlist | id, email (unique), name, has_oura, source | Pre-enrollment waitlist signups |
auth_log | id, email, event, detail, created_at | Auth events + rate limiting |
survey_responses | id, enrollment_id, survey_type, responses_json | Phase start/end survey data |
support_messages | id, participant_id, subject, message | Participant support requests |
| Service | Purpose | Status |
|---|---|---|
Resend API | Magic link emails via api.resend.com/emails | Active (temp: onboarding@resend.dev) |
Oura Cloud API | OAuth2 for sleep data (11 scopes) | Scaffolded (Phase 8) |
Shopify Admin API | Page deployment via create_shopify_pages.py | Active |
Pending: Resend domain verification for noreply.renuebyscience.com (Monday 11686890353). Oura OAuth end-to-end blocked on developer portal (Monday 11529000917).
| Step | Command | What it does |
|---|---|---|
| 1. Edit mockups | Edit static/*.html | Source of truth for all page content |
| 2. Deploy to Shopify | python3 create_shopify_pages.py --update | Extract CSS → strip elements → transform links → push via Admin API |
| 3. Sync Workers assets | cd workers && bash scripts/sync-assets.sh | Copy static/ → assets-built/ |
| 4. Deploy Workers | npm run deploy | Wrangler deploy to Cloudflare |
| 5. Verify | kit screenshot + npm test | Visual check + 199 tests |
CDN note: Shopify CDN caches page content for 15-30 min. Use ?preview_theme_id=159834898690 (staging theme) to bypass during development.
Generated 2026-04-08 · Renue Research Portal · 7 Shopify pages · 22 Workers pages · 21 API endpoints · 12 D1 tables