Ever found yourself wanting to get fit but struggling with the trifecta of workout woes?
- Gym memberships cost more than your coffee addiction
- Planning workouts feels like rocket science
- Routine is the enemy of motivation
Well, fear not! I've created this incredible C# console app to solve all these problems and more. Welcome to the Workout Generator, where fitness meets innovation.
- Generates a "Workout of the Day" faster than you can say "I'll start on Monday"
- Emails your workout at 5am, because nothing says "good morning" like burpees
- Customisable exercises and workout schemas via a
data.jsonfile - Hosted on DigitalOcean's Droplets, because even apps need a good home
- The app wakes up at 5am, earlier than any of us want to
- It randomly selects a workout schema and exercises from
data.json - It crafts an email containing the workout plan
- The email arrives in your inbox, ready to inspire (or terrify) you when you wake up
These instructions assume that you have the necessary tools installed on your local Linux machine (git, dotnet SDK) and that you have a DigitalOcean account set up.
Remember to replace droplet_ip, [email protected], [email protected], smtp_port, smtp_address and from_email_password with your actual values.
(Note: I used Google so if you are too use smtp_address = smtp.gmail.com and smtp_port = 587)
-
Clone the repository:
git clone https://github.com/JordanRobo/Workout_Generator.git
-
Navigate to the cloned directory:
cd Workout_Generator -
Publish the application:
dotnet publish -c Release -r linux-x64 --self-contained
-
Create a deployment package:
mkdir -p deployment-package cp -r bin/Release/net8.0/linux-x64/publish/* deployment-package/
-
Create a new droplet on DigitalOcean through the web interface or using doctl.
-
SSH into your new droplet:
ssh root@droplet_ip
-
Update the system and install .NET runtime:
sudo apt update sudo apt install -y aspnetcore-runtime-8.0
-
Create a directory for your application:
mkdir -p /opt/workout-generator
-
Exit the droplet SSH session.
- From your local machine, transfer your application files to the droplet:
scp -r deployment-package/* root@your_droplet_ip:/opt/workout-generator/
-
SSH back into your droplet:
ssh root@your_droplet_ip
-
Set up environment variables (replace with your actual email credentials):
echo 'export EMAIL_TO_ADDRESS="[email protected]"' >> /root/.profile echo 'export SMTP_ADDRESS="smtp_address"' >> /root/.profile echo 'export SMTP_PORT="smtp_port"' >> /root/.profile echo 'export EMAIL_FROM_ADDRESS="[email protected]"' >> /root/.profile echo 'export EMAIL_FROM_PASSWORD="from_email_password"' >> /root/.profile source /root/.profile
-
Set the timezone (Replace
TIMEZONE/REGIONwith your desired region):sudo timedatectl set-timezone TIMEZONE/REGION
-
Set up a cron job to run your application daily at 5am:
(crontab -l 2>/dev/null; echo "0 5 * * * cd /opt/workout-generator && ./Workout_Generator") | crontab -
-
Verify the cron job:
crontab -l
-
Test run your application:
cd /opt/workout-generator ./Workout_Generator
-
To modify exercises, SSH into your droplet and edit the data file:
nano /opt/workout-generator/data.json
-
Remember to maintain proper JSON syntax when editing.
-
After making changes, you can manually run the application to test:
cd /opt/workout-generator && ./Workout_Generator
Tip: to make it easier to edit create a bash alias.
- Check application logs (if implemented) for any errors.
- Verify that the cron job is running by checking system logs:
grep CRON /var/log/syslog
- Ensure environment variables are set correctly in /root/.profile.
I'm just a guy who decided that if computers can solve complex algorithms, they can surely tell me how many push-ups to do. When I'm not coding, I'm probably thinking about coding, or doing a workout that this app told me to do.
Remember, the only bad workout is the one that didn't happen. So let this app be your digital fitness buddy, personal trainer, and morning alarm all rolled into one. Happy sweating!