How Magic works

Magic is a CRUD backend generator that will scaffold up HTTP REST endpoints for you, wrapping your database “automagically”. This allows you to point it towards an existing database, click a button, and end up with every single CRUD operation towards every single table in your database. Behind the scenes, Magic will read the meta data from your database, and create one code file for every single CRUD operation in your database. These code files will contain “Hyperlambda” code. Magic supports both MySQL and Microsoft SQL Server databases, and is built on top of .Net Core and C#. Most of its source code is publicly available online.

Hyperlambda is my own programming language, inspired by YAML, that allows you to create functionality in a more “declarative way” than traditional programming. In fact, if you look at any of the Hyperlambda files that Magic creates, they will resemble “configuration files” more than for instance C#. However, have no doubts, Hyperlambda is 100% perfectly Turing complete, and actually a “real” programming language, albeit a bit “simple” in its syntax. For instance, Hyperlambda have no classes, no OO, and none of the complex and advanced structures that more “hardcore” programming languages contains, such as C# or Java. In a way, Hyperlambda is a super scalable DSL, as easily understood and extended as FoxPro or Clipper from the old days of 4th generation programming languages – But of course 100 times as scalable as both FoxPro and Clipper were. Hyperlambda sits as a tiny layer in between your HTTP REST endpoint, and the C# code that Magic is built with. Hence, for Magic, Hyperlambda is an “orchestration programming language with DSL qualities”.

Magic also contains a “routing controller” which is a plain C# controller class, that accepts “any URL”. This component will map URLs and HTTP verbs to files physically existing in your Magic installation – Some of whom are the results of the CRUDify operations you have performed on your databases. This combination between having physical files representing each endpoint, and using Hyperlambda to “declare” the endpoints functionality, allows Magic to know a lot of meta information about its own capabilities. You can see this in action after you have CRUDified your tables, and you click the “Endpoints” menu item, to look at your endpoints. This results in that Magic produces a very friendly API, arguably inspired by the Open Web API initiative, that allows you to “see” into your server, and understand what Magic is capable of doing – Without risking creating security holes, etc. Each endpoint can be secured through mechanisms of authorisation and authentication, forcing the client that invokes your endpoint, to belong to some pre-defined role to allow him or her access to execute the code in the endpoint. Internally, Magic is using JWT security tokens to authenticate and authorise its clients.

The end results of this, becomes that you can create 4662 lines of code, and 888 code files, wrapping a database with 222 tables into all CRUD operations, securely – In no more than 40 seconds. Which is what I am doing in the video below.

Notice, scaffolding endpoints and creating CRUD endpoints from your database, does not even interrupt normal usage of the existing backend – And could in theory be done on your production server, without interrupting normal usage. An analogy for this process would be repairing the wings of an airplane, during its flight, without risk of crashing.

Extending Magic with your own functionality, is easy, since the whole thing is created in C#. So you can easily mix Magic with as much C# code as you wish, in addition to creating your own “keywords” for Hyperlambda, by looking at how the existing keywords are implemented, in components such as magic.lambda. However, you don’t really need to understand Hyperlambda at all in order to use Magic – Because it was created more to be understood by the computer, than to be understood by the software developer. In a way, Hyperlambda serves the same function to Magic as IL code or Assembly code serves to C# and C++. So hence, arguably, there is little or no new knowledge required to start using Magic in your own solution – Beyond being able to modify a connection string, compiling your Angular frontend, and C# backend, and literally clicking a button. Clicking that button of course, often results in saving you for hundreds and sometimes thousands of hours of work – Which is its purpose.

That’s why I chose to name it Magic, because you don’t need to understand how it works to take advantage of it. You can simply take advantage of that something else understands how it works (your computer), for then to take advantage of your computer’s ability to make you fly, kind of like you probably don’t understands how a Boing 747 works – But you can still fly. And that’s Magic!

If you’re still interested in its technical details, and you feel you have to understand its internals, 98% of its source code is publicly available online by following my GitHub account. Magic will cost your company €495 for each server you want to run it on. You can obtain a license to run Magic here.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.