Sequence Diagrams - bounswe/bounswe2024group12 GitHub Wiki

1. Logged in User Interactions

1.1 View Profile

sequenceDiagram
    actor U as User
    participant P as Profile
    participant DB as Database
    
    %view
    U->>P: viewProfile(user)
    P->>DB: Retrieve profile data
    alt Retrieve Successful
      DB-->>P: Return profile data
      P->>U: Display profile
    else Failure
      DB-->>P: Failure
      P-->>U: Failure
    end
Loading

1.2 Follow User

sequenceDiagram
    actor U as User
    participant P as Profile
    participant DB as Database

    %follow
    U->>P: followUser(user)
    P->>DB: Update followings
    alt Successful
      DB-->>P: Success
      P->>U: Success
    else Failure
      DB-->>P: Failure
      P-->>U: Failure
    end
Loading

1.3 Unfollow User

sequenceDiagram
    actor U as User
    participant P as Profile
    participant DB as Database

    %follow
    U->>P: unfollowUser(user)
    P->>DB: Update followings
    alt Successful
      DB-->>P: Success
      P->>U: Success
    else Failure
      DB-->>P: Failure
      P-->>U: Failure
    end
Loading

1.4 Block User

sequenceDiagram
    actor U as User
    participant P as Profile
    participant DB as Database

    %block
    U->>P: blockUser(user)
    P->>DB: Update block list
    alt Successful
      DB-->>P: Success
      P->>U: Success
    else Failure
      DB-->>P: Failure
      P-->>U: Failure
    end
Loading

1.5 Report User

sequenceDiagram
    actor U as User
    participant P as Profile
    participant DB as Database

    %report
    U->>P: reportUser(user, reason)
    P->>DB: Log report
    alt Successful
      DB-->>P: Success
      P->>U: Success
    else Failure
      DB-->>P: Failure
      P-->>U: Failure
    end
Loading

1.6 Select Favorite Game

sequenceDiagram
    actor U as User
    participant P as Profile
    participant DB as Database

    %select fav game
    U->>P: viewProfile()
    P->>DB: setFavoriteGame(index, game)
    alt Successful
      DB-->>P: Success
      P->>U: Success
    else Failure
      DB-->>P: Failure
      P-->>U: Failure
    end
Loading

1.7 Select Favorite Game Property

sequenceDiagram
    actor U as User
    participant P as Profile
    participant DB as Database

    %select fav property
    U->>P: viewProfile()
    P->>DB: setFavoriteGameProperty(gameProperty, value)
    alt Successful
      DB-->>P: Success
      P->>U: Success
    else Failure
      DB-->>P: Failure
      P-->>U: Failure
    end
Loading

1.8 Edit Profile Picture

sequenceDiagram
    actor U as User
    participant P as Profile
    participant DB as Database
   
    %edit profile picture
    U->>P: changeProfilePicture(picture)
    P->>DB: Update profile picture
    alt Successful
      DB-->>P: Success
      P->>U: Success
    else Failure
      DB-->>P: Failure
      P-->>U: Failure
    end
Loading

1.9 Log out

sequenceDiagram
    actor U as User
    participant P as Profile
   
    %logout
    U->>P: logOut()
    alt Successful
      P-->>U: Confirm logout
    else Failure
      P-->>U: Failure
    end
Loading

1.10 Change Password

sequenceDiagram
    actor U as User
    participant P as Profile
    participant DB as Database

    %change password
    U->>P: changePassword(password)
    P->>DB: Update password
    alt Successful
      DB-->>P: Successful
      P-->>U: Successful
    else Failure
      DB-->>P: Failure
      P-->>U: Failure
    end
    
Loading

1.11 Delete Account

sequenceDiagram
    actor U as User
    participant P as Profile
    participant DB as Database

    %delete account
    U->>P: deleteAccount()
    P->>DB: Remove account data
    alt Successful
      DB-->>P: Successful
      P-->>U: Successful
    else Failure
      DB-->>P: Failure
      P-->>U: Failure
    end
Loading

2. Guest User Interactions

2.1 Register

sequenceDiagram
    actor G as Guest User
    participant S as System
    participant DB as Database

    %register
    G->>S: register(username, email, password)
    S->>DB: Save new user
    alt Successful
      DB-->>S: User saved
      S-->>G: Successful
    else Failure
      DB-->>S: Failure
      S-->>G: Failure
    end
    
Loading

2.2 Login

