Skip to content

Sequence Diagrams

Oğuz Kağnıcı edited this page Dec 20, 2024 · 8 revisions

Post

Create

sequenceDiagram
  actor User
  participant PostController
  participant Database

  User->>PostController: createPost(title, content, category, challenged_post)
  PostController->>Database: savePost(user_id, title, content, category, challenged_post)
  alt Success
    Database-->>PostController: <OK>
    PostController-->>User: Post created successfully.
  else Failure
    Database-->>PostController: <ERROR>
    PostController-->>User: <ERR_CODE, errorMessage>
  end

Loading

Delete

sequenceDiagram
  actor User
  participant PostController
  participant Database

  User ->>PostController: deletePost(post_id)
  PostController->>Database: deletePost(post_id)
  alt Success
   Database-->>PostController: <OK>
   PostController-->>User: Post deleted successfully.
  else Failure
   Database-->>PostController: <ERROR>
  PostController-->>User: <ERR_CODE, errorMessage>
  end
Loading

View

sequenceDiagram
  actor User
  participant PostController
  participant Database

  User ->>PostController: viewPost(post_id)
  PostController->>Database: getPostDetails(post_id)
  
  alt Success
    Database-->>PostController: <OK, content, post_type, comments>
    
    alt Text-Only Post
      PostController-->>User: displayContent(content)
      PostController-->>User: displayComments(comments)
    else Visual Post
      PostController-->>User: displayContent(content)
      PostController-->>User: displayComments(comments)
      PostController-->>User: display3DModelViewer(model_file)
    end
    
  else Failure
    Database-->>PostController: <ERROR>
    PostController-->>User: <ERR_CODE, errorMessage>
  end
Loading

Like

sequenceDiagram
  actor User
  participant PostController
  participant Database

  User ->>PostController: likePost(post_id, value)
  PostController->>Database: likePost(user_id, post_id, value)
  alt Success
   Database-->>PostController: <OK, post_likes>
   PostController-->>User: displayPostLikes(post_id)
  else Failure
   Database-->>PostController: <ERROR>
   PostController-->>User: <ERR_CODE, errorMessage>
  end
Loading

Bookmark

sequenceDiagram
  actor User
  participant PostController
  participant Database

  User ->>PostController: bookmarkPost(post_id)
  PostController->>Database: bookmarkPost(user_id, post_id)
  alt Success
   Database-->>PostController: <OK>
   PostController-->>User: Bookmark added successfully.
  else Failure
   Database-->>PostController: <ERROR>
   PostController-->>User: <ERR_CODE, errorMessage>
  end

Loading

Comment

Create

sequenceDiagram
  actor User
  participant PostController
  participant Database

  User->>PostController: createComment(post_id, content)
  PostController->>Database: saveComment(user_id, post_id, content)
  alt Success
    Database-->>PostController: <OK>
    PostController-->>User: Comment created successfully.
  else Failure
    Database-->>PostController: <ERROR>
    PostController-->>User: <ERR_CODE, errorMessage>
  end
Loading

Delete

sequenceDiagram
  actor User
  participant CommentController
  participant Database

  User->>CommentController: deleteComment(post_id, comment_id)
  CommentController->>Database: deleteComment(post_id, comment_id)
  alt Success
    Database-->>CommentController: <OK>
    CommentController-->>User: Comment deleted successfully.
  else Failure
    Database-->>CommentController: <ERROR>
    CommentController-->>User: <ERR_CODE, errorMessage>
  end
Loading

Like

sequenceDiagram
  actor User
  participant CommentController
  participant Database

  User ->>CommentController: likeComment(post_id, comment_id, value)
  CommentController->>Database: likeComment(user_id, post_id, comment_id, value)
  alt Success
   Database-->>CommentController: <OK, comment_likes>
   CommentController-->>User: displayCommentLikes(post_id, comment_id)
  else Failure
   Database-->>CommentController: <ERROR>
   CommentController-->>User: <ERR_CODE, errorMessage>
  end
 
Loading

Feed

View Following

sequenceDiagram
  actor User
  participant PostController
  participant FeedController
  participant Database

  User ->>PostController: viewFollowing(user_id)
  PostController->>FeedController: fetchFollowing(user_id)
  FeedController->>Database: fetchFollowing(user_id)
  alt Success
   Database-->>FeedController: <OK, following>
   FeedController-->>PostController: <following>
   PostController-->>User: displayFollowingFeed(following)
  else Failure
   Database-->>FeedController: <ERROR>
   FeedController-->>PostController: <ERR_CODE>
   PostController-->>User: <ERR_CODE, errorMessage>
  end
 
Loading

Category

Follow

sequenceDiagram
  actor User
  participant CategoryController
  participant Database

  User ->>CategoryController: follow(category)
  CategoryController->>Database: follow(user_id,category)
  alt Success
   Database-->>CategoryController: <OK>
   CategoryController-->>User: Followed category successfully.
  else Failure
   Database-->>CategoryController: <ERROR>
   CategoryController-->>User: <ERR_CODE, errorMessage>
  end
Loading

Unfollow

sequenceDiagram
  actor User
  participant CategoryController
  participant Database

  User ->>CategoryController: unfollow(category)
  CategoryController->>Database: unfollow(user_id,category)
  alt Success
   Database-->>CategoryController: <OK>
   CategoryController-->>User: Unfollowed category successfully.
  else Failure
   Database-->>CategoryController: <ERROR>
   CategoryController-->>User: <ERR_CODE, errorMessage>
  end
Loading

View Gallery

sequenceDiagram
  actor User
  participant PostController
  participant CategoryController
  participant Database

  User ->>PostController: viewGallery(category)
  PostController->>CategoryController: fetchGallery(category)
  CategoryController->>Database: fetchGallery(category)
  alt Success
   Database-->>CategoryController: <OK, gallery>
   CategoryController-->>PostController: <gallery>
   PostController-->>User: displayGallery(gallery)
  else Failure
   Database-->>CategoryController: <ERROR>
   CategoryController-->>PostController: <ERR_CODE>
   PostController-->>User: <ERR_CODE, errorMessage>
  end
 
Loading

View Discussions

sequenceDiagram
  actor User
  participant PostController
  participant CategoryController
  participant Database

  User ->>PostController: viewDiscussions(category)
  PostController->>CategoryController: fetchDiscussions(category)
  CategoryController->>Database: fetchDiscussions(category)
  alt Success
   Database-->>CategoryController: <OK, discussions>
   CategoryController-->>PostController: <discussions>
   PostController-->>User: displayDiscussions(discussions)
  else Failure
   Database-->>CategoryController: <ERROR>
   CategoryController-->>PostController: <ERR_CODE>
   PostController-->>User: <ERR_CODE, errorMessage>
  end
 
Loading

User Interactions

View User

sequenceDiagram
  actor User
  participant UserController
  participant Database

  User ->>UserController: viewProfile(user_id)
  UserController->>Database: fetchProfile(user_id)
  alt Success
   Database-->>UserController: <OK, details, posts, comments>
   UserController-->>User: displayProfile(details, posts, comments)
  else Failure
   Database-->>UserController: <ERROR>
   UserController-->>User: <ERR_CODE, errorMessage>
  end
 
Loading

Follow User

sequenceDiagram
  actor User
  participant UserController
  participant Database

  User ->>UserController: followUser(user_id, value)
  UserController->>Database: followUser(user_id, value)
  alt Success
   Database-->>UserController: <OK, follower_count>
   UserController-->>User: displayFollowers(follower_count)
  else Failure
   Database-->>UserController: <ERROR>
   UserController-->>User: <ERR_CODE, errorMessage>
  end
 
Loading

Account

View Own Profile

