# Feature COMMS-1122 - Replace Hocuspocus with y/hub

Project: Stream Communicator
Status: in specification
URL: https://community.openproject.org/work_packages/COMMS-1122

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | Product Backlog |
| Sprint |  |
| Backlog bucket |  |
| Votes |  |
| List |  |
| Roadmap |  |
| Relevance |  |

## OPEN POINTS / FEEDBACK

_No work packages_

## Use cases

_No work packages_

## Features and Chunks

_No work packages_

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module | Modules and project features / Documents, Modules and project features / Text editor / Real time collaboration |
| Feature Flag |  |
| Requires doc change | No |
| Enterprise plan |  |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups |  |
| Accessibility | No |

## People

| Attribute | Value |
| --- | --- |
| Assignee | Judith Roth |
| Accountable |  |
| Product manager |  |
| Feature Lead |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| PD (min) |  |
| PD (max) |  |
| Work |  |
| Labor costs |  |

## Description

**As** a developer of documents  
**I want to** use a better collaboration server  
**so that** I can implement all the features I want, but can&#x27;t have with Hocuspocus

**Motivation**

*   With Hocuspocus it&#x27;s hard to know exactly which user did which change when multiple users are editing a document at the same time, because the writes are &quot;debounced&quot; and saved together, y/hub can do exact attribution of users
    
*   y/hub offers the clearer auth model for composite resources (e.g. comments on a document - one user is allowed to see them, another is only allowed to see the documents without comments)
    

**Acceptance criteria**

*   Hocuspocus is replaced with [y/hub](https://github.com/yjs/yhub)
    
*   Authentication uses proper JWT tokens
    
    *   Tokens can be validated without additional server requests (e.g. validating signatures with a public certificate)
        
*   y/hub writes data to the database directly
    
    *   It uses separate database user(s) with restricted permissions
        
    *   This has to work in a multi-tenancy setup where data has to be written to different schemas
        
*   y/hub is set up to work with redis (probably it&#x27;s own one)
    
    *   This has to work in a multi-tenancy setup
        
*   Markdown contents of a document still get written (necessary for e.g. search to work)
    
*   Journal entries of documents include
    
    *   The real author
        
    *   The content changed by that author (It would be nice to find a better way to store the journals than duplicating the whole document yDoc into each journal entry, but maybe this could also be a different feature)
        

**Technical notes**

*   How authentication was built with Hocuspocus is not optimal (but was the best we could do at that time). So we want to improve on that with y/hub. The extra api request for authorization did create security vulnerabilities in the past. And is also slow.
    
*   Y/hub will directly write to DB and this not require writing documents to DB via API v3. It therefore does not need an api access token.
    
*   It would be good if we can use a narrowed-down API scope for the token that y/hub will use (with only the permissions it needs). That requires that this kind of scopes are implemented for the `JwtOidc` Strategy
    

**OpenPoints (need to be resolved before or with this feature):**

*   [Licensing](https://github.com/yjs/yhub#licensing)
    
*   [y/hub missing features](https://github.com/yjs/yhub#missing-features)
    
    *   We need to include y/hub in our own helm charts - do we need y/hub Helm charts for this?
        
    *   **Are we okay with y/hub not being production ready yet?**
        
*   When and how do we write the Markdown contents of a document (which are used e.g. for search)?
    
*   How and when do we write the journal entries?
    
*   How do we ensure multitenancy for cloud?
    
*   Do we need a separate Redis for y/hub or can we re-use the existing one?
    
    *   We need to find out if the Redis configuration that y/hub needs is compatible with what our existing Redis uses
        
    *   If we reuse the existing Redis, we have to make sure the data stays separate between mutliple tenancts, e.g. by using Redis ACLs with one user per deployment
        
*   Will we keep the yDoc binary in the `documents` table? Probably not.
    

**Out of scope**

*   Implementing the new features y/hub enables, e.g. comments on documents. This needs to happen separately.