sequenceDiagram
    actor G as Guest User
    participant S as System
    participant DB as Database

    %login
    G->>S: login(username, password)
    S->>DB: Validate user credentials
    alt Valid
      DB-->>S: Credentials valid
      S->>G: Login successful
    else Unvalid
      DB-->>S: Credentials unvalid
      S-->>G: Failure
    end
    
Loading

2.3 Forget Password

sequenceDiagram
    actor G as Guest User
    participant S as System
    participant DB as Database
    participant E as Email System

    %forget password
    G->>S: resetPassword(email)
    S->>E: Send password reset email
    E->>G: Password reset email
    G->>E: Click reset link
    E->>S: Prompt reset password
    S->>DB: Update password
    alt Successful
      DB->>S: Password updated
      S-->>G: Password reset successful
    else Failure
      DB-->>S: Failure
      S-->>G: Failure
    end
    
Loading

3. Logged In Review Interactions

3.1 Give Review

sequenceDiagram
    actor Registered User
    Registered User->>+Game: createReview(game, rating, text)
    Game->>+ Database: add review to the Game's review list
    alt Addition Succesfull
        Database-->>Game: success
        Game-->>Registered User: success
    else 
        Database-->>-Game: failure
        Game-->>-Registered User: failure
    end
Loading

3.2 Delete Review

sequenceDiagram
    actor Registered User
    Registered User->>+Game: deleteReview(review)
    Game->>+ Database: delete review from the Game's review list
    alt Deletion Succesfull
        Database-->>Game: success
        Game-->>Registered User: Your review has been deleted succesfully
    else 
        Database-->>-Game: failure
        Game-->>-Registered User: An error occured while deleting your review!
    end
Loading

3.3 View Review

sequenceDiagram
    actor Registered User
    Registered User->>+Game: getReview(game, reviewId)
    Game->>+ Database: show the review from the Game's review list
    alt Viewing Succesfull
        Database-->>Game: review
        Game-->>Registered User: review
    else 
        Database-->>-Game: failure
        Game-->>-Registered User: An error occured while fetching the review!
    end
Loading

3.4 Filter Reviews by Rating

sequenceDiagram
    actor Registered User
    Registered User->>+Game: filterReviews(game, upperLimit, lowerLimit)
    Game->>+ Database: show the reviews from the Game's review list
    alt Fetching Reviews Succesfull
        Database-->>Game: reviewList
        Game-->>Registered User: reviewList
    else 
        Database-->>-Game: failure
        Game-->>-Registered User: An error occured while fetching the review list!
    end
Loading

4. Logged In Game Interactions

4.1. View Game

sequenceDiagram
    actor Registered User
    Registered User->>+System: getGame(gameId)
    System->>+ Database: get the details of the Game
    alt Fetching Succesfull
        Database-->>System: game
        System-->>Registered User: game
    else 
        Database-->>-System: failure
        System-->>-Registered User: An error occured while fetching the game details!
    end
Loading

4.2 Like a Game

sequenceDiagram
    actor Registered User
    Registered User->>+System: likeGame(gameId)
    System->>+ Database: add the Game to the likedGames list
    alt Like Succesfull
        Database-->>System: success
        System-->>Registered User: Success!
    else 
        Database-->>-System: failure
        System-->>-Registered User: An error occured while liking the game!
    end
Loading

4.3 Unlike a Game

sequenceDiagram
    actor Registered User
    Registered User->>+System: unlikeGame(gameId)
    System->>+ Database: remove the Game from the likedGames list
    alt Unlike Succesfull
        Database-->>System: success
        System-->>Registered User: Success!
    else 
        Database-->>-System: failure
        System-->>-Registered User: An error occured while unliking the game!
    end
Loading

4.4 Add Game to A List

sequenceDiagram
    actor Registered User
    Registered User->>+System: addGameToList(listId, gameId)
    System->>+ Database: add the game to the game list
    alt Fetching Succesfull
        Database-->>System: success
        System-->>Registered User: Success!
    else 
        Database-->>-System: failure
        System-->>-Registered User: An error occured while adding the game to the list!
    end
Loading

4.5 Remove Game from A List

sequenceDiagram
    actor Registered User
    Registered User->>+System: removeGameFromList(listId, gameId)
    System->>+ Database: remove the game from the game list
    alt Fetching Succesfull
        Database-->>System: success
        System-->>Registered User: Success!
    else 
        Database-->>-System: failure
        System-->>-Registered User: An error occured while removing the game from the list!
    end
Loading

5. View Main Page

