Skip to content

Instantly share code, notes, and snippets.

@kevintab95
Last active August 22, 2020 03:50
Show Gist options
  • Save kevintab95/3b2375f71f04476b507b22e7ad8d123f to your computer and use it in GitHub Desktop.
Save kevintab95/3b2375f71f04476b507b22e7ad8d123f to your computer and use it in GitHub Desktop.
Sequence diagrams for Topic, Story, Subtopic, and Practice Session pages
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
participant acl_decorators
participant story_fetchers
participant topic_fetchers
participant topic_services
participant user_services
participant story_viewer
participant summary_services
participant exp_fetchers
participant rights_manager
participant stats_services
Note left of acl_decorators: Receives GET request
acl_decorators->story_fetchers: get_story_by_url_fragment()
Note over story_fetchers: Get Story by url_fragment from\nmemorystore if key exists\nelse get from datastore
story_fetchers-->acl_decorators:Story model
acl_decorators->user_services:UserActionsInfo.init()
Note over user_services:Does a get_multi call to fetch UserSettingsModel\nand get user settings and initializes UserActionsInfo
user_services-->acl_decorators:UserActionsInfo objects
acl_decorators->topic_fetchers:get_topic_by_id()
Note over topic_fetchers: Get Topic by id from\nmemorystore if key exists\nelse get from datastore
topic_fetchers-->acl_decorators:Topic model
Note over acl_decorators: Get classroom_url_fragment for the\ntopic id by iterating over the list of\n topic ids in the classroom config\nproperty
acl_decorators->topic_services:get_topic_rights()
Note over topic_services:Does get call to fetch TopicRightsModel
topic_services-->acl_decorators:TopicRights model
Note left of acl_decorators: GET StoryPage
acl_decorators->story_viewer: StoryPage.get()
Note over story_viewer: Returns story-viewer-page.mainpage.html
Note left of acl_decorators: GET StoryPageData
acl_decorators->story_viewer: StoryPageDataHandler.get()
story_viewer->story_fetchers:get_story_by_id()
Note over story_fetchers: Get Story by id from\nmemorystore if key exists\nelse get from datastore
story_fetchers-->story_viewer:Story model
story_viewer->topic_fetchers:get_topic_by_id()
Note over topic_fetchers: Get Topic by id from\nmemorystore if key exists\nelse get from datastore
topic_fetchers-->story_viewer:Topic model
Note left of story_viewer: LOOP BEGIN:\nIterate over Story nodes in each Story
story_viewer->story_fetchers:get_completed_nodes_in_story()
Note over story_fetchers: Get StoryProgressModel
story_fetchers-->story_viewer:List of completed Story Nodes
Note left of story_viewer: LOOP END
Note over story_viewer: Iterates over ordered_node_dicts\nto populate 'completed'\nnode property
Note over story_viewer: Iterates over ordered_node_dicts\nto populate exp_ids list
story_viewer->summary_services:get_displayable_exp_summary_dicts_matching_ids()
summary_services->exp_fetchers:get_exploration_summaries_matching_ids()
Note over exp_fetchers:Does ExpSummaryModel.get_multi()
exp_fetchers-->summary_services:exploration_summaries
summary_services->rights_manager:get_multiple_exploration_rights_by_ids()
Note over rights_manager:Does ExplorationRightsModel.get_multi()
rights_manager-->summary_services:exploration_rights_objects
summary_services->stats_services:get_exploration_stats_multi()
Note over stats_services: Does ExplorationStatsModel.get_multi_stats_models()
stats_services-->summary_services:exp_stats_list
Note over summary_services: Iterates over exp_stats_list\nto populate view_counts
Note over summary_services: Iterates over exploration_summaries\nto populate displayable_exp_summaries
summary_services-->story_viewer:displayable_exp_summaries
Note over story_viewer: Iterates over ordered_node_dicts\nto populate 'exp_summary_dict'\nnode property
Note over story_viewer:Renders JSON
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
participant acl_decorators
participant topic_fetchers
participant topic_services
participant user_services
participant subtopic_viewer
participant subtopic_page_services
Note left of acl_decorators: Receives GET request
acl_decorators->topic_fetchers: get_topic_by_url_fragment()
Note over topic_fetchers: Get Topic from the memorystore if key exists\nelse get from datastore
topic_fetchers-->acl_decorators:Topic model
acl_decorators->topic_services:get_topic_rights()
Note over topic_services:Does get call to fetch TopicRightsModel
topic_services-->acl_decorators:TopicRights model
acl_decorators->user_services:UserActionsInfo.init()
Note over user_services:Does a get_multi call to fetch UserSettingsModel\nand get user settings and initializes UserActionsInfo
user_services-->acl_decorators:UserActionsInfo objects
Note over acl_decorators:Iterates over subtopics to\nfind matching url_fragment
Note over acl_decorators: Get classroom_url_fragment for the\ntopic id by iterating over the list of\n topic ids in the classroom config\nproperty
acl_decorators->subtopic_page_services:get_subtopic_page_by_id()
Note over subtopic_page_services:Does get call to fetch SubtopicPageModel
subtopic_page_services-->acl_decorators:subtopic_page
Note left of acl_decorators: GET Page
acl_decorators->subtopic_viewer: SubtopicViewerPage.get()
Note over subtopic_viewer: Returns subtopic-viewer-page.mainpage.html
Note left of acl_decorators: GET Data
acl_decorators->subtopic_viewer: SubtopicPageDataHandler.get()
subtopic_viewer->topic_fetchers:get_topic_by_name()
Note over topic_fetchers: Get Topic by name from\nmemorystore if key exists\nelse get from datastore
topic_fetchers-->subtopic_viewer:Topic model
Note left of subtopic_viewer: LOOP BEGIN:\nIterate over subtopics
Note over subtopic_viewer:Iterate over subtopics to populate subtopic_title, next_subtopic_dict
Note left of subtopic_viewer: LOOP END
subtopic_viewer->subtopic_page_services:get_subtopic_page_contents_by_id()
Note over subtopic_page_services:Does get call to fetch SubtopicPageModel
subtopic_page_services-->subtopic_viewer:page_contents
Note over subtopic_viewer:Renders JSON
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
participant acl_decorators
participant topic_fetchers
participant topic_services
participant user_services
participant topic_viewer
participant story_fetchers
participant skill_services
participant skill_fetchers
participant practice_sessions
Note left of acl_decorators: Receives GET request
acl_decorators->topic_fetchers: get_topic_by_url_fragment()
Note over topic_fetchers: Get Topic by url_fragment from\nmemorystore if key exists\nelse get from datastore
topic_fetchers-->acl_decorators:Topic model
Note over acl_decorators: Get classroom_url_fragment for the\ntopic id by iterating over the list of\n topic ids in the classroom config\nproperty
acl_decorators->topic_services:get_topic_rights()
Note over topic_services:Does get call to fetch TopicRightsModel
topic_services-->acl_decorators:TopicRights model
acl_decorators->user_services:UserActionsInfo.init()
Note over user_services:Does a get_multi call to fetch UserSettingsModel\nand get user settings and initializes UserActionsInfo
user_services-->acl_decorators:UserActionsInfo objects
Note left of acl_decorators: GET TopicViewerPage
acl_decorators->topic_viewer: TopicViewerPage.get()
Note over topic_viewer: Returns topic-viewer-page.mainpage.html
Note left of acl_decorators: GET TopicViewerPage Data
acl_decorators->topic_viewer: TopicPageDataHandler.get()
topic_viewer->topic_fetchers:get_topic_by_name()
Note over topic_fetchers: Get Topic by name from\nmemorystore if key exists\nelse get from datastore
topic_fetchers-->topic_viewer:Topic model
Note left of topic_viewer: LOOP BEGIN:\nIterate over Topic summary ids
topic_viewer->story_fetchers:get_story_summary_by_id()
story_fetchers-->topic_viewer:Story Summary model
Note left of topic_viewer: LOOP END
Note left of topic_viewer: LOOP BEGIN:\nIterate over Story nodes in each Story
topic_viewer->story_fetchers:get_completed_nodes_in_story()
Note over story_fetchers: Get StoryProgressModel
story_fetchers-->topic_viewer:List of completed Story Nodes
Note left of topic_viewer: LOOP END
topic_viewer->skill_services:get_descriptions_of_skills()
Note over skill_services:SkillSummaryModel.get_multi() and iterates\nover result to populate skill_id_to_description_dict,\ndeleted_skill_ids
skill_services-->topic_viewer:skill_id_to_description_dict, deleted_skill_ids
topic_viewer->skill_services:get_multi_user_skill_mastery()
Note over skill_services:UserSkillMasteryModel.get_multi() and\npopulates degrees_of_mastery dict
skill_services-->topic_viewer:degrees_of_mastery dict
Note over topic_viewer:Renders JSON
Note left of acl_decorators: GET PracticeSessionsPage
acl_decorators->practice_sessions: PracticeSessionsPage.get()
Note over practice_sessions: Returns practice-session-page.mainpage.html
Note left of acl_decorators: GET PracticeSessionsPage Data
acl_decorators->practice_sessions: PracticeSessionsPageDataHandler.get()
practice_sessions->topic_fetchers:get_topic_by_name()
Note over topic_fetchers: Get Topic by name from\nmemorystore if key exists\nelse get from datastore
topic_fetchers-->practice_sessions:Topic model
Note over practice_sessions: Iterates over subtopics to populate selected_skill_ids
practice_sessions->skill_fetchers:get_multi_skills()
Note over skill_fetchers: Does SkillModel.get_multi() and\niterates over results to check\nif skill models exist
skill_fetchers-->practice_sessions:skills
Note over practice_sessions: Iterates over skills to populate\nskill_ids_to_descriptions_map
Note over practice_sessions:Renders JSON
@kevintab95
Copy link
Author

kevintab95 commented Aug 22, 2020

Generating Sequence Diagrams using Text:

  1. Starting from the entry method, when a new file is referred to, add the file as a new 'participant'. E.g.
    participant <new_file>

  2. When a call is made to a method in a different file, use this syntax:
    current_file->new_file: method_being_called()

  3. Represent execution of a fetch call, using this syntax:
    Note over current_file: Get XYZ from datastore

  4. When the method execution is completed, use this syntax to show control returning to the calling method and the data returned:
    current_file-->new_file:XYZ model

  5. Represent loops using a note to the left of the calling method. E.g.
    Note left of current_file: LOOP BEGIN:\nIterate over XYZ ids
    current_file->new_file: method_being_called()
    new_file-->current_file: XYZ model
    Note left of current_file: LOOP END

  6. Once the text file is ready, generate the sequence diagram SVG by going to this page:
    https://bramp.github.io/js-sequence-diagrams/

  7. Copy paste the text content into one of the 'Demo' boxes, select 'Simple' as the theme, and download the SVG file.

See examples:
https://gist.github.com/kevintab95/3b2375f71f04476b507b22e7ad8d123f

Reference for syntax:
https://bramp.github.io/js-sequence-diagrams/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment