Code Monkey home page Code Monkey logo

pinejs's Introduction

Pine.js

Pine.js is a sophisticated rules-driven API engine that enables you to define rules in a structured subset of English. Those rules are used in order for Pine.js to generate a database schema and the associated OData API. This makes it very easy to rapidly create, update and maintain a backend while keeping the logic in an easily understood form, as well as providing the ability to update and maintain this logic going forward.

Rules are described in SBVR format, which stands for "Semantics of Business Vocabulary and Business Rules". SBVR provides a way to capture specifications in natural language and represent them in formal logic, so they can be machine processed.

The basic components of SBVR are as follows:

  • Terms - these are the atomic elements of your data model, defined via Term: [Term Name]. Generally speaking, these map to tables in a relational database, or attributes of other tables.
  • Fact Types - these define relations between different terms and properties of those terms, e.g. Fact type: pilot can fly plane or Fact type: pilot is experienced - these somewhat map to fields and foreign keys in a relational database.
  • Rules - these define logical constraints on the data model and is the most powerful aspect of SBVR and Pine.js itself. Rules map loosely to constraints in a relational database, but extend them to constraints that can traverse tables and generally be far more powerful than a database constraint. E.g. Rule: It is obligatory that each pilot can fly at least 1 plane. The expressive capability of SBVR rules is much more than simple SQL DDL, and has the full power of First Order Logic.

In order to get an idea of how SBVR works, visit the sbvr lab, and for more details, check out the SBVR spec.

As part of the @balena/pinejs package the following tools are installed:

  • sbvr-compiler: Can be used to compile SBVR via the SBVR chain into SQL, eg npx sbvr-compiler test.sbvr
  • odata-compiler: Can be used to compile an OData URL via the OData chain from to SQL, eg npx odata-compiler test.sbvr /test

Both tools use some of the main dependencies of Pine.js:

  • abstract-sql-compiler
  • lf-to-abstract-sql
  • sbvr-parser
  • odata-parser
  • odata-to-abstract-sql

The above packages are written in OMeta and compiled into Javascript. The following resources consitute a good starting point in order for someone to get a better understanding of OMeta and the above dependencies:

The following papers are also helpful in understanding the main concept of Pine.js:

The documentation inside /docs folder also provide a great overview of the main concepts of Pine.js, in particular:

  • docs/Migrations.md: provides information regarding sql queries or Javascript functions that are executed prior to pinejs executing a given SBVR model.
  • docs/Hooks.md: functions that you can implement in order to execute custom code when API calls are requested.
  • docs/ProjectConfig.md: provides information regarding creating and configuring a project.
  • docs/Types.md: types definitions and declarations in various systems.
  • docs/sequence-diagrams/: provide a great overview of how the main processes are executed, including OData request parsing, response processing, etc. (The sequence diagrams can be depicted in websequencediagrams.com)

One can experiment with Pine.js, its main dependencies and the above tools inside the development environment of balena.

Where to go from here:

Start by creating your very first application with Pine.js. Jump to the Getting Started guide.

pinejs's People

Contributors

page- avatar balena-ci avatar alexwarth avatar alexandrosm avatar brianewing avatar indutny avatar veged avatar petrosagg avatar propella avatar lorenzo-stoakes avatar afitzek avatar jmike avatar dt-rush avatar izavits avatar thgreasi avatar abresas avatar roman-mazur avatar dfunckt avatar nazrhom avatar lekkas avatar shanewholloway avatar flesler avatar nv avatar pcarranzav avatar anotherquiz avatar

Watchers

James Cloos avatar  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.