Generate a CRUD API using Low-Code and No-Code
Tags: lowcode, productivity, ai
Published: 2024-01-19 07:14:12

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](https://docs.ainiro.io/workflows/) based upon the declarative programming parts of [Hyperlambda](https://docs.ainiro.io/hyperlambda/).

By combining the [CRUD generator](https://docs.ainiro.io/dashboard/endpoint-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.

{% embed https://www.youtube.com/watch?v=6ynhajh75cM %}

## The CRUD generator

A relational database such as the [SQLite](https://www.sqlite.org/index.html) 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](https://ainiro.io/assets/images/blog/crud-generator.jpeg)

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
```

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](https://ainiro.io/blog/hyper-ide-using-no-code-and-no-code-to-generate-software). 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](https://ainiro.io/assets/images/blog/declarative-programming-with-hyper-ide.jpeg)

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](https://ainiro.io/blog/sql-studio-visually-designing-your-database) 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](https://ainiro.io/assets/images/blog/sql-studio-visually-design-your-database.jpeg)

## Conclusion

There's been a lot of hype about AI stealing our jobs as software developers lately. I [wrote about it yesterday](https://ainiro.io/blog/ai-cannot-steal-your-job), where my argument was that AI will _save_ your job. If you don't believe me, please go to [ChatGPT](https://chat.openai.com) 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](https://github.com) 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 ...