Skip to content

451 ‐ Design Diagrams

ceylin edited this page Oct 15, 2024 · 24 revisions

Class Diagram

1.1

classDiagram
    class User {
        -user_id: int
        -username: string
        -email: string
        -password: string
        -posts: Post[]
        -comments: Comment[]
        -bookmarks: Bookmark[]
        -profile: Profile

        +view_post_details(int post_id): Post
        +comment(int post_id, string text, string code): Comment
        +run_snippet(string code): string
        +viewProfile(): Profile
        +editProfile(Profile): bool
        +deleteAccount(): bool
    }

    class Post {
        -post_id: int
        -post_title: string
        -post_details: string
        -post_code_snippet: string
        -labels: string[]
        -comments: Comment[]
        
        +run_snippet(string code): string
        +add_comment(Comment): void
    }

    class Comment {
        -comment_id: int
        -post_id: int
        -user_id: int
        -text: string
        -code_snippet: string

        +editComment(string newText, string newCode): bool
    }

    class CodeExecutionApi {
        +run_snippet(string code): string
    }

    class SearchQuery {
        +queryText: string
        +filters: FilterOptions
        +executeSearch(): SearchResult[]
    }

    class FilterOptions {
        +dateRange: DateRange
        +languages: string[]
        +tags: string[]
        +applyFilters(): void
    }

    class ProgrammingLanguage {
        +languageName: string
        +languageDesigner: sring
        +languageFoundaionDate: string
        +languageImage:Image
        +languageDescription: string
        +getSimilars(languageName : string) : List[string]
    }

    class DateRange {
        +startDate: Date
        +endDate: Date
    }

    class UserController {
        +signUp(string name, string email, string password): bool
        +logIn(string email, string password): Session
        +logOut(Session): bool
        +viewProfile(User): Profile
        +editProfile(User, Profile): bool
        +deleteAccount(User): bool
        +viewQuestions(User): Post[]
        +viewComments(User): Comment[]
        +viewBookmarks(User): Bookmark[]
        +editQuestion(User, Question): bool
        +deleteQuestion(User, Question): bool
        +editComment(User, Comment): bool
        +deleteComment(User, Comment): bool
        +unbookmark(User, Post): bool
        +updateName(User, string name): bool
        +updatePassword(User, string password): bool
        +updateProfilePicture(User, Image): bool
    }

    class PrivateDatabase {
        +checkIfEmailExists(string email): bool
        +saveUser(User): bool
        +checkUser(string email, string password): bool
        +createSession(User): Session
        +invalidateSession(Session): bool
        +fetchProfileData(User): Profile
        +getQuestions(User): Post[]
        +getComments(User): Comment[]
        +getBookmarks(User): Bookmark[]
        +editQuestion(User, Question): bool
        +deleteQuestion(User, Question): bool
        +editComment(User, Comment): bool
        +deleteComment(User, Comment): bool
        +deleteBookmark(User, Post): bool
        +updateName(User, string name): bool
        +updatePassword(User, string password): bool
        +updateProfilePicture(User, Image): bool
        +deleteUser(User): bool
    }

    class Session {
        -session_id: int
        -user_id: int
        -startTime: DateTime
        -endTime: DateTime

        +isValid(): bool
    }

    class Profile {
        -profile_id: int
        -user_id: int
        -profile_picture: Image
        -bio: string
        -additional_info: string

        +updateProfilePicture(Image): bool
        +removeProfilePicture(): bool
        +updateBio(string bio): bool
    }

    class Bookmark {
        -bookmark_id: int
        -user_id: int
        -post_id: int

        +addBookmark(Post): bool
        +removeBookmark(Post): bool
    }

    class Image {
        -image_id: int
        -url: string
        -metadata: string

        +uploadImage(string path): bool
        +deleteImage(): bool
    }

    User --> Post : views/posts/comments
    User --> SearchQuery : initiates
    SearchQuery --> Post : returns
    SearchQuery --> ProgrammingLanguage : returns
    ProgrammingLanguage --> ProgrammingLanguage : related to
    Post --> CodeExecutionApi : runs snippet
    Post --> Comment : contains comments
    User --> Profile : has
    User --> Bookmark : bookmarks
    User --> Session : has
    UserController --> PrivateDatabase : interacts with
    UserController --> User : manages
    UserController --> Session : manages
    PrivateDatabase --> User : stores
    PrivateDatabase --> Post : stores
    PrivateDatabase --> Comment : stores
    PrivateDatabase --> Profile : stores
    PrivateDatabase --> Bookmark : stores
    PrivateDatabase --> Session : stores
    Profile --> Image : has
    Bookmark --> Post : references

Loading

Use Case Diagrams

2.1 Post Details & Code Execution

by Kristina, Serhan

  flowchart 
  User --> ViewPost;
  ViewPost-->ExecuteCodeSnippet;
  ViewPost-->Comment;
  ViewPost-->Report
  Comment-. includes .-> AddCommentDescription;
  Comment-. extends .-> AddCodeSnippet;
  ViewPost-->Upvote/Downvote
  
Loading

2.2 Post Creation

_by Damla

    flowchart 
 User --> CreatePost;
 CreatePost-. includes .->AddTitle;
 CreatePost-. includes .->AddBody;
 CreatePost-. includes .->SpecifyLanguage;
 CreatePost-. includes .->SpecifyLabel;
 CreatePost-->Comment
 AddBody-->AddCodeSnippet
Loading

2.3 Browsing Programming Languages

by Eray

flowchart
    User --> SearchLanguages
    User --> FilterLanguages
    User --> ViewQuestionsAboutLanguage

    SearchLanguages --> Browser
    Browser --> GetWordsFromAPI
    Browser --> GetLanguageDetails

    GetWordsFromAPI --> WikidataAPI
    GetLanguageDetails --> WikidataAPI

    ViewQuestionsAboutLanguage --> LanguageController
    LanguageController --> ShowLanguageDetails
    LanguageController --> ShowRelatedPosts

    ShowLanguageDetails --> WikidataAPI
    ShowRelatedPosts --> WikidataAPI

    FilterLanguages --> LanguageController
    FilterLanguages -.-> |extend| ViewQuestionsAboutLanguage

    LanguageController --> FilteredPosts
Loading

2.4 Profile

by Emin

flowchart
    subgraph Viewing Actions
        User --> SeeProfilePicture["View Profile Picture"]
        User --> ListQuestions["View Questions"]
        User --> ListComments["View Comments"]
        User --> ListBookmarks["View Bookmarks"]
    end
    
    subgraph Editing Actions
        User --> EditProfileInfo["Edit Profile Information"]
        EditProfileInfo --> EditName["Edit Name"]
        EditProfileInfo --> EditPassword["Edit Password"]
        EditProfileInfo --> EditProfilePicture["Edit Profile Picture"]
        EditProfilePicture --> RemovePicture["Remove Profile Picture"]

        EditName -."extend".-> EditProfileInfo
        EditPassword -."extend".-> EditProfileInfo
        RemovePicture -."extend".-> EditProfilePicture
    end

    subgraph Content Management
        ListQuestions --> EditQuestions["Edit Questions"]
        ListQuestions --> DeleteQuestions["Delete Questions"]

        ListComments --> EditComments["Edit Comments"]
        ListComments --> DeleteComments["Delete Comments"]

        ListBookmarks --> Unbookmark["Unbookmark"]

        EditQuestions -."extend".-> ListQuestions
        DeleteQuestions -."extend".-> ListQuestions

        EditComments -."extend".-> ListComments
        DeleteComments -."extend".-> ListComments
        Unbookmark -."extend".-> ListBookmarks
    end

    User --> DeleteAccount["Delete Account"]
    DeleteAccount --> ConfirmDeletion["Confirm Account Deletion?"]
    ConfirmDeletion --> AccountDeleted["Account Deleted"]
Loading

2.5 Signup, Login, Logout

by Emin

flowchart
    User["Guest User"] --> SignUp["Sign Up"]
    SignUp --> CheckEmail["Is Email Registered?"]
    
    CheckEmail -- Yes --> SignUpFailed["Sign-Up Failed: Email already registered"] --> User
    CheckEmail -- No --> SaveUser["Save User"] --> SignUpSuccess["Sign-Up Successful"] --> RegisteredUser["Registered User"]

    User --> Login["Log In"]
    Login --> CheckCredentials["Are Credentials Valid?"]
    
    CheckCredentials -- No --> LoginFailed["Login Failed: Invalid email or password"] --> User
    CheckCredentials -- Yes --> CreateSession["Create Session"] --> LoginSuccess["Login Successful"] --> RegisteredUser

    RegisteredUser --> Logout["Log Out"]
    Logout --> InvalidateSession["Invalidate Session"] --> LoggedOut["User Logged Out"] --> User
Loading

2.6 Feed

by Halil, Ceylin

