Fawredd Gym is a mobile-first training log and AI coaching assistant. Users can record workouts, set a personal training objective, review their history, and generate a one-day workout recommendation informed by their recent activity.
The app keeps a compact, persistent training state so coaching requests can use a concise summary of a user's progress instead of repeatedly sending their entire workout history to the model. The application interface and AI-generated coaching content are currently in Spanish.
- Workout tracking: create, edit, and review workouts and their exercises.
- Natural-language import: describe one or more past workouts and have AI extract structured workout data for review and storage.
- Personal training objective: add or update a short objective that guides future coaching.
- AI-generated routines: generate a structured, one-day routine using the user's training objective (or profile goal when no objective is set), recent workouts, and current training state.
- Training memory: maintain a concise coaching summary covering priorities, progression focus, recovery, strategy, and next steps. It is refreshed when a workout is recorded or the training objective changes.
- Dashboard: review recent workout dates, training summaries, progress information, and the latest AI recommendation.
- Exercise catalog: normalize and classify exercises to support consistent workout history and muscle-group summaries.
- Authentication and access control: protect user-specific pages and data with Clerk.
- Progressive Web App support: includes a web app manifest and optional web push notifications.
The routine-generation endpoint assembles its prompt on the server from the user's current training objective (or profile goal when no objective is set), the latest persisted training state, and up to ten recent workouts. The training-state generator uses the objective, previous state, and recent workout history to produce a concise coaching summary. The app validates structured AI outputs before storing or returning them.
This state is a coaching-memory summary, not a replacement for the underlying workout records. The AI endpoints do not accept arbitrary database access; workout and objective data are loaded by the application server for the authenticated user.
- Next.js 16 with the App Router
- React 19 and TypeScript
- Tailwind CSS 4 and shadcn/ui
- Drizzle ORM with PostgreSQL (
@vercel/postgres) - Clerk authentication
- Vercel KV for idempotency and rate-limit data
- Vercel AI SDK with Google Gemini for routine generation, workout import, exercise classification, and training-state generation
- OpenRouter for the exercise reclassification maintenance script
- Web Push for optional browser notifications
- Node.js 20.9 or newer
- pnpm
- PostgreSQL 15 or a compatible PostgreSQL service
- Clerk application keys
- Google Generative AI API key
- Vercel KV / Upstash REST credentials for endpoints that use the KV client
Docker Compose is provided for local PostgreSQL and Redis services. The application uses the Vercel KV REST client (@vercel/kv); a plain Redis REDIS_URL by itself does not configure that client. Use Vercel KV or compatible Upstash REST credentials for the app's KV integration.
pnpm installCopy .env.example to .env.local and fill in the values for your environment. Do not commit .env.local or any other file containing secrets.
| Variable(s) | Purpose |
|---|---|
POSTGRES_URL |
PostgreSQL connection string used by Drizzle and database scripts. Include the schema=fawredd_gym query parameter. |
POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_PORT |
Credentials and port used by the Docker Compose PostgreSQL service. |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY, CLERK_SECRET_KEY |
Clerk authentication. |
GOOGLE_GENERATIVE_AI_API_KEY |
Gemini calls used by AI features. |
KV_REST_API_URL, KV_REST_API_TOKEN |
Vercel KV / Upstash REST credentials used by @vercel/kv. Set these in your local environment and deployment environment. |
OPENROUTER_API_KEY |
Used by the exercise reclassification script. |
NEXT_PUBLIC_APP_URL |
Optional canonical site URL; useful for local or custom-domain configuration. |
NEXT_PUBLIC_VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY |
Optional Web Push keys. Push notifications are disabled when valid keys are not configured. |
GOOGLE_SITE_VERIFICATION |
Optional Google Search Console verification token. |
For local development, a PostgreSQL URL can use this format:
POSTGRES_URL=postgres://fawredd:change_me@localhost:5432/fawredd_gym?schema=fawredd_gym
If you want to run the database and Redis through Docker Compose, also copy .env.example to .env and set the POSTGRES_* values in that file. Compose reads .env, while the database scripts prefer .env.local when both files exist.
With Docker Desktop running and .env configured:
docker compose up -d db redisThe PostgreSQL container initializes the fawredd_gym schema on first startup. The database initialization script can also create it explicitly:
pnpm db:initFor a new or updated local database, push the Drizzle schema:
pnpm db:pushThe project also provides pnpm db:generate, pnpm db:migrate, pnpm db:introspect, and pnpm db:studio for migration generation, applying migrations, schema introspection, and opening Drizzle Studio.
pnpm devOpen http://localhost:3000. Sign-in, AI features, and database-backed pages require valid credentials and services configured in the environment.
| Command | Description |
|---|---|
pnpm dev |
Start the Next.js development server. |
pnpm build |
Create a production build. |
pnpm start |
Serve the production build. |
pnpm lint |
Run ESLint. |
pnpm db:init |
Create the fawredd_gym PostgreSQL schema if it does not exist. |
pnpm db:push |
Push the Drizzle schema to the configured database. |
pnpm db:generate |
Generate Drizzle migrations. |
pnpm db:migrate |
Apply generated Drizzle migrations. |
pnpm db:studio |
Open Drizzle Studio. |
pnpm db:introspect |
Introspect the configured database. |
pnpm db:push-force |
Force-push the Drizzle schema; use with care. |
There is no pnpm test script configured in package.json at this time.
app/
api/ Route handlers for AI, objectives, workouts, and exercises
dashboard/ Authenticated dashboard
entrenamientos/ Workout creation, editing, and objective screens
components/
dashboard/ Dashboard UI
entrenamientos/ Workout UI
ui/ Shared UI primitives
db/
schema.ts Drizzle tables and relations
migrations/ Generated database migrations
lib/
schemas/ Input and AI-output validation schemas
training-state-utils.ts
workouts-utils.ts Workout persistence and AI context helpers
scripts/ Database and maintenance scripts
The app is designed to deploy on Vercel. Configure the production PostgreSQL connection, Clerk keys, Google Generative AI API key, and Vercel KV credentials in the Vercel project environment settings. Add Web Push keys and Google Search Console verification only if those features are enabled.
For SEO, the canonical origin uses the Vercel production project URL when available, falling back to the deployment URL. Set NEXT_PUBLIC_APP_URL only when you need to specify a custom canonical domain. After deployment, verify ownership in Google Search Console, submit https://your-domain/sitemap.xml, and request indexing as needed. Search rankings and sitelinks are determined by search engines and are not guaranteed.
- Create a branch for your change.
- Install dependencies with
pnpm install. - Configure the required environment variables and services.
- Run
pnpm lintandpnpm buildbefore opening a pull request. - Keep changes focused and avoid committing credentials or local environment files.