sequenceDiagram
    participant Main_Page
    participant Game_Service
    participant Review_Service
    participant Friend_Service
    participant User_Service

    Main_Page ->> Game_Service: +gameOfTheDay(): Game
    Game_Service -->> Main_Page: Game

    Main_Page ->> Game_Service: +popularGames(): List<Game>
    Game_Service -->> Main_Page: List<Game>

    Main_Page ->> Game_Service: +newGames(): List<Game>
    Game_Service -->> Main_Page: List<Game>

    Main_Page ->> Review_Service: +recentReviews(): List<Review>
    Review_Service -->> Main_Page: List<Review>

    Main_Page ->> Friend_Service: +friendReviews(user: RegisteredUser): List<Review>
    Friend_Service -->> Main_Page: List<Review>

    Main_Page ->> Game_Service: +moreGames(): List<Game>
    Game_Service -->> Main_Page: List<Game>
Loading

6. Search

sequenceDiagram
    participant User
    participant Server
    User ->> Server: search(category, term)
    Server ->> Server: Validate category and term
    alt category is GAME
        Server ->> Server: Search for games matching term
        Server -->> User: Return search results
    else category is REVIEW
        Server ->> Server: Search for reviews matching term
        Server -->> User: Return search results
    else category is LIST
        Server ->> Server: Search for lists matching term
        Server -->> User: Return search results
    else category is USER
        Server ->> Server: Search for users matching term
        Server -->> User: Return search results
    end
Loading

7. Admin

7.1 Delete User

sequenceDiagram
    participant Admin
    participant Server
    Admin ->> Server: deleteUser(user)
    Server ->> Server: Validate admin privileges
    Server ->> Server: Delete user account
    alt Success
        Server -->> Admin: User deleted successfully
    else Failure
        Server -->> Admin: Failed to delete user
    end
Loading

7.2 Delete Review

sequenceDiagram
    participant Admin
    participant Server
    Admin ->> Server: deleteReview(review)
    Server ->> Server: Validate admin privileges
    Server ->> Server: Delete review
    alt Success
        Server -->> Admin: Review deleted successfully
    else Failure
        Server -->> Admin: Failed to delete review
    end
Loading

7.3 Delete List

sequenceDiagram
    participant Admin
    participant Server
    Admin ->> Server: deleteList(list)
    Server ->> Server: Validate admin privileges
    Server ->> Server: Delete list
    alt Success
        Server -->> Admin: List deleted successfully
    else Failure
        Server -->> Admin: Failed to delete list
    end
Loading

7.4 Edit Public List's Title

sequenceDiagram
    participant Admin
    participant Server
    Admin ->> Server: editPublicListTitle(list, newTitle)
    Server ->> Server: Validate admin privileges
    Server ->> Server: Edit public list title
    alt Success
        Server -->> Admin: List title edited successfully
    else Failure
        Server -->> Admin: Failed to edit list title
    end
Loading

7.5 Edit Public List's Description

sequenceDiagram
    participant Admin
    participant Server
    Admin ->> Server: editPublicListDescription(list, newDescription)
    Server ->> Server: Validate admin privileges
    Server ->> Server: Edit public list description
    alt Success
        Server -->> Admin: List description edited successfully
    else Failure
        Server -->> Admin: Failed to edit list description
    end
Loading

7.6 Change Public List to Private

sequenceDiagram
    participant Admin
    participant Server
    Admin ->> Server: changePublicListToPrivate(list)
    Server ->> Server: Validate admin privileges
    Server ->> Server: Change public list to private
    alt Success
        Server -->> Admin: List changed to private successfully
    else Failure
        Server -->> Admin: Failed to change list to private
    end
Loading

7.7 Edit Review

sequenceDiagram
    participant Admin
    participant Server
    Admin ->> Server: editReviewText(review, newText)
    Server ->> Server: Validate admin privileges
    Server ->> Server: Edit review text
    alt Success
        Server -->> Admin: Review text edited successfully
    else Failure
        Server -->> Admin: Failed to edit review text
    end
Loading

7.7 Change Profile Picture

sequenceDiagram
    participant Admin
    participant Server
    Admin ->> Server: changeProfilePicture(user, picture)
    Server ->> Server: Validate admin privileges
    Server ->> Server: Change user's profile picture
    alt Success
        Server -->> Admin: Profile picture changed successfully
    else Failure
        Server -->> Admin: Failed to change profile picture
    end
Loading

7.8 Ban User

sequenceDiagram
    participant Admin
    participant Server
    Admin ->> Server: banUser(user, period)
    Server ->> Server: Validate admin privileges
    Server ->> Server: Ban user for specified period
    alt Success
        Server -->> Admin: User banned successfully
    else Failure
        Server -->> Admin: Failed to ban user
    end
Loading
⚠️ **GitHub.com Fallback** ⚠️