flowchart TD
    %% Loading the feed
    User([User]) --> LoadFeed[Load Feed Page]
    LoadFeed --> FetchPosts[Fetch Posts from Database]
    FetchPosts --> DecisionSuccess{Posts Loaded Successfully?}
    DecisionSuccess -->|Yes| DisplayPosts[Display Posts in Feed]
    DecisionSuccess -->|No| ShowError[Show Error Message]

    %% Display and filter logic
    DisplayPosts --> DecisionFilter{Apply Filters/Sorting?}
    DecisionFilter -->|Yes| GetFilters[Get Filter/Sort Criteria]
    GetFilters --> ApplyFilter[Apply Filters/Sorting]
    ApplyFilter --> FetchPosts
    
    DecisionFilter -->|No| WaitForAction[Wait for User Action]

    %% Handling post click or interactions
    WaitForAction --> DecisionPostClick{User Clicks a Post?}
    DecisionPostClick -->|Yes| ShowPost[Show Post Details]
    DecisionPostClick -->|No| DecisionInteraction{Upvote, Downvote?}
    
    %% Handling other interactions like like/comment/share
    DecisionInteraction -->|Yes| PerformAction[Perform Upvote, Downvote]
    PerformAction --> WaitForAction
    DecisionInteraction -->|No| WaitForAction

    %% Post details and returning to main feed
    ShowPost --> WaitForAction
Loading

Sequence Diagrams

3.1 Code Execution

by Kristina

sequenceDiagram
   participant User
   participant PostDetailsPage
   participant CodeExecutionApi
   
   User->>PostDetailsPage: run_code_snippet();
   PostDetailsPage->>CodeExecutionApi: run_snippet(string code);
   CodeExecutionApi-->>PostDetailsPage: string code_output;
   PostDetailsPage-->>User:display_output();
Loading

3.2 Commenting

by Damla, Serhan

sequenceDiagram
   participant User
   participant PostDetailsPage
   participant CommentDatabase
   
alt Add Comment
    User ->> PostDetailsPage: writeComment()
    PostDetailsPage ->> CommentDatabase: storeComment()
    CommentDatabase -->> PostDetailsPage: commentStored()
    PostDetailsPage -->> User: displayComment()
end

alt Edit Comment
    User ->> PostDetailsPage: editComment()
    PostDetailsPage ->> CommentDatabase: updateCommentInDB()
    CommentDatabase -->> PostDetailsPage: commentUpdated()
    PostDetailsPage -->> User: displayUpdatedComment()
end

alt Delete Comment
    User ->> PostDetailsPage: deleteComment()
    PostDetailsPage ->> CommentDatabase: deleteCommentFromDB()
    CommentDatabase -->> PostDetailsPage: commentDeleted()
    PostDetailsPage -->> User: confirmCommentDeletion()
end
Loading

3.3 Browsing Programming Languages

by Mutti

sequenceDiagram
    participant User
    participant Browser
    participant LanguageController
    participant WikidataAPI

    User->>Browser: Search(keyword)
    Browser->>WikidataAPI: getWords(keyword)
    WikidataAPI-->>Browser: top5MatchedWords
    Browser->>WikidataAPI: getLanguageDetails(language)
    WikidataAPI-->>LanguageController: LanguageDetails
    WikidataAPI-->>LanguageController: LanguageRelatedPosts
    LanguageController-->>User: allPosts
    LanguageController-->>WikidataAPI: getSimilars(languageName)
    WikidataAPI-->>LanguageController: similarLanguageLinks
    User->>LanguageController: filterPosts(filters)
    LanguageController-->>User: FilteredPosts
Loading

3.4 Profile Page

by Emin

