Skip to main content

Class Diagram

SmartWeights uses an MVVM architecture and the class diagrams reflect as such.

Architecture

The SmartWeights application is made with SwiftUI and the visual elements are made through its views. The elements within the views vary, but all are relevant to some graphical component. Some contain buttons, images, or components that we are creating that are not part of the SwiftUI library such as the WorkoutGraph or Calendar. The methods in the views represent any sort of user interaction with the view. The method itself calls to its respective ViewModel to handle the functionality. ViewModels handle logic such as changing which view to redirect to, or update the current view with new data relevant to their reliant variables. The models are the classes that hold the data elements these views rely on.

Additionally, there are classes to connect to external systems being CloudKit and the Raspberry Pi Pico. These classes establish the connection between the application and system and allow the transfer of data between the two. These classes are used in the relevant views where it would be needed. For example: The virtual pet page would require the CloudKit related classes, and the workout page would require the Raspberry Pi related classes.

Features of the SmartWeights App

The following class diagrams show the main sections that the user can interact with in the app and the logic that comes with it.

App

The SmartWeightsApp class acts as the entry point for the application. Pages in the app contain a NavBar component.

Login

The login page consists of a big image of a pet and the login button. The user would click on the login button which would then ask them to "Continue with Apple". This is done through Apple's OAuth services with Apple Login.

Virtual Pet

The pet page consists of an image of the pet, their stats (hp, exp, lvl) and whatever they have equipped (accessories or clothes). There are some interactive features for the user that involve the pet such as changing their appearance, feeding their pets, and buying things for their pets. There is an inventory button, shop button, and a customize button within a hamburger menu.

Challenges

The challenges page consists of a list of several achievements that can be unlocked through the user by various tasks completed. Once any challenge/achievement is completed, the user can then reap their rewards through a click of a button. The users could also view their own progress of certain challenges as well to see how much closer they are to completing it.

Pet Store

The pet store page consists of a bunch of items that can be bought with the user's hard-earned pet coins. With the pet coins, they can be achieved through rewards via challenges or completing workouts. Some of the items that can be bought within the pet store are things like food to restore hp for your pet, buy clothes/accessories to swag out your pet, new pets, and backgrounds.

Profile

The profile page consists of the user's profile pic, name, level, pet, and their achievements. The user can edit the showcase of their achievements, change their name, height, weight, and share their profile. Sharing their profile would create a new image that has the user's hard-earned accolades on display to show their friends.

Settings

The settings page allows users to customize their notifications

HomePage

The home page is where the user will usually go to or see first after they login successfully. There will be a video carousel of workout forms, there will be a tab to allow navigation through the app.

Workout

The workout page is where the user goes when they want to start working out or review their past feedback history. The user selects their workout and enters how many sets and reps they'll be doing in their desired workout. Once the user is ready to initiate their workout, they can either use a button or voice activation/recognition to start. While they are working out, after each set is completed the feedback will processed through an algorithm to detect whether their form is good or bad and the pet will give suggestions on how to fix their form. The data is received through sensors and raspberry pi's during the workout. There will also be graphs and past feedback histories that the user can access if they want to. The user should also be able to see the video carousel to have more insight on what correct form could look like.

External Logic

The external logic contains the classes that connect to external systems being CloudKit and the Raspberry Pi Pico W.

DB Management

The CloudKitManager class serves as the central manager for interacting with CloudKit. It provides methods for saving, fetching, and deleting records from the CloudKit databases. The other classes represent more specific uses for the DB and help facilitate the necessary parameters for the CloudKitManager to perform its operations.

Example Implementation

The Login view model will use the UserDB class in order to create a user with a successful login. The Virtual Pet view model will use the PetDB class to fetch the pet's health.

Bluetooth Low Energy Connector

This represents the class that is in the application that is used to connect to the Raspberry Pi Pico W. It establishes connections with multiple sensors and determines the central and peripheral systems. It contains an integer array of the data that is being received from the Picos.

Example Implementation

The Workout View Model requires the BLEManager class in order to get the data and use it.

Raspberry Pi Pico W

The Raspberry Pi Pico W has its own classes in order to function. The Pico W runs on a continuous loop, which is represented as main. The classes represent the logic and data for the sensors that are attached to the Pico for reading and writing data in order for the Pico to send to the application via Bluetooth Low Energy (BLE) IDK Which class is being used