Business Logic Database Agent
A natural language agent to create database business logic using declarative rules: an admin web app, API, and database in 1 minute. Download to customize in your IDE.
Join the DZone community and get the full member experience.
Join For FreeIn a recent interview, Satya Nadella prophesied the "end of SaaS" with Business Logic Database Agents. The vision was exciting and broad but indefinite. And, it sparked concerns — serious ones.
In this article, we describe a definite (in fact, running) vision for such a system and how to deal with reasonable concerns raised in the comments.
A Business Logic Database Agent
The video imagines "the business logic going into the agents." The exact form of such an agent was left open. We share that vision and, in fact, have been working on it for years. This short article is our take on a Business Logic Database Agent.
The Prompt
Enter this prompt at the GenAI-Logic website:
Create a system with customers, orders, items and products. Include a notes field for orders. Use LogicBank to enforce business logic. Use case: Check Credit 1. The Customer's balance is less than the credit limit 2. The Customer's balance is the sum of the Order amount_total where date_shipped is null 3. The Order's amount_total is the sum of the Item amount 4. The Item amount is the quantity * unit_price 5. The Item unit_price is copied from the Product unit_price
Observe this is not a “FrankenPrompt” that requires an in-depth programming language or framework background. It’s simply your intent.
The Result: Running Database, API, Web App… and Logic
In about a minute, the system creates a running system:
- Database with test data
- A JSON:API — multi-table, with filtering, sorting, optimistic locking, pagination, and OpenAPI doc
- An admin web app, so you can explore the system. It’s a multi-page app with master-detail, navigation for related data, etc. Here’s a screenshot:
You can iterate this (e.g., add more tables/attributes, rename them, etc).
More About Logic
The numbered items are the business logic that Nadella spoke about. Such logic addresses:
- Multi-table derivations and constraints — these enforce database integrity. This is well beyond familiar support for valid values, null-allowed, etc.
- Security — authorization and role-based access control
- Enterprise integration (send the order to shipping on Kafka, email the customer)
We believe our approach is unique. Instead of "your code goes here," this approach provides:
- Natural language specification, of...
- Declarative business rules
As Nadella explains, such logic is critical. In fact, for a traditional interactive system, it’s nearly half the effort.
If this were coded in Java or Python, it would require 200 lines of code instead of these five rules. That’s a 40x reduction for the backend half of the system.
If that sounds hard to believe, consider using a procedural language instead of a spreadsheet. You’d see exactly the same explosion of code since declarative automates all your dependency management, optimized data access, transaction management, and logic ordering.
To put it another way, declarative automates re-use. The rules above, perhaps conceived for adding orders, automate nearly a dozen use cases… without error. For example:
- If the user selects a different product, the system uses its price to re-price the order and check the credit.
- If the order were assigned to a different customer, one account would be decreased, and the other increased.
Quite a Kickstart
You go from idea to running in one minute. Then iterate. No database design, no screen painting.
If that’s all there was, it would be a wonderful way to drive the Agile Manifesto: engage business users — with working software — to collaborate and iterate to get the requirements right.
Concerns: Autopilot vs. Copilot
The article got a lot of push-back ("There’s always some odd requirement," "Trust AI with corporate database integrity?"). Quite a lot of push-back.
And they’re absolutely right. The idea that an agent can be an autopilot — just provide a few rules, and it takes over — is indeed losing all control.
And it’s unnecessary. With the proper engineering, you can achieve extensible automation:
- Automate what makes sense without ceding control to AI
- Enable customizations using standard languages and tools
So, more of a copilot — takes on certain tasks, but the pilot can take the yoke whenever necessary. For example, the screenshot below shows what happened to our declarative rules:
Standard Dev/Database/Deploy Tooling
It’s a standard Python project. Download it, and use your favorite Dev Tools (IDE, debugger, source control, etc). Use the API with your favorite approaches for custom apps: create UI agents, use Low Code screen painters, traditional UI frameworks, or even the new breed of GenAI-driven UI. Custom App Dev is dramatically simplified, since the API encapsulates the declarative logic.
The created systems use standard relational databases.
Projects include scripts for creating docker images. Use your favorite deployment tools.
The AI elements are not used for project execution, so your corporate data is not subject to the dreaded hallucination.
Rules, Not FrankenCode
And the logic? It stayed declarative!
The system did not generate 200 lines of code. It leverages a powerful rules engine, accessed using Python as a Domain Systems Language. It’s the same five lines, just in Python syntax.
GenAI and FrankenCode
You might reasonably wonder — can existing GenAI services build the logic? Why is GenAI-Logic in the loop?
So, we tried "native GenAI" — it was:
- Incorrect: It missed many of the corner cases above (more details here).
- Inefficient: It generated code that would run many orders of magnitude slower due to excessive SQL aggregate queries (more details here).
- Undesirable: The 200 lines of generated code are exactly what developers hate: FrankenCode, which is hard to understand, debug, and extend.
If the goal is ultimately business transformation, it requires broad adoption across the enterprise — including developers. We believe that a business logic (rules) engine is critical in maintaining a level of abstraction that is transparent and maintainable (for more information, click here).
The Power of Suggestion
The notion of copilot — not autopilot — can be taken one step further. The system provides facilities to suggest logic. Always under developer control, to accept, reject, or modify:
This makes the agent substantially more accessible. Instead of being a passive robot, the agent can help you learn rules, and trigger your creativity about features you might not have thought about.
More Business Transformation, Less Stress
The industry has long dealt with the stress between:
- Speed: Accelerate business transformation by enabling line of business users with tools like Low Code, Microsoft Access, etc
- Governance: IT delivers value by leveraging enterprise-class technology for quality of service, security, performance, integration, etc.
The stress arises since the LOB-focused software may use non-standard databases, might preclude standard dev/deployment tools, etc. This can lead to LOB/IT organizational conflict, the need to support multiple technologies, etc.
The Business Logic Database Agent can reduce this stress: LOB users can kickstart projects even more simply (no database design, no screen painters) yet create projects that can be smoothly transitioned to IT as needs dictate.
It’s Available Now
The realization of Business Logic Database Agents is available now. It’s open source and free on our website: Genai-Logic.
Opinions expressed by DZone contributors are their own.
Comments