Turning Gym App Screenshots into a Private Health Dashboard
How I used Go, Gemini and GitHub Actions to pull body-scan data out of an app with no export button, and the Netlify Edge Function that keeps it private.
In this post I’m going to walk you through a little side project that started with a simple annoyance: my gym’s app has no way to export my data.
The problem
I do regular body-composition scans at David Lloyd. The app shows the results as a long list of cards: weight, body fat, muscle mass, body water, left and right arm and leg readings, and plenty more. It looks nice, but there’s no API, no export button and no way to see a trend over more than a couple of scans.
My other fitness data already flows into my site. Every week a GitHub Action downloads my Android Health Connect backup from Google Drive, opens the SQLite database inside it, and writes a small fitness.json with my weekly step and workout totals. The home page reads that at build time, so the Activity section is plain HTML with zero JavaScript.
So the question was: if the only way to get the gym data out is a screenshot, can I turn screenshots into data?
The first plan, and why I changed it
My first idea was a hidden upload page on the site. I’d pick a screenshot on my phone, post it to a Netlify Function written in Go (I’m learning Go, so that part was non-negotiable), have Gemini read the numbers, and commit the result back to the repo.
Then I read Netlify’s docs properly. Go functions run in “Lambda compatibility mode”, and that mode is deprecated: from July 2027, deploys that include those functions won’t be accepted. Building something new on a runtime with a closing date didn’t make much sense.
Thinking about it more, I didn’t need an upload page at all. I already had a pipeline that reads from Google Drive on a schedule. So the new plan was much simpler:
- Share screenshots from my phone into a Google Drive folder.
- Once a week, a GitHub Action runs a Go program that reads any new screenshots with Gemini.
- The Action opens a pull request with the results, so I can check the numbers before they go anywhere.
No public endpoint, no upload secret, no payload limits, and I still get to write Go.
Reading screenshots with Gemini
The Go program uses the official google.golang.org/genai SDK. The important part is asking for structured output: instead of hoping the model replies in the right shape, you give it a JSON schema and it has to fill it in.
resp, err := client.Models.GenerateContent(ctx, model, contents, &genai.GenerateContentConfig{
Temperature: genai.Ptr[float32](0),
ResponseMIMEType: "application/json",
ResponseSchema: responseSchema(),
})
Every metric in the schema is a nullable number with a description that names the card it comes from, like "The \"Muscles Arm, Left\" card". The prompt adds a few rules I learned the hard way by looking at real screenshots:
- Use
nullwhen a card shows “—”, or when the number is cut off by the edge of the screen. Never guess. - Copy numbers exactly as shown.
- Say what date is printed on the cards, and flag it if a screenshot shows more than one.
A schema guarantees the shape of the answer, not that the numbers are right. That’s what the pull request review is for.
One scan, lots of screenshots
My original design saved one JSON file per screenshot. Then I actually took the screenshots and realised one scan is spread across about seven overlapping screens, with some cards showing up on two of them.
So the program merges everything into one file per scan date. If two screenshots show the same card, the values have to agree. If they don’t, the program keeps the first one and flags the disagreement in the PR description. A value that’s half cut off at the bottom of one screenshot usually appears in full on the next, so the merge fills in the gaps.
The program also remembers every screenshot it has seen (by Drive file ID and by a SHA-256 hash of the image), so nothing gets sent to Gemini twice. That includes the random non-gym screenshot that ended up in the folder by mistake: it was marked “not a body scan” and skipped.
The weekly pull request
The workflow runs every Monday, just before the existing Health Connect sync. If there are new readings, it opens a PR with a table of every value, ready to check against the app on my phone. If I spot a misread number, I fix the JSON on the branch and merge.
A couple of small details turned out to matter:
- Don’t run while a PR is waiting. Otherwise the next run would re-read the same screenshots and overwrite any fixes I’d made on the branch.
- Don’t open a PR when nothing worked. My first real run failed on every screenshot (more on that below) and still opened a PR containing an empty file. Now the program only writes files when at least one screenshot was actually handled.
Things that went wrong
- An empty secret. The very first error was
JSONDecodeError: Expecting value. The service account key secret had never been added to the repo, and GitHub quietly passes a missing secret as an empty string. Both scripts now check for that and say so clearly. - A restricted API key. The Gemini key belonged to a Google Cloud project where the Gemini API wasn’t switched on, and the key itself was restricted to other APIs. Two different 403s, two different fixes in the Cloud console.
- Huge error messages. Google’s API errors repeat themselves and include pages of detail, which made the PR description unreadable. The program now keeps just the first sentence.
A private dashboard on a static site
With the data in the repo, I wanted somewhere to actually look at it: trend charts at the top, a table of every reading at the bottom. But this is health data, so it needed to be properly private, and my site is fully static.
A “hidden” URL isn’t private. On a static site every page is a file anyone can request if they know or guess the address, and the numbers would be sitting right there in the HTML. Leaving the page out of the sitemap and adding noindex keeps search engines away, but it doesn’t stop a person.
The fix was a Netlify Edge Function that runs before the page is served. Without a valid login cookie you get a password form, and the real page never leaves Netlify.
- The password is stored in a Netlify environment variable, never in the repo. If it isn’t set, the function refuses everyone.
- The session cookie is just an expiry time plus an HMAC signature made with the password. It can’t be forged without the password, and changing the password logs every device out.
- The cookie is
HttpOnly,Secure,SameSite=Strictand uses the__Host-prefix. - Wrong passwords wait about a second before replying, and the page is sent with
no-store,noindexand a strict Content Security Policy. - The function matches the path with a case-insensitive pattern that also covers the page’s
index.htmlfile, so changing the letter case or adding the file name doesn’t sneak past it.
I deployed the gate in front of a placeholder page first and tested the live site with every URL variation I could think of before any real data went up. That turned out to be worth it, because the first real login attempt failed with “Request blocked”.
The Origin: null bug
The login form checks that the request came from my own site by comparing the Origin header. It worked perfectly in my tests and failed in a real browser.
The reason: I’d also set Referrer-Policy: no-referrer on the login page. Under that policy, browsers send Origin: null on form posts, so my own form looked like it came from nowhere. My tests had set the Origin header by hand, so they never saw it.
The fix was to use Referrer-Policy: same-origin and fall back to the Sec-Fetch-Site header, which the browser sets and a page can’t change:
function sameOrigin(request: Request, url: URL): boolean {
const origin = request.headers.get("origin");
if (origin && origin !== "null") return origin === url.origin;
return request.headers.get("sec-fetch-site") === "same-origin";
}
Charts with no JavaScript
Like the rest of the site, the dashboard ships zero JavaScript. The trend charts are SVG generated at build time by an Astro component, the body-composition chart is a row of flexbox segments, and the left-vs-right comparison is plain HTML bars. Hovering a point shows its value through an SVG <title>, and every number is also in the table at the bottom, which covers phones and screen readers.
Tightening things up
Since this pipeline handles keys and personal data, I finished with a security pass over everything:
- Pin GitHub Actions to commit SHAs, not tags like
@v8. A tag can be moved to point at different code later, and these workflows have access to my secrets. - Pin Python packages to exact versions in a
requirements.txt. - Don’t leave the GitHub token in the checkout while the Go program runs, since it pulls in third-party libraries.
- Keep Drive access read-only, and make sure the Gemini key is on a paid project, so screenshots aren’t used to train models.
Wrapping up
My weekly routine is now: take screenshots after a scan, share them to a Drive folder, and merge a pull request on Monday. Everything else is automatic, and the data finally lives somewhere I can chart it.
The biggest lessons for me were less about Go or Gemini and more about the boring parts: read the docs before you pick a runtime, check what your data actually looks like before designing around it, and test security on the live site, not just in your tests. Oh, and I built this with the help of Claude Code, which was great for working through the Google Cloud and Netlify setup step by step.