DEV Community

Cover image for Generate a CRUD API using Low-Code and No-Code
Thomas Hansen for AINIRO.IO

Posted on • Updated on • Originally published at ainiro.io

Generate a CRUD API using Low-Code and No-Code

CRUD translates to Create, Read, Update, and Delete, and is the axiom around which your data exists. If you've solved CRUD, you've "solved data".

CRUD isn't enough though. Just because you're able to handle data doesn't imply you can create an app - Even though it's a huge part of it. This is why we created workflows and actions based upon the declarative programming parts of Hyperlambda.

By combining the CRUD generator with programming, you can however create an application, entirely without coding - At least its backend parts. Watch the following video to understand what I mean.

The CRUD generator

A relational database such as the SQLite database I am wrapping in the above video contains meta data. Meta data implies "information about information", and allows Magic to retrieve information about how the database is structured. This allows Magic to read the schema from the database, and understand what tables, columns, and primary keys exists for a particular database.

Magic's CRUD generator in action

Once Magic knows the structure of your database, it can generate API endpoints for each database table, correctly handling the required arguments needed to interact with your database. Below is one example of the code it generates for one particular table and one particular CRUD verb.


// Create endpoint inserting one record into your Artist table in your chinook database taking ArtistId, Name with authentication and authorisation for root,admin roles
.arguments

   // ArtistId column value
   ArtistId:long

   // Name column value
   Name:string

// Meta data description for endpoint
.description:Create endpoint inserting one record into your Artist table in your chinook database taking ArtistId, Name with authentication and authorisation for root,admin roles

// Type of endpoint
.type:crud-create

// Verifying user is authorized to access endpoint.
auth.ticket.verify:root,admin

// Opening up database connection.
data.connect:[generic|chinook]
   database-type:sqlite

   // Parametrising our create invocation.
   add:x:./*/data.create/*/values
      get-nodes:x:@.arguments/*

   // Creating our record.
   data.create
      database-type:sqlite
      table:Artist
      return-id:bool:false
      values

   // Returning the correct status code.
   response.status.set:201

   // Returning result of above invocation to caller.
   unwrap:x:+/*
   return
      result:success
Enter fullscreen mode Exit fullscreen mode

If you have a database with 100 tables, Magic will automatically create 500 Hyperlambda files such as the above. This allows Magic to generate thousands of lines of code for you, 100% automatically, where each HTTP endpoint has the exact same structure, allowing you to easily interact with your API using standardised code constructs.

This saves you months of manual software development, while producing 1,000 times higher quality in the process

Declarative programming

Hyperlambda is a declarative programming language. A declarative programming language ignores "the how" and allows you to focus on "the what". This implies that adding business logic to your app becomes 1,000 times easier, to the point where adding business logic implies "dragging and dropping functionality on to some API endpoint."

Declarative programming with Hyper IDE to create a Stripe payment

Once you can combine generating CRUD endpoints with declarative programming, you've basically ended up with an interface where you can create any app you wish, completely without having to code. The declarative parts of Magic is still in its infancy, but as you can see in the above YouTube video, I am clearly able to add fairly complex business to my API, without having to manually code any of it.

The end result becomes.

  • 1,000 times faster Time2Market
  • 1,000 times higher quality
  • 1,000 times easier to create

Visually designing your database

With SQL Studio you can visually design your database. This brings us full circle, allowing you to start out with nothing but an idea, create your database, generate a CRUD API, for then to use declarative programming to add business logic to your API.

Software development in its traditional sense has been completely eliminated

No need to remember create table SQL statements, or fiddle with how to add columns and indexes. The database designer does this for you, 100% automatically.

Use SQL Studio to Visually Design your Database

Conclusion

There's been a lot of hype about AI stealing our jobs as software developers lately. I wrote about it yesterday, where my argument was that AI will save your job. If you don't believe me, please go to ChatGPT and tell it to create an app for you.

The punchline of the above exercise is that unless you're a software developer, you've got no idea what to even ask it. It's the same problem we've got with chess computers. If I've got a chess computer and Magnus Karlsen has a chess computer, Magnus will be able to use his chess computer to do things I cannot even imagine the same computer doing.

Every time I go to GitHub I am reminded of how CoPilot increases software development productivity by 55%. However, try giving CoPilot to your CEO and tell him to "create an app". He'd be baffled and have no idea where to even start. Simply conceptually understanding the acronyms and constructs required to phrase a prompt to the AI requires years of training and experience.

Just like AI, Magic is more of a tool than a replacement. If for nothing else than the fact of that regardless of how much code we're able to create, and how fast we're able to deliver it, there seems to be an infinite demand for more. Neither Magic nor AI will replace you as a software developer, it's just a better tool. However, just like AI, declarative programming and meta programming will result in changes. I love the following quote in regards to the issue.

AI won't replace you, a person using AI will replace you

The same is true for Magic, Hyperlambda, and declarative programming. As in, a person using said tools will replace you. There will still be a person in the equation in there somewhere. The way that person solves your problems will just change, and that's it really ...

Top comments (0)