-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added license and documentation/roadmap
- Loading branch information
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters