Espresso Logic, illustrated via a small sample application
About this Overview
Here we use a small but representative sample application to demonstrate how Espresso Logic enables you to eliminate a significant obstacle in building and running modern mobile applications – a product category that is known as Mobile backend as a service.
Problem: Servers are hard to build
But servers are slow and complex to build, consisting of three projects shown here.
Sure, there are tools and frameworks to reduce the coding, but these are complex and time-consuming. And worse, they don’t address Business Logic and Security, which can comprise up to half the effort.
So we pose the question:
The ideal solution embraces the vision that:
Here’s how such a system might look:
- Instant Server – Deploy a server just by pointing at a SQL database, and optionally defining some custom resources
- Logic Automation – Imagine directly entering the “cocktail napkin” specification.. and it runs!
- Security Automation – Add expressions that filter rows/columns for a specified role
This would result in amazing savings of time and money, and be so simple to use that it feels like magic.
1. Instant Server
So let’s move from the ideal to the real, here examining Espresso Logic.
Since Espresso Logic is a service, there’s no installation / configuration hassles. To build a REST server, we simply sign-up with the Espresso Logic service, where we create a project and register our database connection parameters. And that’s literally all there is to it.
It’s all done through the browser, using the Logic Designer.
The initial resources are the Base Tables of the configured database.
Single-table resources are great for admin apps, but multi-table apps require services to minimize latency and support more complex screens.
Custom Multi-Table Resources
You can define Custom, Multi-Table Resources that deliver such data in a single JSON response. Simply select the tables. The system defaults the SubResource join (Customers / Orders) from the Foreign Key Constraints.
Test in REST Lab
No need to write test programs – the Logic Designer provides a REST Lab where you can send retrieval and update requests to the server, and see the JSON response, here for the Multi-Table Resource OneCustomer.
So, by just pointing at your database, and selecting a few tables, you have a complete REST API.
Test it with the REST Lab.
Client app development is fully enabled – in minutes.
3. Reactive Business Logic
Business Logic is the set of multi-table computations, validations, and actions (e.g., auditing, cloning, sending mail) performed during an update.
Why so much effort?
As much as half the app involves the Business Logic. Let’s see why by considering Place Order.
Analysis (the venerable “cocktail napkin spec” in the lower left) reveals we need to check credit – the balance cannot exceed the credit limit, where the balance is the sum of the unpaid order totals, which is the sum of the Line Item amounts, derived as the quantity times the parts’ price.
This is a nice clear requirements spec. But it represents quite a lot of business logic.
First, we must identify all the related Use Cases that must also respect these rules. If we miss one, serious bugs will result.
Each of these requires dependency management design: change detection, and propagation to dependent data. And optimizations to minimize / reduce SQLs. Pretty soon, the simple 5-line spec becomes 500 lines of code. Weeks of work to write, test, optimize, deploy, maintain, and document.
Not fast. Not simple.
11 Use Cases X Dependencies = 500 lines of code.
And yet, the requirements were so simple.
If only they were executable… that would be amazing.
And that is exactly what is provided by Reactive Business Logic. Your requirements are directly captured and enforced with automated Dependency Management. The executable cocktail napkin.
When REST updates are processed, your logic is automatically invoked, analyzed, optimized, and executed. You can imagine what this does for maintenance.
This screenshot shows all the logic required to supplant 500 lines of code. You can explore logic here.
Note especially the multi-table derivations, such as the customers’ balance. Such derivations can be chained – used in related logic (used by the credit limit check, uses the amount_total result). These are highly optimized to dramatically eliminate and simplify SQL access.
The Power of Reactive Programming
The contrast of “500 lines of code vs. 5 rules” is stark, but only part of the story:
- We solved all the Use Cases – even though we targeted only Add Order. Re-use is automatic – and so is quality.
- Our logic is unordered – the system takes care of that through logic dependency analysis. This is repeated on every change, so maintenance is simple – just change the logic.
- We did not optimize our logic – that is also the system’s responsibility. So our logic is pruned based on actual changes, and SQLs are eliminated / optimized to reduce server traffic. As for ordering, these optimizations are repeated on each change.
- Our logic is transparent – even business users can read it and spot errors / omissions. Compliance can be verified. So we finally have a common business / IT language that is both transparent documentation and maintainable implementation. A corporate asset.
For Security, you define role permissions that filter table rows and columns, based on the user profile.
This security example is defined as follows:
- Security is specified by role/table filter expressions, not code
- It is automatically applied to all requests to that table
- You can drive security from user-context data, such as values in a user-specific database row
What Just Happened
In this short overview, you’ve seen how to build a REST/JSON server for your SQL database. Your server can support mobile apps, as well as service calls from other computers – regardless of their language or architecture.
But you have far more than a server. You have a Smart Server that enforces security and complex, multi-table business logic. That means you have a safe and secure Public API.
Server creation was more a matter of specifying spreadsheet-like expressions than writing code. So, you are done in minutes rather than weeks. And you can change these expressions, with automatic activation.
Automation is the key, providing the speed and agility your business requires. And simple as a spreadsheet.
If you haven’t already signed up, this would be a great time to
sign up. Start by executing the procedures shown here for your own database.
To learn more, check out the Evaluation Guide, and the documentation.