Automatic generation of user interfaces from SHACL https://shacl-vue.psychoinformatics.de/
  • Vue 73%
  • JavaScript 25.4%
  • Python 0.9%
  • CSS 0.3%
  • Shell 0.3%
  • Other 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Stephan Heunis cc08f69a55 Improve design to limit rendering latency for records with many properties
The problem this new approach aims to solve is the bad UX of waiting several
(tens of) seconds for a record with thousands of related nodes to render. It
came to light when rendering a file with thousands of parts. This is likely a
minor representation of the issue, which will worsen with larger records.

The new approach aims to do defer the maximum amount of processing until the
latest possible timepoint. Previous work in 3501e82380 already paved the way
for solving the current record rendering challenge. That commit introduced the
new record handling approach, a.k.a. maintaining a global list of items that is
incrementally updated when new nodes are added to or updated in the graph. This
global list of items also contains information about related nodes, preflabels,
and displayLabels. So it already calculated and contains information required
by the current record viewer, which currently ignored that and just recalculated
everything itself.

The new approach firstly involves minimal processing upfront when a record is
first fetched form the backend. It only indexes related nodes (not recursively)
but now in the structure expected by the NodeShapeViewer, i.e. divided into
termType triples. The minimally processed item that is now part of the global
list of items (recordItemsAll) is accessed in the NodeShapeViewer when it first
mounts. The NodeShapeViewer then takes an on-demand approach to processing
related nodes (i.e. its properties). For each property, on first mount it will
process up to the 'stepsize'-configured amount of values (e.g. 5) in order to
fetch nodes related to that property value and to calculate the display label
of that property value. Furthermore the same on-demand processing happens only
when the user hits the + button which changes the index-shown value of the
MoreOrLessRecordsViewer for that particular property. This replaces the previous
approach of the NodeShapeViewer where it calculated everything from scratch at
component mounting time using the quad prop.

Newly introduced functionality in the NodeShapeViewer includes:
- updateItem() which is called in onBeforeMount. This function does additional minimal
  processing for all properties and values that will be rendered by default (i.e.
  they are fewer than the default displayed step size, e.g. 5. This minimal processing
  is handled by updateNamedNodeProperty() and updateBlankNodeProperty())
- updateNamedNodeProperty() and updateBlankNodeProperty() update specific properties
  on-demand. Updating involves sometimes fetching related nodes and subsequently
  determining label details from related nodes. The point is to have readily available
  display label and preflabel information for rendering.
- waitForRecordProcessing() is a new async function that allows waiting for a record
  in the global list of items to finish processing (after a triggered fetch) so that
  the NodeShapeViewer functionality can be sure that the item contains label details
  that are necessary for further processing.
- when the NodeShapeViewer mounts, updateItem makes a structural copy from the associated
  item in recordItemsAll into a local reactive object, and does the rest of the processing
  for updating on that object. In contrast, after a record is edited and saved, the
  updateItem function builds up the item from scratch directly from the graph (using new
  useRecords utilities, specifically constructItem), i.e. it doesn't copy the state from
  recordItemsAll. This was necessary because the edited changes did not want to render as
  expected after a record save, if the normal updateItem was run. This issue caused much
  frustration and lots of wasted time trying to debug. The end-result, which now does what
  is expected, is therefore not in the current state by perfect design, but by necessity
  and as a solution to the to-me inexplicable Vue reactivity problem.
- however many values of a given property is shown at any given time, all of those will be
  ordered alphanumerically; this means that the rendered index of a value might change
  if the user hits the + or - buttons to show more or fewer values of a property. This
  was done as a second-prize, to still allow sorting while not being able to sort all
  values since all values' display labels might not have been generated yet due to the
  new on-demand approach.

Another note on the waitForRecordProcessing() function and its use. When the
NodeShapeViewer uses fetchFromService to fetch a record, the expected outcome is that
the record is fetched and processed by useRecords' updateRecordItem function, and then
it ends up in recordItemsAll. It could be the case that the fetched record was already
in recordItemsAll prior to the fetch (in which case the fetch is skipped), or that the
record could not be fetched at all (perhaps it doesn't exist in the backend, perhaps
there was an http error). So the result from fetchFromService is first tested:

results?.status?.includes('success') || results?.status?.includes('skipped')

and only if this condition is met can we be certain that the record exists in recordItemsAll
and only then can waitForRecordProcessing be called without fear of a timeout error.
To support this process, the useData composable needed to be updated to:
- check recordItemsAll rather than fetchedRequests for the pre-existence of the record
  (TODO: fetchedRequests seemed to suffer from a race condition and could not
  persistently and correctly pick up whether a record already existsed or was fetched
  or not)
- also return the pid of the record that was skipped, specifically in the case of the
  'get-record' endpoint which is the one used in the NodeShapeViewer when a related
  record is fetched.

To support all of the above, the useRecords composable was updated to do the minimal upfront
processing and also to set a status flag when it has finished processing a new or
updated item. It also underwent a bit of refactoring to make the code more understandable
and allow the constructItem to be used in the composable as well as to be exported for
use by the NodeShapeViewer.

