Skip to content

Sequence Diagrams: Fitness and Diet Forum

Bilge Kaan Güneyli edited this page Oct 16, 2024 · 29 revisions

Creation Actions

Create a Post

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
Loading

Create a Diet Program Meal

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
Loading

Create an Exercise Program

sequenceDiagram
  actor User
  participant UserInterface
  participant Database

  User->>+UserInterface: createExercise(exercises)
  UserInterface->>Database: meal(username, exercises)

  alt Success
    Database-->>UserInterface: Success.
    UserInterface-->>User: <successMessage>
  else Failure
    Database-->>UserInterface: <ERR_CODE>
    UserInterface-->>User: <ERR_CODE, errorMessage>
  end
Loading

Create Food

!!! not finished yet !!!

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
      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
    end
  end

Loading

Deletion Actions

Delete a Post

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

Loading

Delete a Exercise Program

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


Loading

Delete a Diet Program

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


Loading

Delete a Comment

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

Loading

User Interactions

View Profiles

Follow or Unfollow Other Users

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
Loading

Post Interactions

Like or Unlike a Post

    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
Loading

Bookmark or Remove Bookmark from a Post

    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

Loading

Create a Comment

    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

Loading

Account

View Own Profile

    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
Loading

Edit Email Address

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
Loading

Edit Profile Picture

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
Loading

Edit Bio

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
Loading

Edit Password

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
Loading

Searching

Clone this wiki locally