Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-7905 - Update documentation on tldraw #42

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

bergatco
Copy link

Description

The new setup of the tldraw feature needs to be documented.

Links to Tickets or other pull requests

JIRA :

Changes

Datasecurity

Deployment

New Repos, NPM pakages or vendor scripts

Screenshots of UI changes

Approval for review

  • All points were discussed with the ticket creator, support-team or product owner. The code upholds all quality guidelines from the PR-template.

Notice: Please remove the WIP label if the PR is ready to review, otherwise nobody will review it.

@bergatco bergatco self-assigned this Nov 28, 2024

1. User from schulcloud app in CourseBoard deletes whiteboard (tldraw) instance form CardBoard.
2. Having drawingName sc-server is removing Representation data in sc-database - BoardNodes collection ( drawingName === BoardNode id)
3. Sc-server is calling tldraw-server via tldraw-management rules in tldraw-server-svc to delete all data that has given id).
3. Schulcloud-server is calling tldraw-server via tldraw-management rules in tldraw-server-svc to delete all data that has given id.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Via tldraw-management rules ergibt irgendwie nicht so richtig Sinn.

@@ -1,31 +1,25 @@
# Technical details

## Backend
We are using pure Web Sockets implementation to establish connection between client and server. The reason why we used pure websockets is because tldraw-client is using y-websockets from Yjs library, that does not connect with socket.io web sockets. We also have to implement broadcasting mechanism to provide stateless solution. To achive that goal we decided to use Redis. We used ioredis library to connect to our Redis instance. Everytime user make some changes at first it is handled to the server instance that he is connected to an then this change is send to the channel with the name of the board and servers that also operate that board are listening on this channel so they can recive messages from other servers and provide those changes to users that are connected to this pod. We added the same mechanism for awareness channel so every user from every pod can see other users cursours.
We are using pure Web Sockets implementation to establish connection between client and server. The reason why we used pure websockets is because tldraw-client is using y-websockets from Yjs library, that does not connect with socket.io web sockets. We also have to implement broadcasting mechanism to provide stateless solution. To achive that goal we decided to use Redis. We used ioredis library to connect to our Redis instance. Everytime user make some changes at first it is handled to the server instance that he is connected to an then this change is send to the channel with the name of the board and servers that also operate that board are listening on this channel so they can recive messages from other servers and provide those changes to users that are connected to this pod. We added the same mechanism for awareness channel so every user from every pod can see other users cursors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warum will man generell socket.io benutzen? Warum brauchten wir eine stateless solution? Warum benutzen wir dann doch socket.io? Der Absatz ist nicht verständlich. Dazu Grammatik und die Verwendung von Zeiten.


Tldraw is deployed as a separate application from schoulcloud-server. On the backend side we have added couple new resources:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jetzt gerade sind die neu aber wenn das jemand in zwei Jahren liest? Und der client hat ja auch nichts mit der backend side zu tun.

- tldraw.repo.ts - repository used by TldrawService to find and delete boards from database.
- ws-shared-doc.do.ts - main structure representing tldraw drawing during web socket communication. it holds all the web-socket addresses that are connected to this board, so we can inform all the connected clients about changes.
- tldraw-drawing.entity.ts - object representing tldraw drawingn entity in database.
- tldraw-config.controller.ts - controller that exposes tldraw server configuration to be used by the tldraw client.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sollte eigentlich auch vom vue client benutzt werden oder?
Aktuell leider noch so:

const sanitizedUrl = computed(() =>
	sanitizeUrl(`/tldraw?parentId=${element.value.id}`)
);

- redis.service.ts - encapsulates the logic for creating and managing Redis instances, supporting both standalone and sentinel configurations, and integrates seamlessly with the NestJS framework.
- ioredis.adapter.ts - encapsulates the logic for interacting with Redis, including defining custom commands and subscribing to channels. It leverages the ioredis library and integrates with the application's configuration and logging systems to provide a robust and flexible Redis adapter.
- api.service.ts - API service for y-redis.
- ws.service.ts - main service responsible for establishing web socket connection as well as saving data to database. Responsibe for Redis communication.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Responsibe for Redis communication. würde ich beim Adapter sagen

- metrics.service.ts - service resonsible for storing application-level metrics.

- worker.service.ts - responsible for persisting the current state of changed tldraw documents into the file storage.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gibt es noch ein detailliertere Beschreibung des Workers?

@@ -70,7 +64,7 @@ This hook is designed to observe changes in the DOM, specifically targeting cert

- https://github.com/tldraw/tldraw-v1 - tldraw v1 repo

- https://github.com/MaxNoetzold/y-mongodb-provider - code from this package was used to add mongodb as a persistence to tldraw
- https://github.com/yjs/y-redis - code from this package was used to add y-redis as a persistence to tldraw
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Den Satz verstehe ich nicht

- TLDRAW_WEBSOCKET_PATH - path for the tldraw websocket connection
- TLDRAW_WEBSOCKET_URL - URL for the tldraw websocket connection
- WORKER_MIN_MESSAGE_LIFETIME - minimal lifetime of a message consumed by the worker
- WORKER_TASK_DEBOUNCE - minimum idle time (in milliseconds) of the pending messages to be claimed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idle time of the messages or worker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants