An AI-powered fitness application that generates personalized workout plans using artificial intelligence. Built with Next.js 15, TypeScript, and MongoDB.
- Personalized Plans: Generate workouts tailored to your equipment, fitness level, and goals
- Cohere AI Integration: Advanced AI model for intelligent workout recommendations
- Real-time Generation: Instant workout plan creation with typing animation
- Multiple Prompts: Create and save multiple workout variations
- Google OAuth: Secure authentication with Google
- Profile Management: Complete user profiles with BMI calculation
- Progress Tracking: Monitor your fitness journey
- Workout History: Save and access previous workout plans
- Local Storage Caching: Persistent data across sessions
- Responsive Design: Works seamlessly on desktop and mobile
- Toast Notifications: Real-time feedback for user actions
- Loading States: Smooth user experience with loading indicators
- Daily Workouts: Detailed daily exercise routines
- Warm-up & Cool-down: Complete workout structure
- Diet Recommendations: AI-generated nutrition tips
- Progress Overview: Track days per week, duration, and focus areas
- Next.js 15: App Router with TypeScript
- React 19: Latest React features and hooks
- Tailwind CSS: Utility-first CSS framework
- Framer Motion: Smooth animations and transitions
- React Query: Server state management and caching
- React Hook Form: Form handling and validation
- Next.js API Routes: Serverless API endpoints
- MongoDB: NoSQL database with Mongoose ODM
- NextAuth.js: Authentication and session management
- Cohere AI: Advanced AI model for workout generation
@tanstack/react-query: Data fetching and cachingreact-hot-toast: Toast notificationstypewriter-effect: Typing animationsframer-motion: Animations and transitionsmongoose: MongoDB object modeling
workout/
├── app/ # Next.js App Router
│ ├── (pages)/ # Route groups
│ │ ├── about/ # About page
│ │ ├── createWorkout/ # AI workout generation
│ │ ├── dashboard/ # User dashboard
│ │ ├── login/ # Authentication
│ │ ├── myWorkout/ # Saved workouts
│ │ ├── settings/ # User settings
│ │ └── updateProfile/ # Profile management
│ ├── api/ # API routes
│ │ ├── auth/ # Authentication endpoints
│ │ ├── cohereAI/ # AI workout generation
│ │ ├── createWorkout/ # Workout management
│ │ ├── user/ # User management
│ │ └── workout/ # Workout data
│ ├── layout.tsx # Root layout
│ ├── page.tsx # Landing page
│ └── providers.tsx # React Query provider
├── components/ # Reusable components
│ ├── ui/ # UI components
│ │ ├── CreateWorkoutForm.tsx # Workout form
│ │ ├── Navigation.tsx # Side navigation
│ │ ├── Timer.tsx # Workout timer
│ │ └── ... # Other UI components
│ └── auth/ # Authentication components
├── hooks/ # Custom React hooks
│ ├── userHooks.ts # User data management
│ └── workoutHooks.ts # Workout data management
├── lib/ # Utility libraries
│ ├── auth.ts # NextAuth configuration
│ ├── db.ts # Database connection
│ └── performance.ts # Performance monitoring
├── schemas/ # Database schemas
│ ├── User.ts # User model
│ └── workout.ts # Workout model
├── types/ # TypeScript types
├── public/ # Static assets
└── middleware.js # Route protection
- Node.js 18+
- MongoDB database
- Google OAuth credentials
- Cohere AI API key
-
Clone the repository
git clone <repository-url> cd workout
-
Install dependencies
npm install
-
Environment Variables Create a
.env.localfile in the root directory:# Database MONGODB_URI=your_mongodb_connection_string # Authentication GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret NEXTAUTH_SECRET=your_nextauth_secret NEXTAUTH_URL=http://localhost:3000 # AI Integration COHERE_API_KEY=your_cohere_api_key
-
Run the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
The application uses MongoDB with Mongoose for data modeling. The main schema includes:
- User Profile: Personal information, BMI calculation
- Workout Plans: AI-generated exercise routines
- Diet Tips: Nutrition recommendations
- Progress Tracking: Fitness metrics and goals
- Google OAuth: Primary authentication method
- Session Management: NextAuth.js handles sessions
- Route Protection: Middleware protects private routes
- Cohere AI: Generates personalized workout plans
- Prompt Engineering: Structured prompts for consistent results
- Response Parsing: JSON parsing with error handling
- Hero section with animated features
- Feature cards highlighting AI capabilities
- Call-to-action for getting started
- User profile overview with BMI calculation
- Workout summary and progress tracking
- Fitness dashboard with clock and timer components
- AI-powered workout generation
- Real-time typing animation
- Local storage caching for persistence
- Toast notifications for user feedback
- Save functionality with state management
- Display saved workout plans
- Daily workout breakdowns
- Diet recommendations
- Animated sections with Framer Motion
- User profile management
- BMI calculation updates
- Personal information editing
GET/POST /api/auth/*- NextAuth.js authentication
GET /api/user- Get user profilePOST /api/user- Create new userPATCH /api/user- Update user profile
GET /api/workout- Get saved workoutPATCH /api/workout- Save workout planGET /api/createWorkout- Legacy workout endpointPATCH /api/createWorkout- Legacy save endpoint
POST /api/cohereAI- Generate workout with AI
- Navigation: Side navigation with user profile
- CreateWorkoutForm: AI workout generation form
- Timer/Clock: Fitness tracking components
- InfoRow/OverviewItem: Data display components
- Responsive Design: Mobile-first approach
- Dark/Light Theme: Consistent color scheme
- Animations: Smooth transitions and micro-interactions
- Loading States: User feedback during operations
- Authentication: Google OAuth with NextAuth.js
- Route Protection: Middleware for private routes
- Input Validation: Form validation and sanitization
- Error Handling: Comprehensive error management
- Database Indexing: Optimized MongoDB queries
- Connection Pooling: Efficient database connections
- React Query Caching: Client-side data caching
- Local Storage: Persistent client-side data
- Code Splitting: Automatic Next.js optimization
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint- TypeScript: Full type safety
- ESLint: Code linting and formatting
- Prettier: Code formatting
- React Query: Data fetching best practices
- Connect your GitHub repository
- Add environment variables
- Deploy automatically on push
- Netlify: Static site deployment
- Railway: Full-stack deployment
- DigitalOcean: App Platform deployment
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js Team: Amazing React framework
- Cohere AI: Powerful AI capabilities
- MongoDB: Robust database solution
- NextAuth.js: Secure authentication
- Tailwind CSS: Utility-first styling
For support, email [email protected] or create an issue in this repository.
Built with ❤️ using Next.js, TypeScript, and AI