Article
· May 9 3m read

Building the UI by Prompting vs InterSystems IRIS Backend: Lovable, Spec First and REST API

Hi developers!

Observing the avalanche of AI-driven and vibe-coding developer tools that have been appearing lately almost every month with more and more exciting dev features, I was puzzled whether it is possible to leverage it with InterSystems IRIS. At least to build a frontend. And the answer - yes! At least with the approach I followed.

Here is my recipe to prompt the UI vs InterSystems IRIS Backend:

  1. Have the REST API on the IRIS side, which reflects some Open API (swagger) spec.
  2. Generate the UI with any vibe-coding tool (e.g., Lovable) and point the UI to the REST API endpoint.
  3. Profit!

Here is the result of my own exercise - a 100% prompted UI vs IRIS REST API that allows to list, create, update delete entries of a persistent class (Open Exchange, frontend source, video):

What is the recipe in detail?

How to get the Open API (Swagger) spec vs IRIS backend?

I took the template with persistent class dc.Person, which contains a few simple fields: Name, Surname, Company, Age, etc.

I thought that ChatGPT could generate swagger spec but it would be shy to do it vs ObjectScript (perhaps it can now) so I generated DDL vs the class in IRIS terminal:

Do $SYSTEM.SQL.Schema.ExportDDL("dc_Sample","*","/home/irisowner/dev/data/ddl.sql")

and fed ChatGPT with the DDL + prompt:

Please create an Open API spec in JSON version 2.0 vs the following DDL which will allow to get all the entries and individual ones, create, update, delete entries. Also, add _spec endpoint with OperationId GetSpec. Please provide meaningful operation id's for all the endpoints. The DDL: CREATE TABLE dc_Sample.Person( %PUBLICROWID, Company VARCHAR(50), DOB DATE, Name VARCHAR(-1), Phone VARCHAR(-1), Title VARCHAR(50) ) GO CREATE INDEX DOBIndex ON dc_Sample.Person(DOB) GO

And it worked quite well - here is the result.

Then I used %REST command-line tool to generate rest-api backend classes.

After that, I implemented IRIS REST backend logic with ObjectScript for GET, PUT, POST, and DELETE calls. Mostly manually ;) with some help from the Co-pilot in VSCode.

Tested the REST API manually with swagger-ui and after everything was ready to build the UI:

The UI was prompted with Lovable.dev tool which I fed with the following prompt:

Please create a modern, convenient UI vs. the following open API spec, which will allow list, create, update, and delete persons { "swagger":"2.0", "info":{ "title":"Person API," "version":"1.0.0" }, .... the whole swagger spec.

After it was built and tested (manually), I asked Lovable to direct it vs the REST API endpoint in IRIS. First, locally in Docker, and after testing and fixing a few bugs (via prompts), the result was deployed.

A few caveats and lessons learned:

  • REST API security on the IRIS side is not always clear from scratch (mostly because of CORS-related topics), e.g. I needed to add a special cors.cls and modify swagger spec manually to make CORS work. 
  • Swagger documentation is not working automatically for docker in IRIS but it is fixable with special _spec endpoint and some objectscript code lines.
  • Swagger spec for IRIS should be 2.0, not the latest 3.1.

Other than that, this approach is quite an effective way for a backend IRIS developer to build comprehensive full-stack application prototypes in a very short time with zero knowledge of front-end development.

Share what you think.  And what is your "vibe" coding development experience with IRIS?

Here is the video walkthrough:

https://www.youtube.com/embed/Oo4OBfTf4d4
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

Discussion (0)1
Log in or sign up to continue