Lastly, to reduce onMount processing for the NodeShapeViewer even more, the backlink viewer
functionality was disabled, by commenting out the associated lines of code. It will
be brought back in a future commit, but via a user-clickable interface, i.e. it will
not be displayed upfront by default.
2026-07-08 14:27:23 +02:00
.forgejo/workflows correct directory paths for cp command 2026-01-15 21:39:56 +01:00
.github/workflows Add github action to codespell main on push and PRs 2025-02-24 14:30:02 -05:00
docs add more content+updates to 'useful features' section 2026-06-11 08:23:22 +02:00
public Add update_shapes option to config template 2026-01-23 16:17:42 +01:00
src Improve design to limit rendering latency for records with many properties 2026-07-08 14:27:23 +02:00
tests Reformat all files with prettier 2025-06-08 23:57:26 +02:00
tools Helpers for getting default schemas and data 2025-04-22 18:35:36 +02:00
.browserslistrc Basic scaffolding of vite-powered vuejs+vuetify project for rendering/viewing shacl shapes 2024-03-26 15:07:32 +01:00
.codespellrc Add rudimentary codespell config 2025-02-24 14:30:02 -05:00
.editorconfig Basic scaffolding of vite-powered vuejs+vuetify project for rendering/viewing shacl shapes 2024-03-26 15:07:32 +01:00
.gitignore ignore 'src/runtime-plugins' directory 2026-03-30 21:13:18 +02:00
.npmignore update npmignore to deal with recent updates to build process 2025-02-28 23:30:09 +01:00
.prettierignore Add prettier, indentation set at 4 spaces, add npm script 2025-06-08 23:56:38 +02:00
.prettierrc Add prettier, indentation set at 4 spaces, add npm script 2025-06-08 23:56:38 +02:00
index.html Reformat all files with prettier 2025-06-08 23:57:26 +02:00
index.js Reformat all files with prettier 2025-06-08 23:57:26 +02:00
jsconfig.json Reformat all files with prettier 2025-06-08 23:57:26 +02:00
LICENSE Initial commit 2024-03-21 11:11:07 +01:00
package-lock.json Support nunjucks templating for wizardeditor feature 2026-03-18 21:26:20 +01:00
package.json Support nunjucks templating for wizardeditor feature 2026-03-18 21:26:20 +01:00
README.md Refer to new docs and dev repo links 2026-01-15 21:32:45 +01:00
vite.config.app.mjs Make build output directory configurable via env variable 2026-05-14 14:02:55 +02:00
vite.config.lib.mjs Reformat all files with prettier 2025-06-08 23:57:26 +02:00

shacl-vue

THIS REPOSITORY IS UNDER CONTINUOUS DEVELOPMENT

Overview

shacl-vue is a web-based user interface for entering, editing, and viewing linked (meta)data using a VueJS application driven by the Shapes Constraint Language (SHACL).

Think of it as an automatic builder that you just have to feed with a model of your data. If you have a SHACL schema, or a schema in a format that can be exported to SHACL, then you're good to go. No need to build custom forms for data entry, no need to struggle with post-entry data validation, no need to create a catalog application that renders all the entered data. shacl-vue does all of this automatically.

shacl-vue is built with VueJS 3, Vuetify frontend components, and Vite build tools, and was heavily inspired by the WC3 Draft: Form Generation using SHACL and DASH. For reading, manipulating, and writing RDF data (including SHACL), the package uses libraries compatible with the RDF/JS specifications (see also: https://github.com/rdfjs-base)

Installation and usage

shacl-vue can be installed from npm:

npm install shacl-vue

Use as a library

The npm package currently provides the named export ShaclVue:

import { ShaclVue } from 'shacl-vue'

This is the main configurable VueJS component that is used to render all functionality of shacl-vue. It can be instantiated inside a VueJS application as follows:

<template>
    <ShaclVue :configUrl="myconfig"></ShaclVue>
</template>
<script setup>
const myconfig = 'config.json';
</script>

Here, config.json is used to configure the properties of the specific shacl-vue deployment. See examples here, and here.

For the above to work, the VueJS application will have to install Vuetify and the ShaclVue might need to be registered explicitly.

Use as a standalone site

The build steps of shacl-vue produce both the library as well as a set of static files that can be served as a standalone site. The abovementioned metadata annotation tool of the TRR379 Research Consortium deploys shacl-vue in this manner, and its source code can be viewed here.

To use shacl-vue to deploy a standalone site, follow the build steps below. In addition, a deployment-specific confi file should be provided.

Local development and building

The shacl-vue source code can be cloned for local development, testing, or building. First clone the repository:

git clone https://hub.psychoinformatics.de/datalink/shacl-vue.git
cd shacl-vue

Then create a local NodeJS virtual environment, e.g with micromamba:

micromamba create -n <my-env-name> nodejs
micromamba activate <my-env-name>

Then install the application:

npm install .

Local rendering during development

To serve the application locally in order to test it in the browser, run:

npm run dev

Build steps

To build the library (output at /dist/lib):

npm run build:lib

To build the standalone site, i.e. VueJS application (output at /dist/app):

npm run build:app

To build both the library and the standalone site:

npm run build

Testing

Testing remains a primary TODO for this package, although a minimal test is in place to check whether the named exports can be imported into a new project. Testing is done with Vitest.

npm run test

Dependency on shacl-tulip

In an effort to generalize shacl-vue for improved use by and interoperability with other applications, the underlying functionality was factored out and packaged as the shacl-tulip library (like "shacl-vue-lib"). shacl-tulip provides the main (derived) classes for handling RDF data and related form data. It is completely independent of VueJS, yet class constructors allow passing reactive objects as arguments, which shacl-tulip handles seamlessly. It also focuses purely on library-level functionality (including utilities that were previously part of shacl-vue), and contains no frontend code. shacl-vue imports shacl-tulip classes and uses them mainly in its composable code.

Access to external webservices

Unless configured to connect to specific API endpoints (see Service API integration docs), a client accessing a bundled shacl-vue deployment does not load any external resources. All required resources are loaded from the server where the bundled application is hosted.

Acknowledgements

This work was funded, in part, by

  • Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under grant TRR 379 (546006540, Q02 project)
  • Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under grant SFB 1451 (431549029, INF project)
  • MKW-NRW: Ministerium für Kultur und Wissenschaft des Landes Nordrhein-Westfalen under the Kooperationsplattformen 2022 program, grant number: KP22-106A