Skip to content

Architecture

browser / CLI / AI assistants / future apps
│ @gymgym/sdk (generated from schema.graphql + operations/*.graphql)
▼
gymgym.club, app.gymgym.club ── one Cloudflare Worker (apps/web/src/worker.ts)
├── gymgym.club the landing page; app links hand off to app.gymgym.club (src/site.ts)
├── /api/auth/* Better Auth (Hono)
├── /api/graphql GraphQL Yoga + Pothos
├── /api/agent/* the Coach: an answer streamed as server-sent events (and rejoined, or stopped), voice to text
├── /api/media/* photos (custom exercises, photos sent to the Coach), to their owner only
├── /mcp the remote MCP server for AI assistants, with OAuth discovery under /.well-known
└── everything else Astro pages, the React app at /app
│
├── D1 users, routines, workouts, weigh-ins, conversations (Drizzle)
├── R2 photos, stripped of their metadata
├── Durable Objects RestTimer, one per user; AgentTurn, one per Coach conversation (the answer is made there, so it outlives the page)
├── Cron workout reminders and the Coach's check-ins, via Web Push
└── OpenRouter the Coach's model, and speech to text for voice messages

Pages and API share one origin per host. This keeps cookies and passkeys simple. The landing page and the app are on sibling hosts, and they share the sign-in cookie on the parent domain (COOKIE_DOMAIN). A single-host instance serves the landing page at / and the app at /app.

The landing page at / speaks the visitor’s language. Each of the 17 languages also has its own address (/de/, /pt-BR/ and so on). The pages link to each other with hreflang, and /sitemap.xml lists them, so search engines can index each language. / is their x-default.

Package Role
packages/domain Pure training logic: progression, one-rep max, effort, PRs, muscle volume, scheduling, routine names and importers. It does no I/O, so every client can reuse it.
packages/catalog The exercise library: 5,632 exercises, with names and steps in 17 languages.
packages/db The Drizzle schema and the D1 migrations, including the owner guard triggers.
packages/api The Hono app, the Better Auth setup, the GraphQL schema and resolvers, the coach (src/agent), the MCP server, push, cron, and the RestTimer and AgentTurn Durable Objects.
packages/sdk schema.graphql, the operation documents, the generated client, and the actions and documents that the CLI, the MCP server and the coach share.
packages/ui The shared components. The app and the design screens in design/ both render them.
apps/web The Astro site and the React app.
apps/docs This site.
apps/cli The gymgym command-line tool. It uses only the SDK. See the CLI reference.
  1. The resolvers and their descriptions live in packages/api/src/graphql.
  2. pnpm contract prints packages/sdk/schema.graphql and runs graphql-codegen over packages/sdk/operations/*.graphql.
  3. The generated client has a method for each operation. The web app imports only the SDK.
  4. The GraphQL and SDK pages of this site come from the same schema and operation files.

The MCP server and the coach act as the signed-in person through the same SDK, called in the same process. Their tools reach the data in the same way as the app, with the same row rules.

Swift and Kotlin clients can generate code from the same schema.graphql and operation documents with Apollo. This keeps watch and mobile apps on the same contract.

We design the screens first in stitch2, in design/. DESIGN.md holds the colors, the type levels and the rules. The tokens of the app are generated from it. Each screen has versions, and the app implements the approved version. The design screens and the app render the same components in packages/ui, so they cannot drift.