A modern, full-stack workout tracking application built with cutting-edge technologies including Next.js 16, React 19, Prisma ORM, PostgreSQL, and TanStack Query. Track your workouts, build custom routines, monitor personal records, and achieve your fitness goals with real-time workout execution and comprehensive analytics.
Workout Again is a personalized workout tracking app that provides a complete fitness management solution. Originally started as a BetterAuth practice project, it has evolved into a production-ready application with enterprise-grade authentication, real-time workout tracking, and powerful analytics.
- Custom Workout Routines - Create and organize personalized workout plans with multiple exercises
- Exercise Library - Browse and search exercises by category, muscle group, and equipment
- Real-Time Tracking - Execute workouts with live timers, rest periods, and set logging
- Superset Support - Group exercises together for efficient circuit training
- Public Sharing - Share workout templates with images via SEO-friendly URLs
- Workout History - Complete log of all finished workouts with detailed stats
- Personal Records - Automatic PR tracking using the Epley 1RM formula
- Volume Metrics - Track total sets, reps, weight lifted, and workout duration
- Weekly Activity - Monitor consistency and training frequency
- Workout Summaries - Detailed post-workout analytics and insights
- Email/Password Auth - Secure authentication with Better Auth
- OAuth Integration - Google and GitHub sign-in support
- Two-Factor Authentication - TOTP-based 2FA with backup codes
- Email Verification - Resend-powered verification flow
- Session Management - Secure HTTP-only cookies with auto-expiry
- Email Enumeration Protection - Privacy-focused security measures
- Dark Mode - Full theme support (light/dark/system)
- Responsive Design - Mobile-first UI with Tailwind CSS
- Beautiful Components - shadcn/ui with Radix UI primitives
- Smooth Animations - Framer Motion for polished interactions
- Type-Safe - Full TypeScript coverage with runtime validation
- Server Actions - Next.js 16 server-side mutations
- TanStack Query - Optimistic updates and intelligent caching
- Prisma ORM - Type-safe database queries with PostgreSQL
- Docker Support - Containerized development environment
- CI/CD Pipeline - GitHub Actions for automated testing and deployment
- Framework: Next.js 16.0.10 (App Router)
- UI Library: React 19.2.1
- Language: TypeScript 5.x (strict mode)
- Styling: Tailwind CSS 4.x
- Components: shadcn/ui (Radix UI)
- Icons: Lucide React 0.561.0
- Animations: Framer Motion 12.23.26
- Theme: next-themes (dark/light/system)
- Database: PostgreSQL 15 (Docker)
- ORM: Prisma 5.22.0
- Authentication: Better Auth 1.4.7
- Email Service: Resend 6.6.0
- Validation: Zod 4.1.13
- File Storage: AWS S3 (presigned URLs)
- Data Fetching: TanStack Query 5.90.12
- Dev Tools: TanStack Query DevTools 5.91.1
- Password Hashing: bcryptjs
- CSRF Protection: Built-in (Better Auth)
- Input Validation: Zod schemas
- Session Security: HTTP-only cookies
- Containerization: Docker & Docker Compose
- CI/CD: GitHub Actions
- Linting: ESLint 9
- Dependencies: Dependabot
- Node.js 20+ (LTS recommended)
- PostgreSQL 15+ (or Docker)
- pnpm/npm Package manager
- Resend API Key (for email verification)
- AWS S3 (optional, for public workout images)
git clone https://github.com/Reese408/WorkoutApp-3.git
cd appnpm install
# or
pnpm installcp .env.example .envConfigure the following in .env:
# Database
DATABASE_URL="postgresql://user:password@localhost:5434/workout_db"
# Better Auth
BETTER_AUTH_SECRET="your-random-secret-key-32-chars-min"
BETTER_AUTH_URL="http://localhost:3000"
# Email (Resend)
RESEND_API_KEY="re_xxxxxxxxxxxx"
# OAuth Providers (Optional)
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
# AWS S3 (Optional - for public workout images)
AWS_REGION="us-east-1"
AWS_ACCESS_KEY_ID="your-access-key"
AWS_SECRET_ACCESS_KEY="your-secret-key"
AWS_S3_BUCKET_NAME="your-bucket-name"docker-compose up -d postgresnpx prisma generate
npx prisma migrate dev
npx prisma db seed # Optional: seed with sample exercisesnpm run devOpen http://localhost:3000 in your browser.
BetterAuth_Practice/
βββ app/
β βββ actions/ # Server actions
β β βββ auth.ts # Authentication actions
β β βββ exercises.ts # Exercise CRUD
β β βββ routines.ts # Routine management
β β βββ workouts.ts # Workout logging & stats
β β βββ twoFactor.ts # 2FA management
β βββ dashboard/ # Protected dashboard
β βββ exercises/ # Exercise library pages
β βββ routines/ # Workout routine pages
β β βββ [id]/
β β βββ execute/ # Real-time workout tracking
β β βββ summary/ # Post-workout summary
β βββ workouts/ # Workout history & public workouts
β βββ profile/ # User profile management
β βββ signin/ # Authentication pages
β βββ signup/
β βββ verify-email/
βββ components/
β βββ ui/ # shadcn/ui components
β βββ workouts/ # Workout CRUD components
β βββ workoutViewer/ # Workout execution UI (timers, loggers)
β βββ exercises/ # Exercise components
β βββ header/ # Navigation
β βββ profile/ # Profile components
β βββ security/ # 2FA components
βββ hooks/
β βββ use-exercises.ts # Exercise data fetching
β βββ use-routines.ts # Routine data fetching
β βββ use-workouts.ts # Workout logging hooks
βββ lib/
β βββ auth.ts # Better Auth configuration
β βββ s3.ts # AWS S3 utilities
β βββ types.ts # TypeScript types
β βββ validations/ # Zod validation schemas
β βββ utils.ts # Utility functions
βββ prisma/
β βββ schema.prisma # Database schema
β βββ migrations/ # Database migrations
β βββ seed.ts # Database seeding
βββ .github/
β βββ workflows/ # GitHub Actions CI/CD
β βββ ISSUE_TEMPLATE/ # Issue templates
β βββ dependabot.yml # Automated dependency updates
βββ docker-compose.yml # Docker services
βββ proxy.ts # Route protection middleware
- User - User accounts with 2FA support
- Account - OAuth/credential provider accounts
- Session - Active user sessions with auto-expiry
- Verification - Email verification tokens
- TwoFactor - 2FA secrets and backup codes
- TwoFactorVerification - Temporary 2FA verification codes
- Exercise - Exercise library (name, category, muscle groups, equipment, instructions, media)
- WorkoutRoutine - User-created workout plans
- WorkoutExercise - Junction table linking exercises to routines (sets, reps, rest)
- WorkoutProgram - Multi-week training programs
- ProgramRoutine - Schedules routines within programs
- WorkoutLog - Individual workout sessions
- SetLog - Logged sets during workouts (weight, reps, duration)
- PersonalRecord - Best lifts per exercise (Epley 1RM)
- PublicWorkout - Shareable workout templates with images
- Cascade deletes for user ownership
- Optimistic concurrency control
- Comprehensive indexes for performance
- Type-safe queries with Prisma
This application implements enterprise-grade security:
- Input Validation - Zod schemas prevent XSS, SQL injection, and DoS attacks
- Email Enumeration Protection - Generic error messages prevent user discovery
- Password Hashing - bcrypt via Better Auth
- CSRF Protection - Built into Better Auth
- Secure Session Management - HTTP-only cookies with SameSite
- Two-Factor Authentication - TOTP with backup codes
- OAuth Security - Account linking with dangerous mode controls
- Rate Limiting - Email verification and authentication throttling
- Type Safety - Runtime validation with Zod + compile-time with TypeScript
See SECURITY_IMPROVEMENTS.md and EMAIL_ENUMERATION_PROTECTION.md for detailed documentation.
# Development
npm run dev # Start dev server (localhost:3000)
# Build
npm run build # Build for production
npm run start # Start production server
# Linting & Type Checking
npm run lint # Run ESLint
npx tsc --noEmit # Type check without emitting
# Database
npx prisma generate # Generate Prisma Client
npx prisma migrate dev # Run migrations
npx prisma db seed # Seed database with sample data
npx prisma studio # Open Prisma Studio (GUI)
# Docker
docker-compose up -d # Start all services
docker-compose down # Stop all services
docker-compose logs -f # View logsThis project includes a comprehensive CI/CD pipeline that runs on every push and pull request:
CI Pipeline (.github/workflows/ci.yml):
- Lint & Type Check - ESLint and TypeScript validation
- Prisma Schema Check - Validates database schema and migrations
- Build - Ensures the Next.js app builds successfully
- Security Audit - Checks for npm package vulnerabilities
# Lint
npm run lint
# Type check
npx tsc --noEmit
# Validate Prisma schema
npx prisma validate
# Build
npm run build
# Security audit
npm auditThis project uses shadcn/ui components. Add new components:
npx shadcn@latest add <component-name>
# Examples:
npx shadcn@latest add card
npx shadcn@latest add dialog
npx shadcn@latest add toastConfiguration: components.json
- Style: "new-york"
- CSS variables: enabled
- Icon library: Lucide
Ensure these are set in your production environment:
| Variable | Required | Description |
|---|---|---|
DATABASE_URL |
β | PostgreSQL connection string |
BETTER_AUTH_SECRET |
β | 32+ character random string |
BETTER_AUTH_URL |
β | Your production URL |
RESEND_API_KEY |
β | Resend API key for emails |
GOOGLE_CLIENT_ID |
β | Google OAuth (optional) |
GOOGLE_CLIENT_SECRET |
β | Google OAuth secret (optional) |
GITHUB_CLIENT_ID |
β | GitHub OAuth (optional) |
GITHUB_CLIENT_SECRET |
β | GitHub OAuth secret (optional) |
AWS_REGION |
β | S3 region (optional) |
AWS_ACCESS_KEY_ID |
β | S3 access key (optional) |
AWS_SECRET_ACCESS_KEY |
β | S3 secret key (optional) |
AWS_S3_BUCKET_NAME |
β | S3 bucket name (optional) |
- Set all required environment variables
- Run database migrations:
npx prisma migrate deploy - Configure OAuth redirect URIs (if using)
- Set up Resend domain verification
- Configure AWS S3 CORS (if using public workouts)
- Test email verification flow
- Enable 2FA for admin accounts
- Real-time workout execution
- Personal record tracking
- Public workout sharing
- Two-factor authentication
- SECURITY_IMPROVEMENTS.md - Security vulnerability fixes and best practices
- EMAIL_ENUMERATION_PROTECTION.md - Email enumeration attack prevention
- Better Auth Docs - Authentication library documentation
- Prisma Docs - ORM documentation
- TanStack Query Docs - Data fetching documentation
Framework & Runtime:
- Next.js 16.0.10
- React 19.2.1
- TypeScript 5.x
Backend:
- Prisma 5.22.0
- Better Auth 1.4.7
- PostgreSQL 15+
- Resend 6.6.0
- AWS SDK 3.954.0
Frontend:
- Tailwind CSS 4.x
- shadcn/ui
- Radix UI
- Lucide React 0.561.0
- Framer Motion 12.23.26
- next-themes
State & Data:
- TanStack Query 5.90.12
- Zod 4.1.13
- Better Auth - Modern authentication for TypeScript
- shadcn/ui - Beautifully designed components
- Prisma - Next-generation Node.js and TypeScript ORM
- TanStack Query - Powerful data synchronization
- Vercel - Next.js creators and hosting platform