sequenceDiagram
  actor User
  participant UserController
  participant Database

  User ->>UserController: viewOwnProfile(user_id)
  UserController->>Database: fetchOwnProfile(user_id)
  alt Success
   Database-->>UserController: <OK, details, posts, comments>
   UserController-->>User: displayProfile(details, posts, comments)
  else Failure
   Database-->>UserController: <ERROR>
   UserController-->>User: <ERR_CODE, errorMessage>
  end
 
Loading

Edit Profile

sequenceDiagram
  actor User
  participant UserController
  participant Database

  User ->>UserController: updateAttribute(user_id, attribute)
  UserController->>Database: updateAttribute(user_id, attribute)
  alt Success
   Database-->>UserController: <OK, attribute>
   UserController-->>User: displayAttribute(attribute)
  else Failure
   Database-->>UserController: <ERROR>
   UserController-->>User: <ERR_CODE, errorMessage>
  end
 
Loading

Search

sequenceDiagram
    participant User
    participant PostController
    participant WikidataAPI
    participant Database
    

    User->>PostController: search(query)
    PostController->>WikidataAPI: fetchKeywords(query)

    alt Keywords
     WikidataAPI-->>Database: searchDatabase(query, keywords)
    else No Keywords
     WikidataAPI-->>Database: searchDatabase(query)
    end
   
    alt Success
     Database-->>PostController: <OK, results>
     PostController-->>User: displayResults(results)
    else Failure
     Database-->>PostController: <ERROR>
     PostController-->>User: <ERR_CODE, message>
    end

Loading

Tournament

Trigger

sequenceDiagram
    participant TournamentController
    participant CategoryController
    participant Database
    participant PostController
    participant UserProfileController

    TournamentController ->> CategoryController: startWeeklyTournament(category_id)
    CategoryController ->> Database: getPosts(category_id, week)
    Database -->> CategoryController: <OK, post_list_with_likes>
    
    CategoryController ->> PostController: findMostLikedPost(post_list)
    PostController -->> CategoryController: <OK, most_liked_post>
    
    CategoryController ->> TournamentController: declareWinner(most_liked_post)
    TournamentController ->> UserProfileController: awardPoints(user_id, points)
    UserProfileController ->> Database: updateUserPoints(user_id, points)
    Database -->> UserProfileController: <OK>
    TournamentController -->> UserProfileController: displayPointsOnProfile(user_id)

Loading

Enter

sequenceDiagram
  actor User
  participant PostController
  participant Database
  participant TournamentController

  User ->> PostController: createPost(title, content, category, tournament_entry)
  PostController ->> TournamentController: checkTournamentStatus(category)

  alt Tournament Active
    TournamentController -->> PostController: <tournament_active>
    PostController ->> TournamentController: savePost(user_id, title, content, category, tournament_entry)
    alt Success
      Database -->> PostController: <OK>
      PostController -->> User: Post created and entered into tournament successfully.
    else Failure
      Database -->> PostController: <ERROR>
      PostController -->> User: <ERR_CODE, errorMessage>
    end
  else Tournament Not Active
    TournamentController -->> PostController: <no_tournament>
    PostController ->> TournamentController: savePost(user_id, title, content, category)
    alt Success
      Database -->> PostController: <OK>
      PostController -->> User: Post created but no active tournament.
    else Failure
      Database -->> PostController: <ERROR>
      PostController -->> User: <ERR_CODE, errorMessage>
    end
  end



Loading

Prepared By Oğuz Kağnıcı, Improved and Reviewed By Deniz Ulaş Poyraz

🏠Home

Final Milestone Project Artifacts

🛠️Project

🔍Labs

📁Assignments

📝Meeting Notes

👥Team Members

📄Templates

⚽️352 Material

352 Material

🛠️Project

🔍Research

📁Assignments

📝Meeting Notes

👥Team Members

📄Templates

Clone this wiki locally