Fitness-Tracker-Program
Overview
Using python and tkinter we plan on making a fitness tracker program. With a clean UI login capabilites along with knowledge on fitness and exercise workouts. We both enjoy working out at not just the school gym but at home and at a boxing gym. We are passionate about this project because we did not have muhc guidance when beggining our own fitness journey and want to help others. We both think fitness is an important aspect in anyone life no matter their skill level.
This app will allow the user to add workouts to their personal database to allow for easier tracking of their progress of the gym. Its perfect for those who want to take their fitness journey to the next level and really get into keeping themselves healthy.
Build and Run Instructions
Testing
This code base uses pytest pulling from different funcitons meant for logging in tracking workouts and BMI
In order to run pytest:
Call pytest in the main directory "Fitness-Tracker-Program"
Requirements:
- Python 3.6+ (with tkinter, pytest,pillow and json libraries)
Structure/Design
Structure:
Fitness-Tracker-Program/
├──src/
│ └──my_package/
│ ├── main.py # Entry point (screen switching)
│ ├── vars.py # global variables + session data
│ ├── Backend/
│ │ ├── UserInfo.json # Json file for user data
│ │ └── Utils.py # Login, workout, stats and timing logic
│ └── Frontend/
│ ├── Images/
│ ├── theme.py # Red & black theme + shared widgets
│ ├── LoginUI.py # Screen 1
│ ├── createAccount.py# Screen 2
│ ├── HomeScreen.py # Screen 3
│ ├── TrackWorkout.py # Screen 4 (with threaded rest timer)
│ ├── History.py # Screen 5
│ ├── BMICalculator.py# Screen 6
│ └── Settings.py # Screen 7
Design:
Exectuing main will start the user from the login screen and from there the entire app is availible. For testing or indiviual viewing each file can be run independently of each other. Global variables are kept in a seperate vars file so that each screen and the main file can access them and can edit them during runtime.
Every screen is built from the shared theme.py (red & black palette, buttons, inputs, cards). Layouts stretch with the window, stay centred on wide windows and scroll when the window is too short. The rest timer counts down on a background thread and passes each second back to tkinter through a queue, since tkinter widgets can only be changed from the main thread.
Current Limitaitons
- Passwords are stored as plain text in
UserInfo.json - Data is saved on Exit, Log Out or closing the window - if the program crashes the current session is lost
Git to Run
In bash run:
git clone https://github.com/xkoch7/Fitness-Tracker-Program.git
cd Fitness-Tracker-Program
Then in terminal run:
pip install -r requirements.txt
Finally run:
python src/my_package/main.py
Zip to Run
Download
Fitness-Tracker.zipas a raw folderExtract all files into a file named 'Fitness-Tracker'
Run the following command in terminal to install all prerequisites:
pip install -r requirements.txt
- Inside the relative path
.../Fitness-Tracker-Program/src/my_package/main.pyrun:
python -m main
Run with Docker
Run in command line:
docker build fitnessprogram .
then run,
docker run fitnessprogram
Bottlenecks and preformance
The biggest bottlenecks / slowest functions are on start up where it can vary and take up to .5 seconds (this is likely because of all of the tkinter processes initializing) Where as most functions take > 0.002 seconds on average per call being less than 10% of runtime
Benchmarking
In order to test our functions runtimes we used wrappers from functools with time.perf_counter() these results get put into log.txt to view and will be sorted in a future update
Optimization and Integration
After reviewing our biggest bottleneck / slowest function we came up with a plan to optimize speed and imrpove our benchmark. In order to do this we took a look at how each function serparatley opens a json file to make changes. In order to make the code faster we decided to make a tempory dictinary of all the info in the json files. Then have the functions change that tempory dictionary so we are not always reopening a json file reducing the amount of calls yo the json file and making the code faster.
New Benchmark
After appyling this new optimization out benchmark signifgantly decreased our average start up time from a average of 0.5 seconds to an average of 0.2 seconds a run.
Refelction
During this project we learned multiple different techniques and programs used to make a program. For example Docker, Tkinter, Py testing and continuous integration. We had our struggles with each of these programs however getting past those helped us learn even more. In the future we can add demo's for the exercises to make our UX design look better and use databases instead of JSON files.
Built With
- dockerfile
- python
Log in or sign up for Devpost to join the conversation.