Giter Site home page Giter Site logo

encore's Introduction

SvelteKit Triplestore

Features of this application include:

  • Linked-data first structure.
  • JSON-LD graph capabillities.
  • Automatically generated REST api & queries.
  • Schema-less datastore; arbitrary key:val pairs on objects.
  • N-to-N directed resource relationships.
  • Svelte components, delivered in a SvelteKit application.
  • Helpers methods for performing queries and updates via SPARQL graph query language.

Getting Started

$ npm install
$ docker-compose build
$ docker-compose up

Load with Data

  1. Visit http://localhost:7878/
  2. In the little endpoint input, set to http://localhost:7878/update
  3. Run the following:
PREFIX vox: <https://vocab.voxmedia.com/#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
INSERT DATA {
  <http://localhost:5173> rdf:type <vox:Service> .
  <http://localhost:5173> vox:title "Encore" .
}

What's up with those prefix thingies? vox: and rdf:? Those are namespaces. They allow us to disambiguate keys from each other. For this project, you can use vox: for any key you want. You can also edit the src/lib/ld/prefixes.js file to add other namespaces, if you want to create a new namespace or add extant linked-data terms.

Encore Queries

Create Backlink

curl --request POST \
  --url http://localhost:5173/api/backlinks/create \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data id=uri:uuid:sports \
  --data 'vox:context :=chorusNetwork:abc' \
  --data vox:terms=sports \
  --data 'vox:target :=https://sbn.com/sports'

Get Backlinks

curl --request GET \
  --url 'http://localhost:5173/api/backlinks?context=chorusGroup%3A123'

Edit Backlink

curl --request POST \
  --url http://localhost:5173/api/backlinks/edit \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data '- vox:terms=baseketball' \
  --data id=uri:uuid:456

Delete Backlink

curl --request GET \
  --url 'http://localhost:5173/api/backlinks/delete?backlink=uri%3Auuid%3A123'

Get Autolinks

curl --request GET \
  --url 'http://localhost:5173/api/autolinks?context=chorusGroup%3A456&text=%22i%20love%20baseball%20also%20sports%22'

Set Context Parent

curl --request POST \
  --url http://localhost:5173/api/backlinks/edit \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data id=chorusGroup:456 \
  --data 'vox:parent :=chorusNetwork:abc'

How it Works

Create resources via form posts. Request the data for those resources via REST API. Write UI's to present that data via Svelte components.

Creating Resources with Forms

The CreateResource.svelte component shows the basics of how to use form posts to create new resources.

The forms action attribute will be the URL of the new resource. Any inputs with name attributes will be added as keys to the resource, with the associated input value.

The forms implement the RDF-KV specification for identifying relationships, scalar values, and types for those scalar values.

The TL:DR; on that spec is:

name="rdf:type :"  // value is a resource url. Creates a relationship between resources.

name="! rdf:type :"  // value is a resource url. Creates an inverted relationship between resources.

name="vox:date ^xsd:date" // sets the scalar value type to Date

Using REST

HTTP GET from a URL will return the object of that URLs data.

GET http://localhost:5173/resource

Queries

A query can be constructed by api/{key}/{value}, and will return all the objects that contain that key/val pair.

GET http://localhost:5173/api/rdf:type/<vox:Resource>
GET http://localhost:5173/api/vox:title/"SvelteKit Triplestore"

Note the "{value}" vs <{value}>. Quotes are for querying scalar values, brackets are for relationships to other objects.

encore's People

Contributors

nikolaswise avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.