Sequence Diagrams: Fitness and Diet Forum - bounswe/bounswe2024group4 GitHub Wiki
sequenceDiagram
actor User
participant UserInterface
participant Database
User->>+UserInterface: createPost(content)
UserInterface->>Database: post(username, content)
alt Success
Database-->>UserInterface: Success.
UserInterface-->>User: <successMessage>
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
User->>+UserInterface: createMeal(foods)
UserInterface->>Database: meal(username, foods)
alt Success
Database-->>UserInterface: Success.
UserInterface-->>User: <successMessage>
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
participant ExercisesAPI
User->>+UserInterface: getExercises(muscles)
UserInterface->>Database: getExercises(muscles)
alt Success
Database->>UserInterface: <OK, results>
UserInterface->>User: <results>
else Failure
Database->>UserInterface: <ERR_CODE>
UserInterface->>User: <ERR_CODE, errorMessage>
end
UserInterface->>ExercisesAPI: getExercises(muscles)
alt Success
ExercisesAPI->>UserInterface: <OK, exercises>
UserInterface->>User: <exercises>
else Failure
ExercisesAPI->>UserInterface: <ERR_CODE>
UserInterface->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
User->>+UserInterface: createExercise(exercises)
UserInterface->>Database: exercise(username, exercises)
alt Success
Database-->>UserInterface: Success.
UserInterface-->>User: <successMessage>
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
participant WikidataAPI
participant Edamam Nutrition API
User->>+UserInterface: createFood(foodName)
UserInterface->>+Database: getFood(foodName)
alt Failure
Database-->>UserInterface: <ERR_CODE, errorMessage>.
UserInterface->>WikidataAPI: requestFood(foodName)
alt Failure
WikidataAPI-->>UserInterface: <ERR_CODE, foodNotFoundMessage>
UserInterface-->>User: <ERR_CODE, foodNotFoundMessage>
User->>UserInterface: uploadFoodPhoto(foodName, image)
UserInterface->>Database: uploadFoodPhoto(foodName, image)
alt Failure
Database-->>UserInterface: <ERR_CODE, errorMessage>
UserInterface-->>User: <errorMessage>
else Success
Database-->>UserInterface: <successMessage>
UserInterface-->>User: <successMessage>
end
else Success
WikidataAPI-->>UserInterface: <foodName, image>
UserInterface-->>User: <foodName, image>
UserInterface->>Database: saveFoodPhoto(foodName, image)
alt Failure
Database-->>UserInterface: <ERR_CODE, errorMessage>
UserInterface-->>User: <errorMessage>
else Success
Database-->>UserInterface: <successMessage>
UserInterface-->>User: <successMessage>
end
end
UserInterface->>Edamam Nutrition API: requestFood(foodName)
alt Failure
Edamam Nutrition API-->>UserInterface: <ERR_CODE, foodNotFoundMessage>
UserInterface-->>User: <ERR_CODE, foodNotFoundMessage>
User->>UserInterface: uploadFoodInfo(foodName, recipeLink, ingredients, nutritionInfo)
UserInterface->>Database: uploadFoodInfo(foodName, recipeLink, ingredients, nutritionInfo)
alt Failure
Database-->>UserInterface: <ERR_CODE, errorMessage>
UserInterface-->>User: <errorMessage>
else Success
Database-->>UserInterface: <successMessage>
UserInterface-->>User: <successMessage>
end
else Success
Edamam Nutrition API-->>UserInterface: <foodName, recipeLink, ingredients, nutritionInfo>
UserInterface-->>User: <foodName, recipeLink, ingredients, nutritionInfo>
UserInterface->>Database: saveFoodInfo(foodName, recipeLink, ingredients, nutritionInfo)
alt Failure
Database-->>UserInterface: <ERR_CODE, errorMessage>
UserInterface-->>User: <errorMessage>
else Success
Database-->>UserInterface: <successMessage>
UserInterface-->>User: <successMessage>
end
end
end
sequenceDiagram
actor User
participant UserInterface
participant Database
User->>+UserInterface: createExercise(exerciseInfo)
UserInterface->>Database: write(exerciseInfo)
alt Success
Database->>UserInterface: <OK>
UserInterface->>User: <successMessage>
else Failure
Database->>UserInterface: <ERR_CODE>
UserInterface->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
User->>+UserInterface: deletePost(postID)
UserInterface->>Database: deletePost(username, postID)
alt Success
Database-->>UserInterface: Post deleted successfully.
UserInterface-->>User: <successMessage>
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
User->>+UserInterface: deleteExerciseProgram(exerciseProgramID)
UserInterface->>Database: deleteExerciseProgram(username, exerciseProgramID)
alt Success
Database-->>UserInterface: Exercise program deleted successfully.
UserInterface-->>User: <successMessage>
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
User->>+UserInterface: deleteDietProgram(dietProgramID)
UserInterface->>Database: deleteDietProgram(username, dietProgramID)
alt Success
Database-->>UserInterface: Diet program deleted successfully.
UserInterface-->>User: <successMessage>
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
User->>+UserInterface: deleteComment(postID, commentID)
UserInterface->>Database: deleteComment(username, postID, commentID)
alt Success
Database-->>UserInterface: Comment deleted successfully.
UserInterface-->>User: <successMessage>
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
User->>+UserInterface: viewPost(post_id)
UserInterface->>+Database: fetchPost(post_id)
alt Post Exists
Database-->>UserInterface: post
UserInterface->>Database: fetchComments(post_id)
alt Comments Exist
Database-->>UserInterface: comments
UserInterface-->>User: displayPostWithComments(post, comments)
else No Comments
Database-->>UserInterface: <OK, []>
UserInterface-->>User: displayPostWithNoComments(post)
end
else Post Does Not Exist
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: displayErrorMessage(ERR_CODE, errorMessage)
end
sequenceDiagram
actor User
User->>+FeedController: viewFollowingFeed(username)
FeedController->>+Database: getFollowingFeed(username)
alt Feed Exists
Database-->>FeedController: followingFeed
FeedController-->>User: displayFollowingFeed(followingFeed)
else Feed Not Found
Database-->>FeedController: <ERR_CODE>
FeedController-->>User: displayErrorMessage(ERR_CODE, "Error retrieving following feed")
end
sequenceDiagram
actor User
User->>+UserInterface: viewProfile(profileUsername)
UserInterface->>Database: fetchUserProfile(profileUsername)
alt Profile Exists
Database-->>UserInterface: profileData
UserInterface->>Database: fetchUserPosts(profileUsername)
Database-->>UserInterface: posts
UserInterface->>Database: fetchFollowerCount(profileUsername)
Database-->>UserInterface: followerCount
UserInterface->>Database: fetchFollowedCount(profileUsername)
Database-->>UserInterface: followedCount
UserInterface->>Database: fetchExercisePrograms(profileUsername)
Database-->>UserInterface: exercisePrograms
UserInterface->>Database: fetchDietPrograms(profileUsername)
Database-->>UserInterface: dietPrograms
UserInterface-->>User: displayProfile(profileData, posts, followerCount, followedCount, exercisePrograms, dietPrograms)
else Profile Not Found
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: displayErrorMessage(ERR_CODE, errorMessage)
end
sequenceDiagram
actor User
User->>+UserInterface: followUnfollowUser(username)
UserInterface->>+ Database: followUnfollowUser(username)
alt Success
Database-->>UserInterface: <OK, follower_count>
UserInterface-->> User: updateFollowers(username, updated_follower_count)
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->> User: displayErrorMessage(ERR_CODE, errorMessage)
end
sequenceDiagram
actor User
participant Platform
participant Post
participant Database
User->>Platform: Log in
Platform->>Post: Retrieve post details
User->>Platform: Click 'Like' or 'Unlike'
alt Post is liked
Platform->>Post: Add like
Post->>Database: Update post with new like count
Platform->>User: Show updated like count
else Post is unliked
Platform->>Post: Remove like
Post->>Database: Update post with new like count
Platform->>User: Show updated like count
end
sequenceDiagram
actor User
participant Platform
participant BookmarkService
participant Database
User->>Platform: Log in
Platform->>BookmarkService: Retrieve post details
User->>Platform: Click 'Bookmark' or 'Remove Bookmark'
alt Post is bookmarked
Platform->>BookmarkService: Add post to bookmarks
BookmarkService->>Database: Update user's bookmark list
Platform->>User: Confirm post added to bookmarks
else Post is unbookmarked
Platform->>BookmarkService: Remove post from bookmarks
BookmarkService->>Database: Update user's bookmark list
Platform->>User: Confirm post removed from bookmarks
end
sequenceDiagram
actor User
participant Platform
participant CommentService
participant Database
User->>Platform: Log in
Platform->>Post: Retrieve post details
User->>Platform: Enter comment text
User->>Platform: Click 'Submit Comment'
Platform->>CommentService: Validate and store comment
CommentService->>Database: Save comment and associate with post
Database->>Platform: Confirm comment saved
Platform->>User: Show comment under post
sequenceDiagram
actor U as User
U->>+UserInterface: getProfile(username)
UserInterface->>+Database: getUsername(username)
UserInterface->>Database: getEmailAddress(username)
UserInterface->>Database: getProfilePicture(username)
UserInterface->>Database: getBio(username)
UserInterface->>Database: getFollowerCount(username)
UserInterface->>Database: getFollowedCount(username)
UserInterface->>Database: getFollowers(username)
UserInterface->>Database: getFollowedUsers(username)
UserInterface->>Database: getPosts(username)
alt Success
Database-->>UserInterface: <OK, data>
UserInterface-->>U: displayProfile(data)
else Error
Database-->>UserInterface: <ERR_CODE, data>
UserInterface-->> U: displayProfileWithErr(ERR_CODE, data)
end
sequenceDiagram
actor U as User
U->>+UserInterface: changeEmailAddress(username, newEmailAddress)
alt email address is valid
UserInterface->>Database: setEmailAddress(username, newEmailAddress)
alt Success
Database-->>UserInterface: <OK>
UserInterface-->>U: <OK, successMessage>
else Error
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>U: <ERR_CODE, "failed to update email address">
end
else email address is invalid
UserInterface-->>U: <ERR_CODE, "invalid email address format">
end
sequenceDiagram
actor U as User
U->>+UserInterface: changeProfilePicture(username, newProfilePicture)
alt profile picture is valid
UserInterface->>Database: setProfilePicture(username, newProfilePicture)
alt Success
Database-->>UserInterface: <OK>
UserInterface-->>U: <OK, successMessage>
else Error
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>U: <ERR_CODE, "failed to update profile picture">
end
else profile picture is invalid
UserInterface-->>U: <ERR_CODE, "invalid profile picture format">
end
sequenceDiagram
actor U as User
U->>+UserInterface: changeBio(username, newBio)
alt bio is valid
UserInterface->>Database: setBio(username, newBio)
alt Success
Database-->>UserInterface: <OK>
UserInterface-->>U: <OK, successMessage>
else Error
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>U: <ERR_CODE, "failed to update bio">
end
else bio is invalid
UserInterface-->>U: <ERR_CODE, "invalid bio format">
end
sequenceDiagram
actor U as User
U->>+UserInterface: changePassword(username, newPassword)
alt password is valid
UserInterface->>Database: setPassword(username, newPassword)
alt Success
Database-->>UserInterface: <OK>
UserInterface-->>U: <OK, successMessage>
else Error
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>U: <ERR_CODE, "failed to change password">
end
else password is invalid
UserInterface-->>U: <ERR_CODE, "invalid password format">
end
sequenceDiagram
actor User
participant UserInterface
participant Database
User->>+UserInterface: search(query)
UserInterface->>Database: search(query)
alt Success
Database-->>UserInterface: <OK, results>
UserInterface-->>User: <results>
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
participant Filter
User->>+UserInterface: search(query, filters)
UserInterface->>Database: search(query)
UserInterface->>Filter: apply(filters)
alt Success
Database->>Filter:filter(resuls)
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
alt Success
Filter-->>UserInterface: <OK, results>
UserInterface-->>User:<results>
else Failure
Filter-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
participant NutritionAPI
User->>+UserInterface: createMeal(foods)
UserInterface->>Database: meal(username, foods)
alt Success
Database-->>UserInterface: Success.
UserInterface->>NutritionAPI: nutritional_values(foods)
alt Success
NutritionAPI-->>UserInterface: Success
UserInterface-->>User: <successMessage>
else Failure
NutritionAPI-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
else Failure
Database-->>UserInterface: <ERR_CODE>
UserInterface-->>User: <ERR_CODE, errorMessage>
end
sequenceDiagram
actor User
participant UserInterface
participant Database
participant ExercisesAPI
User->>+UserInterface: createExercise()
UserInterface->>ExercisesAPI: getExercises(muscles)
alt Success
ExercisesAPI->>UserInterface: <OK, exercise_lists>
UserInterface->>User: <successMessage>
else Failure
ExercisesAPI->>UserInterface: <ERR_CODE>
UserInterface->>User: <ERR_CODE, errorMessage>
end