PTENES
MODULE 3.4

📊 Dashboard and tracking

See the story in the numbers: the live dashboard (/healthdb), the Sleep & Recovery card, weight/intake/vitals trends, and the cycle data → adjustment → result. This is the module that wraps up the course.

7
Topics
~35
Minutes
Practical
Level
Use
Type
Your progress in this module 0% · 0 of 7
1

🔗 The /healthdb link: the live dashboard

The coach lives in Telegram, but sometimes you want to see everything at once — weekly sleep, falling weight, blood pressure, intake. That’s what the command /healthdb: it sends you a deep-link that opens the live dashboard, reading directly from your Supabase. It's the same source of truth as the bot, but in a visual dashboard.

🟣 New here?

  • Dashboard — a web page (in agent/dashboard/) that reads your Supabase and draws cards and charts. Same database as the coach, another window.
  • Deep-link — a link that opens directly in the right place and authenticated. Here it loads your token all at once, without you entering a password.
  • HttpOnly cookie — a cookie the browser stores but the page’s JavaScript no can read. It helps hide the token from malicious scripts.
healthdb · HealthOS ● live
😴 Sleep & Recovery
71%
⚖️ Weight (14 d)
75.0 kg
▼ 3.5 kg in the sprint
🍽️ Intake today
1,840 kcal
P 142g · C 160g · G 58g
🩺 Blood pressure
118/76
7-day average · stable
💓 HRV / RHR
64 ms / 52
going up during the week
💊 Supplements
6/6 ✓
adherence today

🎛️ Illustrative recreation of the dashboard — isn’t a real screenshot. Made-up numbers, just to show the layout.

📊 How to read: the window has a title bar (3 dots) and independent cards. Each card is a data source: sleep, weight, intake, blood pressure, HRV. The mini bars show the trend, not just today’s number — that’s what the panel adds to the chat.

▶ Copy and use — the dashboard deep link URL

Goal: open the authenticated live dashboard. In Telegram, you just send /healthdb and the coach returns this button; the link itself looks like this:

https://<seu-host>/healthdb?token=<DASHBOARD_TOKEN>

How to verify: when you open it, the dashboard loads; reload the page and notice that the ?token=... disappears from the URL — it migrated to an HttpOnly cookie on the 1st load. If the dashboard stays open without the token in the address bar, it worked.

💡 Why a link, not a password

The token goes once in the URL and disappears afterward — it stays only in the HttpOnly cookie. You don’t type anything, and the secret isn’t left in your browser history after the 1st load. It’s convenient without leaving the door unlocked.

Key concepts

/healthdb

The command that generates the dashboard button.

Deep-link

Opens directly and you’re already authenticated.

Token → cookie

Disappears from the URL on the 1st load.

Same truth

Reads from the same Supabase as the coach.

2

😴 The Sleep & Recovery card

The most important card on the dashboard is the Sleep & Recovery: the last 7 days of sleep and recovery, side by side. One number can lie; seven days show the pattern — whether you’re building up sleep debt or have recovered. It’s the same data that goes into the coach’s snapshot, now shown visually.

Mon7h10 Have7h45 Wed5h30 Thu6h55 Sex8h05 Sat7h20 Today7h40 62%70%48%58%80%66%71% Sleep (purple bar) × Recovery % (cyan line) · 7 days

📊 How to read: the purple bar shows how much you slept; the cyan line is how you recovered. Notice Wednesday (red bar, 5h30 → recovery 48%): a short night pulls recovery down. On Friday, you slept longer and recovered to 80%. The dashboard shows the relationship, not isolated numbers.

🔎 What to look for on this card

  • •A trend of the week, not the day: 7 days tell you whether you're repaying or accumulating sleep debt.
  • •The you’re worth (red days) and what came before: late dinner, alcohol, a hard workout at night.
  • •If recovery goes up later of a good night's sleep—confirms that sleep is your biggest lever.

Key concepts

7 days

The window that reveals the pattern.

Sleep × recovery

The bar and line tell the same story.

Values

The bad day points to the cause from the previous day.

Same data

It’s what the coach uses in the snapshot.

3

📉 Trends: weight, intake, and vitals

Weight, intake (what you ate), and vitals (blood pressure, HRV, resting heart rate) only make sense over time. Today’s weight could be water; the line of two weeks is the truth. The dashboard plots these trends so you can see the direction, not the daily noise.

target range (~75 kg) 79 kg77 kg75 kg 78,5 75,0 D1D5D10D14 Weight · 14 days · −3.5 kg

📊 How to read: ignore it if a point rises a little (water, salt). What matters is the slope: the line drops from 78.5 to 75.0 kg and enters the target range (cyan). A gentle downward trend > obsession with the daily number.

▶ Copy and run — check the trend in the database terminal

Goal: see the same points the dashboard plots, straight from Supabase, without opening the browser.

python3 agent/scripts/db.py query \
  "select date, weight_kg from vitals \
   where weight_kg is not null \
   order by date desc limit 14"

How to verify: a 14-row table comes out with the date and weight. Check that the values match the weight card row in the /healthdb — the dashboard and database tell the same story.

✓ Read the trend

  • ✓Look at the 7–14-day trend.
  • ✓Cross-reference weight ↓ with this week's intake and sleep.
  • ✓Wait for the line before changing strategy.

✗ Reacting to noise

  • ✗Panic because you gained 0.4 kg in a day.
  • ✗Cutting food based on a single spike.
  • ✗Weigh yourself at different times and compare.

Key concepts

Slope

The direction of the line > today’s point.

Noise

Water and salt affect the day, not the week.

Intake

What went in: calories and macros.

Vitals

Blood pressure, HRV, RHR over time.

4

📖 Read it as a story, not an isolated number

A number by itself—"recovery 48%"—doesn’t teach you anything. The history teaches: why fell, what changed, what do. The dashboard shows the numbers; you (and the coach) turn them into a narrative. Reading the dashboard means asking “what’s the story this week?”

✗ Standalone number

  • ✗"Recovery 48%." So what? It doesn’t tell you the cause or the next step.
  • ✗"Weight 75.4." Up or down? Compared to what?
  • ✗Look at one data point, feel guilty, close the dashboard.

✓ As a story

  • ✓"Dropped to 48%" because I ate dinner late + wine; tomorrow I eat dinner early."
  • ✓"Weight has been dropping for 10 days; the change was stopping eating at 7 p.m."
  • ✓Review the week, understand the cause, adjust one thing.
1

See the valley

Recovery plummeted on Wednesday. The number alone is just alarming.

2

Finds the cause

Look at the previous day on the intake card: dinner at 9:30 PM + two glasses of wine.

3

Take away the lesson

"Late dinner + alcohol = low recovery for me." It becomes a familiar pattern.

4

Adjust and confirm

Eat dinner early on Thursday; by Friday, recovery is back to 80%. The story is complete — and it taught you one of your buttons.

Key concepts

Why

The cause behind the number.

What changed

The variable that moved the line.

Narrative

Number → cause → next step.

No guilt

Data is information, not judgment.

5

🔐 Dashboard security

The dashboard displays health data—sensitive information. The DASHBOARD_TOKEN: a secret key in your ~/.env that unlocks the dashboard. Without the right token, the page won’t open. And the token is never exposed: after the 1st load, it lives only in HttpOnly cookie.

🟣 New here?

  • DASHBOARD_TOKEN — one of the keys to ~/.env (the README table says: "Gates the web dashboard"). It’s the secret that unlocks the dashboard.
  • ~/.env — file in your home directory where secrets are stored. Kept out of git, never versioned.
  • HttpOnly — the cookie exists for the server, but the page’s JavaScript can’t read it. This reduces the risk if a malicious script runs in the tab.
🔑 ~/.envDASHBOARD_TOKEN 🔗 URL (first time)?token=… 🍪 HttpOnly cookiestored token ✅ Clean URLtoken disappears the secret appears only once in the URL and disappears as soon as it becomes a cookie

📊 How to read: from left to right is the token's path: it starts in the ~/.env, visit the URL once, it’s stored in the HttpOnly cookie (purple box), and the URL is cleaned up (green box). After that, the secret is no longer visible in the address bar.

▶ Copy and run — generate the DASHBOARD_TOKEN terminal

Goal: create a long, random token and save it in your ~/.env (never an easy-to-guess value).

python3 -c "import secrets; print('DASHBOARD_TOKEN=' + secrets.token_urlsafe(32))" \
  >> ~/.env

How to verify: run grep DASHBOARD_TOKEN ~/.env and see a line with ~43 random characters. Restart the dashboard server and the /healthdb only starts opening with that token.

