Skip to content
SJ
All projects

Private

Groundwork

AI strength coach that adjusts the next set from your reported reps in reserve, and keeps the model out of the logging path.

TypeScript / NestJS / Next.js / Flutter / PostgreSQL / Llama 3 on Bedrock


Why the next set is decided by arithmetic

Groundwork is a mobile-first AI strength coach, installable as a PWA, that adjusts the next set from the reps in reserve the athlete reports and says why in a sentence they can argue with. That decision happens between two sets on gym wifi and has to answer in one round trip, the same way every time, so it is deterministic arithmetic: 3 or more in reserve raises the load a step unless the athlete is in a calorie deficit, 2 changes nothing, 1 stops progression for the session, and 0 drops the load a step and cuts a set.

How one API keeps the database and model keys

One NestJS API owns the schema, the model and the mailer. The athlete app and the back office are separate Next.js apps that call it, the landing page is a static Next.js site, and a Flutter client ports the same screens, so no process but the API holds a database URL or a Bedrock key. The athlete app proxies API calls through its own origin, which keeps the session cookie first-party.

How the code works within Llama 3 70B's limits

The coach runs on Llama 3 70B on Amazon Bedrock, which has a hard 2048-token output ceiling, an 8192-token context window and no tool use. Plan generation makes one call for an outline and then one per training day. JSON is prompted with a schema, extracted, validated with Zod and given one repair attempt, and plan numbers are clamped again on storage. The coach never edits training on its own: every plan change is staged as a proposal with its reasoning and applied by a tap.

How the chat and the model routes are guarded

The guardrails sit in a dependency-free module, so a check script can assert every rule without a key or server. Athlete free text is fenced before it enters the system prompt, standing rules are re-sent every turn, refused output is never written to the history, and all four model routes are rate-limited and serialised per account. Plain statements of self-harm or disordered eating get a fixed referral with no model call. An eval suite sends every case to the model, and the cases this model fails are documented rather than left to be rediscovered.

Services this project shows

Start a project

Describe what you are building and where it is stuck. Rough notes are fine.