1. Page Map — Where Everything Lives
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#0f766e', 'primaryTextColor': '#e2e8f0', 'lineColor': '#475569', 'secondaryColor': '#1e293b' }}}%%
flowchart LR
subgraph SHOPIFY["Shopify Store — renuebyscience.com"]
direction TB
S_LANDING["/pages/research\nLanding Page"]
S_NAD["/pages/...-sleep-study\nNAD+ Study"]
S_SERUM["/pages/...-serum-study\nRenue Blue Study"]
S_APIGENIN["/pages/...-apigenin-study\nApigenin Study"]
S_WAITLIST["/pages/...-join-waitlist\nWaitlist Form"]
S_PRIVACY["/pages/research-privacy\nPrivacy Policy"]
S_CONSENT["/pages/research-consent\nConsent"]
end
subgraph WORKERS["Cloudflare Workers — renue-research.rod-1b4.workers.dev"]
direction TB
W_LOGIN["/login\nMagic Link"]
W_DASH["/dashboard\nParticipant Home"]
W_ADMIN["/admin\nStaff Panel"]
W_DOCS["/docs/*\n6 resource pages"]
W_OTHER["/profile, /support\n/onboarding, /survey/*"]
end
S_LANDING --> S_NAD
S_LANDING --> S_SERUM
S_LANDING --> S_APIGENIN
S_LANDING --> S_WAITLIST
S_NAD --> S_WAITLIST
S_NAD --> S_PRIVACY
S_NAD --> S_CONSENT
S_PRIVACY --> S_LANDING
S_CONSENT --> S_LANDING
S_LANDING -.->|"href"| W_LOGIN
S_WAITLIST -.->|"POST /api/waitlist"| WORKERS
W_DASH -.->|"Back to Research"| S_LANDING
style SHOPIFY fill:#1e3a5f,stroke:#60a5fa,stroke-width:2px,color:#e2e8f0
style WORKERS fill:#0f3b35,stroke:#5eead4,stroke-width:2px,color:#e2e8f0
2. Data Flow — APIs, Database, External Services
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#0f766e', 'primaryTextColor': '#e2e8f0', 'lineColor': '#475569' }}}%%
flowchart TB
subgraph API["Workers API — 21 endpoints"]
A_AUTH["Auth API\nsend-link, verify,\nlogout, me"]
A_PART["Participant API\ndashboard, daily-notes,\nsurvey, support"]
A_ADMIN["Admin API\nparticipants, approve,\noverride-phase, stats"]
A_WAITLIST["Waitlist API\nPOST /api/waitlist\n(CORS: public)"]
A_OURA["Oura OAuth\nconnect, callback"]
A_CRON["Cron\ncheckPhases\ndaily 19:00 UTC"]
end
subgraph D1["D1 Database — 12 tables"]
DB_CORE["participants\nstudy_enrollments\nstudies"]
DB_DATA["daily_notes\nsurvey_responses\nsupport_messages"]
DB_AUTH["sessions\nmagic_links\nauth_log"]
DB_OURA["oura_data\noura_tokens"]
DB_WL["waitlist"]
end
subgraph EXT["External Services"]
RESEND["Resend API\nMagic link emails"]
OURA["Oura Cloud\nOAuth2 + sleep data"]
end
A_AUTH --> DB_AUTH
A_AUTH -->|"Send email"| RESEND
A_PART --> DB_DATA
A_PART --> DB_CORE
A_ADMIN --> DB_CORE
A_WAITLIST --> DB_WL
A_OURA --> DB_OURA
A_OURA -->|"OAuth2"| OURA
A_CRON --> DB_CORE
style API fill:#0f3b35,stroke:#5eead4,stroke-width:2px,color:#e2e8f0
style D1 fill:#2e1065,stroke:#a78bfa,stroke-width:2px,color:#e2e8f0
style EXT fill:#3b2408,stroke:#fb923c,stroke-width:2px,color:#e2e8f0
3. Deploy Pipeline — How Changes Reach Users
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#f472b6', 'primaryTextColor': '#e2e8f0', 'lineColor': '#94a3b8' }}}%%
flowchart LR
SRC["static/*.html\nSource mockups"]
EXTRACT["extract_styles()\nCSS scoped to\n.research-portal-content"]
STRIP["strip_elements()\nRemove nav, footer,\nscripts, mockup badges"]
TRANSFORM["transform_links()\n/ → /pages/research\n/login → Workers URL"]
REINJECT["Re-inject JS\nwaitlist handler\ncard click handler\nsubscribe form"]
API["Shopify Admin API\nPUT page body_html"]
CDN["Shopify CDN\n15-30 min cache\n?preview_theme_id\nbypasses cache"]
LIVE["Live on\nrenuebyscience.com"]
SYNC["sync-assets.sh\nCopy to assets-built/"]
WRANGLER["wrangler deploy\nWorkers + D1"]
WORKERS_LIVE["Live on\nWorkers .dev"]
SRC --> EXTRACT --> STRIP --> TRANSFORM --> REINJECT --> API --> CDN --> LIVE
SRC --> SYNC --> WRANGLER --> WORKERS_LIVE
style SRC fill:#1e293b,stroke:#f472b6,stroke-width:2px,color:#e2e8f0
style CDN fill:#1e293b,stroke:#fbbf24,stroke-width:2px,color:#fbbf24
style LIVE fill:#1e3a5f,stroke:#60a5fa,stroke-width:2px,color:#e2e8f0
style WORKERS_LIVE fill:#0f3b35,stroke:#5eead4,stroke-width:2px,color:#e2e8f0
4. User Journey — Full Lifecycle
%%{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
Detailed Reference
Shopify Pages (7 pages on renuebyscience.com)
| 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. CSS scoped to .research-portal-content. Theme template: page.research-portal.json. Staging theme: 159834898690.
Workers Portal Pages (22 routes)
| 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 |
Workers API Endpoints (21 routes)
| 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 |
D1 Database Schema (12 tables)
| 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 | 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 |
External Service Integrations
| 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. Oura OAuth end-to-end blocked on developer portal.
Deploy Pipeline (see Diagram 3)
| 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, re-inject JS, push via Admin API |
| 3. Sync Workers assets | bash scripts/sync-assets.sh | Copy static/ to assets-built/ |
| 4. Deploy Workers | npm run deploy | Wrangler deploy to Cloudflare |
| 5. Verify | python3 test_e2e_full.py | 12-phase E2E test (440s, all green) |
CDN: Shopify CDN caches 15-30 min. Use ?preview_theme_id=159834898690 (staging theme) to bypass. The deploy pipeline diagram above shows where CSS scoping, script stripping, and link transforms happen.
Updated 2026-04-08 (Mentor-reviewed, rev 2) | 7 Shopify pages | 22 Workers pages | 21 API endpoints | 12 D1 tables