Skip to content

Notebooks

Joulene Huang edited this page Aug 24, 2025 · 4 revisions

2025 CP3108A: Team Notebooks

This project aims to create a Notebook functionality similar to Jupyter Notebooks in Source Academy for students and lecturers. This involves resolving the issues that the current ‘Stories’ has - including CSE, Stepper and Data Visualiser not working properly, issues of shared environment for outputs in Stories (REPL) and stories not recovering from errors without resetting.

Notebooks can be useful for personal notetaking, and definitely for lectures as currently lecture slides have many links that lead to source academy playground, but it would be great if it is possible to combine all these code snippets into one notebook so lecturers can better explain the codes and students can run the codes and try them out during lecture or in their own revision.

The aim of the backend improvements are:

  • Move 'Stories' golang backend to 'Source Academy' elixir backend
  • Combine authentication and other functionality with the main ‘Source Academy’ backend
  • Allow auto save of notebook cells

Pull Requests

Frontend - PR 3121 see frontend wiki for more information

Backend - PR 1246

Combine backends

These are the tables in the Stories Backend that correspond to the Source Academy backend

SA backend Stories
users users
courses groups
groups (for studio groups) na
course_reg user_groups
id id
id course_groups (maps SA id of courses to stories id)

Note: The 'stories' table in SA is for the SA game and not the same as the stories-backend 'stories', which is why we renamed to notebooks

Notebook tables

While we combine the backends, we have to change the way stories are stored. The previous stories-backend implementation simply stored stories as a long string, as users have to edit and then save the markdown. However, the new implementation, Notebooks, allows creating notebook cells with a better UI, just like in jupyter notebooks, while also enabling notebooks to be used on mobile. This results in three tables instead of one: Notebooks, Cells, Environment. Storing notebooks this way can hopefully resolve the issues 'Stories' has on shared environment and output not showing correctly.

image

Notebooks:

  • config: The yaml portion of stories that stores things like the environment (what version of source is being used) etc.

Cells:

  • index vs id: Autosaving of cells (when the user edits a cell, call the backend to update the cell) and being able to delete and reorder cells to any index is a new feature, different from stories. So, there is the index of cells which will be updated rather than using the id. The index can then be extracted in ascending order when building the notebook again. The logic for changing the indexes is currently in the frontend.

Environment: An environment table was created as we allow users to create their own names for environments that can be shared between many cells. For example, they can have one environment called iterFib that uses source 2 and have multiple different cells that share this environment throughout the notebook. This allows students to take notes in a notebook and not be limited to one source variant.

Note for the retrieval of notebooks, it is separated into two functions:

  • Published notebooks - everyone can see this, and admin for the course should be able to edit this while others can only view
  • Own notebooks - retrieves student's own notebooks/ unpublished course notebooks for admins

Changelog

  • Database migration
  • Table schemas
  • CRUD functionalities

Outstanding tasks

  • Implement CSE Machine + Stepper + Data Visualiser - Currently, not all of these tools work
  • CRUD may not work properly as not tested yet. Would be good to check the functionality for different users i.e. professors/students/TA
  • The routes for the CRUD functionalities are not done - so the frontend has not been connected to the backend yet.
  • Frontend has not updated the page that displays all the notebooks - may want to split the page into published and own notebooks
  • Decide on a way to store the default notebook with a tutorial on how to use it - currently it is stored on the frontend, may want to move to backend

Other possible improvements: Sessions, share links, managing share permissions

Clone this wiki locally