sequenceDiagram
    participant User
    participant UserController
    participant PrivateDatabase
    
    alt DisplayProfile
        User ->> UserController: viewProfile()
        UserController ->> PrivateDatabase: fetchProfileData(User)
        PrivateDatabase -->> UserController: ProfileData
        UserController -->> User: ProfileData
    end
    
    alt GetQuestions
        User ->> UserController: viewQuestions()
        UserController ->> PrivateDatabase: getQuestions(User)
        PrivateDatabase -->> UserController: Questions
        UserController -->> User: Questions
    end
    
    alt GetComments
        User ->> UserController: viewComments()
        UserController ->> PrivateDatabase: getComments(User)
        PrivateDatabase -->> UserController: Comments
        UserController -->> User: Comments
    end
    
    alt GetBookmarks
        User ->> UserController: viewBookmarks()
        UserController ->> PrivateDatabase: getBookmarks(User)
        PrivateDatabase -->> UserController: Bookmarks
        UserController -->> User: Bookmarks
    end

    alt EditQuestion
        User ->> UserController: editQuestion(Question)
        alt Question is empty
            UserController ->> UserController: deleteQuestion()
            UserController ->> PrivateDatabase: deleteQuestion(User)
            PrivateDatabase -->> UserController: delete status
            UserController -->> User: delete status
        else Question is not empty
            UserController ->> PrivateDatabase: editQuestion(User, Question)
            PrivateDatabase -->> UserController: edit status
            UserController -->> User: edit status
        end
    end

    alt EditComment
        User ->> UserController: editComment(Comment)
        alt Comment is empty
            UserController ->> UserController: deleteComment()
            UserController ->> PrivateDatabase: deleteComment(User)
            PrivateDatabase -->> UserController: delete status
            UserController -->> User: delete status
        else Comment is not empty
            UserController ->> PrivateDatabase: editComment(User, Comment)
            PrivateDatabase -->> UserController: edit status
            UserController -->> User: edit status
        end
    end

    alt Unbookmark
        User ->> UserController: unbookmark(Post)
        UserController ->> PrivateDatabase: deleteBookmark(User, Post)
        PrivateDatabase -->> UserController: status
        UserController -->> User: "Bookmark removed successfully"
    end
    
    alt EditName
        User ->> UserController: updateName(Name)
        UserController ->> PrivateDatabase: updateName(User, Name)
        PrivateDatabase -->> UserController: status
        UserController -->> User: status
    end
    
    alt EditPassword
        User ->> UserController: updatePassword(Password)
        UserController ->> PrivateDatabase: updatePassword(User, Password)
        PrivateDatabase -->> UserController: status
        UserController -->> User: status
    end
    
    alt EditProfilePicture
        User ->> UserController: updateProfile(Image)
        UserController ->> PrivateDatabase: updateProfilePicture(User, Image)
        PrivateDatabase -->> UserController: status
        UserController -->> User: status
    end

Loading

3.5 SignUp, Login, Logout

by Emin

sequenceDiagram
    participant User
    participant UserController
    participant PrivateDatabase

    alt SignUp
        User ->> UserController: signUp(Name, Email, Password)
        UserController ->> PrivateDatabase: checkIfEmailExists(Email)
        PrivateDatabase -->> UserController: emailExists?
        alt Email exists
            UserController -->> User: "Email already registered"
        else Email does not exist
            UserController ->> PrivateDatabase: saveUser(Name, Email, Password)
            PrivateDatabase -->> UserController: signUpStatus
            UserController -->> User: "Sign-up successful"
        end
    end

    alt Login
        User ->> UserController: logIn(Email, Password)
        UserController ->> PrivateDatabase: checkUser(Email, Password)
        PrivateDatabase -->> UserController: userFound?
        alt User found
            UserController ->> PrivateDatabase: createSession(User)
            PrivateDatabase -->> UserController: sessionInfo
            UserController -->> User: "Login successful", sessionInfo
        else User not found
            UserController -->> User: "Invalid email or password"
        end
    end

    alt LogOut
        User ->> UserController: logOut()
        UserController ->> PrivateDatabase: invalidateSession(User)
        PrivateDatabase -->> UserController: logoutStatus
        UserController -->> User: "Logout successful"
    end
Loading

3.6 Feed

by Halil, Ceylin

sequenceDiagram
    participant User
    participant FeedPage
    participant SearchQuery
    participant PostController

    alt Browse Feed
        User ->> FeedPage: openFeed()
        FeedPage ->> SearchQuery: executeSearch(filters)
        SearchQuery ->> PostController: fetchPosts(filters)
        PostController -->> SearchQuery: posts[]
        SearchQuery -->> FeedPage: searchResults[]
        FeedPage -->> User: displayPosts(searchResults)
    end

    alt Filter/Sort Posts
        User ->> FeedPage: applyFilter(filterOptions)
        FeedPage ->> SearchQuery: executeSearch(filterOptions)
        SearchQuery ->> PostController: fetchPosts(filterOptions)
        PostController -->> SearchQuery: filteredPosts[]
        SearchQuery -->> FeedPage: filteredResults[]
        FeedPage -->> User: displayFilteredPosts(filteredResults)
    end

    alt View Post Details
        User ->> FeedPage: selectPost(postId)
        FeedPage ->> PostController: fetchPostDetails(postId)
        PostController -->> FeedPage: postDetails
        FeedPage -->> User: displayPostDetails(postDetails)
    end

Loading

🏡 Home

🧑‍💻 Team Members
📑 Templates
📍 Project
📆 Planning
📓 Meeting Notes
📓 Lab Reports
CMPE 352
📍 Project
💎 Customer Requirements Milestone
👑 Design and Implementation
Testing 🔬
📓 Meeting Notes

📆 Planning

📑 Templates

Clone this wiki locally