Web GenAI Microservices Creation: An Overview
Create and run a microservice, with a simple prompt from your browser. Download and customize the system in your IDE with rules and Python, all open source!
Join the DZone community and get the full member experience.
Join For Free- This article will show you how to use GenAI from your browser to create and run a microservice in about a minute. Here is what you'll learn:
- Provide a prompt to a cloud-based microservice appliance, and you get a system with a running database, a web app, and an API.
- Collaborate with stakeholders using the web app.
- Iterate instantly, to get the requirements right.
- Download the created project, and customize it in your IDE to build out the system using Python and Rules — 40x more concise than code.
All of this is open source. No runtime or license fees.
Microservices Creation: Get the Requirements Right
We've all seen many projects fail due to difficulties in getting the requirements right. Let's explore that.
Catch 22: Screens Best for Collaboration, But Available Too Late
A common — and frustrating — project experience is:
- Weeks (or months) to get running screens
- Then — after all that investment — stakeholders explore the screens, revealing that the requirements were misunderstood.
So, how do we get the screens — in moments — to collaborate and iterate, to get the requirements right?
Introducing Web GenAI Automation Services
GenAI technology has enabled an exciting new class of software to address this. Products are accessed via your browser and are able to create complete running systems from a natural language prompt. Let's look at one example: Web/GenAI.
Web/GenAI: Get Working Screens Instantly from a Prompt
Web/GenAI creates complete running systems from a prompt. It works like this:
- Create by providing a prompt, right in your Browser. The system creates the microservice in a minute or so.
- Runthe microservice.
- A database, a web app, and an API
- No database definition needed, no framework complexity, not even any screen painting
- It's live on the web - stakeholders can collaborate and review the app and API
- Contrast this to wireframes, which provide little insight into the actual data and its behavior
- Iterate in just a minute. Rename tables, add new tables, change attributes, all while retaining what you have.
- It's not just a wizard - you have a standard project you can download and customize in your IDE, using Python and Rules (described below).
- A database, a web app, and an API
To see it in action, play the video above. Or, run it yourself (link at end).
All that's needed is one minute to create running screens -
collaborate and iterate
to get the requirements right.
Enterprise Class API
The standard JSON:API is enterprise class - multi-table, filtering sorting, pagination, and optimistic locking. Explore it with automatically created Swagger.
Development of a Standard, Fully Customizable Project
Web GenAI may be fast and simple, but it's far more than a wizard. You also get a fully executable project you can download, and customize in your IDE using Python and Rules.
Automation can also reduce architectural risk. For example, using a manual framework does not ensure aspects such as APIs that provide pagination, optimistic locking, and logic sharing (further discussed below). An automated approach can/should provide these.
The basic process is shown in the thumbnail diagram below:
- Inception phase: use Web GenAI to get the requirements right, as described above
- Backend development in your IDE, using Python and Rules, further described below
Architecture
Speed is great, but architecture matters. Let's take a quick look under the hood of how projects are created, developed, and ran.
1. Creation: ChatGPT, API Logic Server
When you provide your prompt, the system:
- Invokes ChatGPT to compute a data model
- Invokes API Logic Server to create and run an executable Python project from a data model, or an existing database (see references, at end).
Not a FrankenPrompt or low level technical instructions
that require deep framework understanding.
Web GenAI prompts are simple business-level requirements.
2. Development: Your IDE, Code-Based, Models
You can download the created project and customize it in your IDE. And/or, use CodeSpaces, a browser-based version of the popular VSCode IDE.
Your project is completely represented as code. There is a not a formal repository stored as a database or markup files. That means you can use your IDE to debug and manage your project. For example, see below how logic is entered in Python, as a DSL.
The resultant project is not a massive amount of code that is hard to understand and customize. Rather, it is a set of models that are clear and concise. For example,
- the API is not code - it is simply a list of data models
- the Admin App is not complex HTML and JavaScript - it is a JSON file listing entities and attributes
Models, represented as code,
are easier to manage, debug, understand, and modify.
3. Runtime: Standard 3-Tiered, API-Driven, Container-Based
Clients access the system via the JSON:API, described above. More than access, the API enforces the semantics of your data - the business logic that governs security, and integrity (multi-table derivations and constraints) with automatic transaction bracketing.
The server executes as a container, accessing the database(s) as required. Containers are share-nothing, providing scalability.
Backend Development: Your IDE, Python, and Rules
Let's now see how you add logic in your IDE, using Python and Rules.
Python
The Python code below illustrates how you can add business logic to format and send Kafka messages for internal application integration. Use your IDE to enter the code, debug it, and manage your source control. Leverage external packages as required - it's a standard Python project.
This combines the speed and simplicity of AI, with the flexibility of a framework.
Rules Enforce Security and Integrity
A rules engine is provided to automate backend business logic. This is a substantial part of any project - typically nearly half.
Rules address:
- Row-level security based on user roles (e.g., use Keycloak for Single Sign-on), and
- Multi-table Derivations and Constraints (with automatic transaction bracketing)
The following rules govern entering and altering orders to enforce the Credit Limit check:
These 5 rules represent the same logic as 200 lines of code.
Maintenance Automation
While conciseness is perhaps the most salient point, rules provide substantial value in maintenance. Maintenance often seems to be a matter of archaeology - you spend most of your time reading existing code to figure out where to insert your new code, so that it always called, and in the correct order.
Rules automate that.
The rules engine plugs into SQLAlchemy events, and monitors updates at the attribute level. Rules that don't apply are pruned. Rules that do apply are executed in an order that respects their system-discovered dependencies. This results in:
- Your ability to insert new rules anywhere in your code.
- The system will ensure they are called, and in the correct order.
Unlike Rete engines and some ORMs, rules are highly optimized to eliminate expensive (and often chained) aggregate queries. In the example above, a new Order makes 1 update to Customer, without reading all the existing Orders and OrderDetails to compute the new Balance.
While the GenAI Automation is exciting, you just might conclude it's "come for creation, stay for the rules."
Front End Development
We do not contend that the automatically created app is a customer-facing app.
This approach is to leverage your existing UI dev tools such as UI frameworks or low code screen painters, by automating the API. In addition to existing UI Dev tools, please explore automation support for Ontimize.
That said, it's worth noting the value that a robust backend can provide to front-end dev:
- An instant API unblocks UI dev, which is often delayed until the end of the project.
- Server-enforced declarative logic averts one of the most serious architectural error, placing critical business logic in UI buttons (controllers). This blocks sharing logic between UI apps, and headless services.
Open Deployment
Created projects include scripts to automate docker creation, so you can deploy on your own infrastructure. To try out your own Web GenAI prompt creation, click here.
In summary, if you provide a natural language prompt, and you'll get:
- A running microservice: Database, API and app, all for collaboration and iteration, to get the requirements right
- A project: download and customize in your IDE with Python and Rules
- Deploy as a container in your preferred infrastructure
You can begin collaborating with business users, and extending the project in your IDE.
Published at DZone with permission of Val Huber, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments