Nucleoid: A Low-code Framework for Node.js

Written by canmingir | Published 2022/08/09
Tech Story Tags: nodejs | javascript | low-code | backend | javascript-frameworks | javascript-development | software-development | software-engineering

TLDRNucleoid low-code framework lets you build your APIs with the help of AI and a built-in datastore. As writing just like any other codes in Node.js, AI inside the runtime rerenders the very same JavaScript codes and makes the necessary adjustments in the state as well as stores them on the disk so that your application doesn't require an external database or anything else. The main objective of the project is to manage both data and logic under the same runtime, at the same time, we can also stream/export data to an external databases like NoSQL.via the TL;DR App

We've launched a project that it can automate data and logic in Node.js so that it can organically reduce your code lines.

Nucleoid Low-code Framework works with an underlying declarative runtime environment that re-renders the very same JavaScript codes that make connections in the graph and eventually save the JavaScript state so that it doesn't require an external database.

Features

  • šŸ‘½ lets developers build APIs with the help of AI (Lots of Graphs)
  • ā¤ works with the underlying declarative runtime environment
  • šŸ¤˜ the runtime also comes with a built-in datastore

Hello World

> npm i nucleoidjs

Once installed, you can simply run with Express.js

const nucleoid = require("nucleoidjs");
const app = nucleoid();

class User {
  constructor(name) {
    this.name = name;
  }
}

// šŸ‘‡ This is it!
app.post("/users", () => {
  new User("Daphne");
});

app.listen(3000);

This is pretty much it, thanks to AI in the runtime, only with this šŸ‘†, you successfully persisted your first object without an external database. šŸ˜Ž

Theory

Applying declarative programming at the runtime gives us ability to include data management in the same process.

In different words, the main objective of the project is to manage both data and logic under the same runtime, at the same time, we can also stream/export data to an external database like NoSQL.

CRUD

Quick Setup

const nucleoid = require("nucleoidjs"); // npm install nucleoidjs
const app = nucleoid();

Create

let's start with creatingĀ UserĀ class and its first user object with this šŸ‘‡

class User {
  constructor(name) {
    this.name = name;
  }
}

nucleoid.register(User);

app.post("/users", (req) => {
  const name = req.body.name;
  return new User(name);
});

šŸŒµĀ The reason why you don't need an external databaseĀ is Nucleoid runtime manages and stores JavaScript state. Every time when there are statements run through the runtime, the Nucleoid runtime adjusts the AI graph and stores it within runtime-managedĀ fs.

Read

app.get("/users/:id", (req) => {
  const id = req.params.id;
  return User[id];
});

When a class likeĀ UserĀ registered, the runtime createsĀ a shortcut arrayĀ for its instances, you can query or use the id (varĀ name) of the instance for the access later down. Alternatively, you can do like this tooĀ User.find(user => user.id === id)

Update & Delete

app.post("/users/:id", (req) => {
  const id = req.params.id;
  const name = req.body.name;

  const user = User[id];

  if (user) {
    user.name = name;
    return user;
  }
});

app.delete("/users/:id", (req) => {
  const id = req.params.id;
  delete User[id];
});

Similar to the examples above, it works with vanilla JavaScript, and the runtime re-renders and manages the JavaScript state. Additionally, you can write up some business logic in JavaScript as well. For example, you may sayĀ if (user.name.length < 3) { throws "INVALID_USER" }Ā if you want certain limitations on users' names.

Query

nucleoidjsĀ the package also opens up a terminal channel in order to run statements like SQL

How it works

nucleoid.run(() => {
  var a = 1;
  var b = a + 2;
  var c = b + 3;
});

Once a variable is defined likeĀ var a = 1, the runtime does 3 major things. First, it places theĀ var aĀ in the graph and makes the connection between dependent variables.

Second, update the state with new values in order to get affected

However, the actual execution is different since variables are tracked in the graph.

state.a = 1;
state.b = state.a + 2;
state.c = state.b + 3;

and finally stores statements in the runtime-managedĀ fs.

OpenAPI Integration with Nucleoid IDE

We are also building an online OpenAPI editor that helps to build up the very same APIs with the user interface. It is specially designed for OpenAPI integration and also has a connection to CodeSandbox so that you can easily run your projects on the sandbox.


Thanks to declarative programming, we have a brand-new approach to data and logic. As we are still discovering what we can do with this powerful programming model, please join us with any type of contribution!

Learn more atĀ https://github.com/NucleoidJS/Nucleoid


Written by canmingir | Contributor at Nucleoid
Published by HackerNoon on 2022/08/09