API Logic Server
There is widespread agreement that APIs are strategic to the business, required for mobile apps and internal / external systems integration.
The problem is that they are time-consuming and costly to develop. This reduces strategic business agility.
API Logic Server provides strategic business agility, by creating an executable server for a database, instantly.
As illustrated below, the ApiLogicServer CLI
(command line interface) creates an API Logic Server,
from your database. An Api Logic Server consists of these features:
Feature | Using | Providing |
---|---|---|
1. JSON:API and Swagger | SAFRS | APIs that clients can configure to reduce network traffic |
2. Transactional Logic | Logic Bank | Spreadsheet-like Rules are 40X more concise Compare Check Credit with legacy code |
3. Basic Web App | Flask App Builder, fab-quickstart |
Instant multi-page, multi-table web app for back-office admin, and prototyping |
This declarative approach is based on standard Python tooling, and can be customized with standard approaches as described below.
Usage
pip
Install with Caution: Python install is rather more than running an installer. Use this page to Verify / Install Python.
Then, install the ApiLogicServer CLI in the usual manner:
virtualenv venv
source venv/bin/activate # windows venv\Scripts\activate
pip install ApiLogicServer
Quick Start - Create and Execute
With a single command, create and run a logic-enabled JSON:API and web app for your database:
As illustrated above, the system operates as follows:
- You run the ApiLogicServer CLI:
ApiLogicServer run # you can also create, without execution
The
db_url
parameter defaults to a supplied sample database. Specify a SQLAlchemy url to use your own database.
-
The CLI introspects your database to create and run an
api_server_project
, which consists of:-
Your API, available in Swagger
-
With underlying logic
-
And a
basic_web_app
-
Customizable Project
The ApiLogicServer CLI also created a
customizable api_server_project
Project.
After customization, your api_logic_server
project can be re-executed (without creating).
To run it:
-
Specify proper
venv
(virtual environment)- The one used for ApiLogicServer install is fine, or you can use a project-specific virtual environment
-
Then:
python api_logic_server_run.py
python ui/basic_web_app/run.py
Features
API: SAFRS JSON:API and Swagger
Your API is instantly ready to support ui and integration development, available in swagger:
Customize your API: edit
api_logic_server_run.py
, and see Customizing
Logic
Transactional business logic - multi-table derivations and constraints - is a significant portion of database systems, often nearly half. Procedural coding is time-consuming to develop and maintain, reducing business agility.
ApiLogicServer integrates Logic Bank, spreadsheet-like rules that reduce transaction logic by 40X. Logic is declared in Python (example below), and is:
-
Extensible: logic consists of rules (see below), plus standard Python code
-
Multi-table: rules like
sum
automate multi-table transactions -
Scalable: rules are pruned and optimized; for example, sums are processed as 1 row adjustment updates, rather than expensive SQL aggregate queries
-
Manageable: develop and debug your rules in IDEs, manage it in SCS systems (such as
git
) using existing procedures
The following 5 rules represent the same logic as 200 lines of Python:
Declare your logic by editing:
logic/logic_bank.py
Basic Web App - Flask Appbuilder
UI development takes time. That's a problem since
-
Such effort may not be warranted for admin "back office" screens, and
-
Agile approaches depend on getting working software soon, to drive collaboration and iteration.
ApiLogicServer CLI therefore creates working software now: multi-page, multi-table applications as shown below:
-
Multi-page: apps include 1 page per table
-
Multi-table: pages include
related_views
for each related child table, and join in parent data -
Favorite fields first: first-displayed field is "name", or
contains
"name" (configurable) -
Predictive joins: favorite field of each parent is shown (product name - not product id)
-
Ids last: such boring fields are not shown on lists, and at the end on other pages
Customize your app by editing:
ui/basic_web_app/app/views.py
Before running, you must Create Admin Data for Flask App Builder (except for Northwind, which is pre-created).
Status
Pre-Alpha / Technology Preview - just entering test.
Initially released 1/19/2021, the project is beginning to stablize:
-
The default Northwind project is working with for both the API and the web app, with pre-created logic (good to explore for examples)
-
We have tested several sqlite databases, and several MySQL databases. These are successfully creating / executing the API and the web app.
We are tracking issues in git.
Acknowledgements
Many thanks to
- Thomas Pollet, for SAFRS
- Daniel Gaspar, for Flask AppBuilder
- Achim Götz, for design collaboration
- Gloria Huber and Denny McKinney, for doc review
Articles
There are a few articles that provide some orientation to Logic Bank and Flask App Builder. These technologies are automatically created when you use ApiLogicServer:
- Extensible Rules - defining new rule types, using Python
- Declarative - exploring multi-statement declarative technology
- Automate Business Logic With Logic Bank - general introduction, discussions of extensibility, manageability and scalability
- Agile Design Automation With Logic Bank - focuses on automation, design flexibility and agile iterations
- Instant Web Apps
Change Log
02/01/2021 - 01.03.00: Fix logic logging, nw rules
01/31/2021 - 01.03.00: Resolve n:m relationships (revised models.py)
01/29/2021 - 01.02.04: Minor cleanup
01/29/2021 - 01.02.03: Flask AppBuilder fixes - Admin setup, class vs table names (wip)
01/28/2021 - 01.02.02: Command line cleanup
01/27/2021 - 01.02.00: Many
- Host option
- --from_git defaults to local directory
- hello world example
- nw rules pre-created
01/25/2021 - 01.01.01: MySQL fixes