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

Multi-tenant architecture #125

Open
benwbrum opened this issue May 30, 2020 · 0 comments
Open

Multi-tenant architecture #125

benwbrum opened this issue May 30, 2020 · 0 comments
Labels

Comments

@benwbrum
Copy link
Contributor

Converting Mashbill to a multi-tenant architecture will allow more than the Civil War Governors of Kentucky to use the tool, so that other documentary editing projects can leverage the technology, but also (to some extent) the research by the Kentucky Historical Society.

Supporting multi-tenant use cases requires separating data for each project. Data is currently stored on Hypothes.is, in the Mashbill database, and in the document repository in Github. We'll need a way to configure a new project, setting the project-specific values of each of these. We'll also need to separate data within Mashbill for users and documents. For entities, projects should be able to see and reuse each other's research, but they should not be required to share the same data for the same person if they appear in more than one collection.

Implementation

  • Move settings for Github repository information, working document directory on the filesystem, and hypothesis group (and API keys, if needed) into a new Project model, which will also contain a project title and any other project-specific information needed.
  • Add a new project_id foreign key (or belongs_to AR relation) onto documents, entities, users and possibly annotations (the last might not be needed, since annotations belong to a document which will have a project already).
  • Add filters to all queries to make sure that retrieval is done against current_user.project
  • Add before_save filters to all models to make sure that data is persisted with current_user.project as the value for the models' project.
  • Use a project-specific document directory for updates
  • Use a project-specific github repository for documents
  • Use a project-specific Hypothes.is group and credentials when syncing

Special handling for Entities

We would like to surface entities from other Mashbill projects so that data can be shared. To this end, we'll make the following changes

Entity Search Screen

Rather than adding a hard restriction to filter on current_user.project, we will search all entities in the system for potential matches.
We will add a new column for "Project" next to each entity.
We'll use Datatables to support sorting and searching.

Entity Display/Edit Screen

When viewing an entity from another project, a new "copy entity" button will appear

  • Copying an entity will create a new entity from the original, with the same values.
  • The user will be able to edit the entity's value, but the initial data values will start with the originating project's.
  • A new copied_entity_id will allow new copied_from and copied_to relationships in the data model.
  • When displaying an entity in either view or edit mode, any other project's entry for a copied entity will be displayed as read-only for cross-project reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants