Skip to content

Commit

Permalink
added license and documentation/roadmap
Browse files Browse the repository at this point in the history
  • Loading branch information
poef committed Jan 5, 2023
1 parent 29c87a1 commit 93cfe2f
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Muze

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# JSONTag REST Server

[JSONTag](https://github.com/poef/jsontag) is an enhancement over JSON that allows you to tag JSON data with metadata using HTML-like tags. This application is a prototype REST-like server using JSONTag, mostly to testdrive JSONTag and what applications using it would look like.

## Installation

JSONTag-rest-server is a Node application. Start it by downloading this git repository:

```shell
git clone [email protected]:poef/jsontag-rest-server
```

Then install its dependencies:

```shell
cd jsontag-rest-server
npm install
```

And start it up:

```shell
npm start
```

The server comes with a small demo dataset, which you can take a look at here `http://localhost:3000/`:

This page will show this:

```
{
"persons":<link>"persons/"
}
```

By following the link to `http://localhost:3000/persons/` you get:

```
[
<object class="Person">{
"name":"John",
"dob":<date>"1972-09-20"
},
<object class="Person">{
"name":"Jane",
"dob":<date>"1986-01-01"
}
]
```

## Goals of this project

JSONTag is an experiment, this server is part of that. The idea is to see if we can create a more defined and usable REST like service, out of the box. One where all you need to do is change the data and add some access rights and get a self-describing, browseable, working API.

## Design

The current version is just a readonly API. The next version will allow you to update the data. It will use a CQRS (Command-Query-Responsibility-Segragation) approach.

The Query part will use the url path as a JSON Pointer, just like the current version. It will also add a graphql-like query feature. Eventually this will support a JSONTag selector, similar to CSS Selectors, combined with JSON Pointer abilities.

The Command part will have a seperate single entry point, with a predefined set of default commands to get a CRUD like experience. Commands will always be processed sequentially. Commands are appended to a command log.

A command can change the dataset, but only by creating new entities. The dataset is immutable. This makes it possible to do atomic updates. Each dataset has a single root entity. A command can create a new dataset root entity, which links to new entities or existing entities. This way the atomic update is done by switching the root entity for the dataset for both the next Command and Queries.

Then the server will update a on-disk backup of the current state at specific times, to be determined.

Next the server can start multiple Query processes using the same dataset using shared memory, since they are immutable. When the dataset root is changed, old query processes are killed of (after processing their last request) and replaced with new query processes using the new dataset root.

This should make the whole system ACID compliant. The atomic switching of the dataset root and immutable nature of the dataset makes sure that each query is always resolved using an internally consistent dataset. The sequential processing of the commands makes sure that there are no possible race conditions.

## Roadmap

- immutable dataset
- allow changes to dataset by creating a new root
- command handling with crud commands and command log
- backup current dataset to JSONTag file
- on startup check if any commands in the log haven't been resolved, if so run them

- improved web client with type-specific views and form elements

- Graphql query support (query only)
- JSONTag-selector implementation and design
- merging JSONTag-selector with Graphql queries
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "JSONTag REST Server",
"scripts": {
"start": "node src/main.mjs"
},
"dependencies": {
"@muze-nl/jsontag": "^0.4.2",
"express": "^4.18.1",
Expand Down

0 comments on commit 93cfe2f

Please sign in to comment.