⚠️ Never do this with the token

  • •Paste the link ?token=... in a group, screenshot, or social network — it’s the key to your dashboard.
  • •Commit the ~/.env or the token in git.
  • •Using a short/obvious value (e.g., 123456). If it leaks, generate another one and replace it in the ~/.env.

Key concepts

DASHBOARD_TOKEN

The key that unlocks the dashboard.

HttpOnly

A cookie that JavaScript can't read.

~/.env

Secret kept out of git.

Leaked? Rotate it

Generate another token and update it.

6

🗓️ Review every week

The coach reviews the morning (daily). The dashboard is for reviewing the week: once a week, open the /healthdb calmly and read the four trends as a report. Five minutes turn accumulated data into a decision.

✅ Weekly review checklist

①Sleep & recovery — did the average go up or down? Where was the low point, and why?
②Weight — is the 14-day trend heading toward the goal?
③Intake — hitting your protein target? Eating dinner early most days?
④Vitals — stable blood pressure? HRV/RHR improving?
⑤Supplements — is the week’s adherence okay?
⑥1 adjustment — choose ONE change for next week, not ten.
▶ Copy and run — update the vitals before reviewing terminal

Goal: make sure the entire week’s recovery and sleep data is already in the database before you open the dashboard.

python3 agent/scripts/whoop-sync.py

How to verify: the script writes recovery_pct, hrv_ms, resting_hr e sleep_hours in the table vitals. Running it again is idempotent (it doesn’t create duplicates). Afterward, the Sleep & Recovery card in the /healthdb shows the full week.

💡 One adjustment at a time

The weekly review isn’t about changing everything. Choose a button (eat dinner earlier, cut out coffee in the afternoon, go to bed 30 min earlier) and test it for seven days. At the next review, the trend confirms it — or doesn’t. That’s how you learn the your buttons without turning it into a guilt spreadsheet.

Key concepts

Weekly rhythm

Morning = coach; week = dashboard.

4 trends

Sleep, weight, intake, vitals.

1 adjustment

One testable change per week.

Idempotent

Running the sync again doesn’t create duplicates.

7

🔁 Data → adjustment → result

Everything in the course converges into a single cycle: you see the data in the dashboard, run an adjustment, and next week shows the result — which becomes the new data point. That was the loop that led the author to −3.5 kg in the sprint, without going hungry: sleeping soundly and stopping eating around 7 p.m.

📊 Datadashboard: sleep, weight, vitals 🛠️ Adjustmentdinner at 7 p.m. · go to bed full 🎯 Result−3.5 kg, without hunger the result becomes the new data — the cycle turns every week The loop that closes out the course

📊 How to read: three boxes, one cycle. Data (dashboard) → Adjustment (a small change) → Result (green, the goal) → and the bottom arrow returns to Data. Each cycle is a week. The secret to −3.5 kg wasn’t willpower: it was the cycle turning.

Data — the dashboard showed recovery dropping on days you had a late dinner and your weight stalling.
Adjustment — stop eating around 7 p.m. and go to bed full (not hungry), instead of abruptly cutting food.
Result — −3.5 kg in the sprint without going hungry; higher and steadier recovery. That result becomes the data for the following week.

🏁 The whole course in one sentence

You built a coach that log (Track 2), which talks with you every day (Track 3) and that shows you the story in the numbers (this module). The rest is keeping the cycle going: observe, adjust, confirm. You’ll learn the buttons by doing.

✅ Self-check (optional): what helped the author lose −3,5 kg without going hungry?

Key concepts

Data

The dashboard shows where you are.

Adjustment

A small, testable change.

Result

−3.5 kg without hunger: the loop working as intended.

Rotate again

The result becomes the next data point.

📋 Module summary

✓
/healthdb opens the live dashboard — deep link with token; the token becomes an HttpOnly cookie on the 1st load and disappears from the URL.
✓
Sleep & Recovery over 7 days — the card shows the week’s pattern, not an isolated number.
✓
Trends > day — weight, intake, and vitals only make sense as trends over time.
✓
Read it as a story — number → cause → next step; weekly review with 1 adjustment.
✓
Data → adjustment → result — the cycle that led to −3.5 kg without going hungry. Dashboard security via DASHBOARD_TOKEN.

🎉 You completed the course!

You’ve completed the course! Go back to the beginning to review any track or pick up where you left off. Now put the cycle into practice in your own routine — observe, adjust, confirm.