ApiLogicServer 14.5.3__py3-none-any.whl → 14.5.14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. api_logic_server_cli/api_logic_server.py +4 -122
  2. api_logic_server_cli/api_logic_server_info.yaml +3 -3
  3. api_logic_server_cli/create_from_model/__pycache__/api_logic_server_utils.cpython-312.pyc +0 -0
  4. api_logic_server_cli/create_from_model/__pycache__/dbml.cpython-312.pyc +0 -0
  5. api_logic_server_cli/create_from_model/api_logic_server_utils.py +29 -10
  6. api_logic_server_cli/create_from_model/dbml.py +16 -9
  7. api_logic_server_cli/database/basic_demo.sqlite +0 -0
  8. api_logic_server_cli/genai/genai.py +4 -0
  9. api_logic_server_cli/genai/genai_svcs.py +10 -2
  10. api_logic_server_cli/manager.py +3 -1
  11. api_logic_server_cli/prototypes/base/.vscode/launch.json +40 -0
  12. api_logic_server_cli/prototypes/base/api/api_discovery/mcp_discovery.py +58 -0
  13. api_logic_server_cli/prototypes/base/database/system/SAFRSBaseX.py +68 -2
  14. api_logic_server_cli/prototypes/base/database/system/SAFRSBaseX.pyZ +73 -0
  15. api_logic_server_cli/prototypes/{basic_demo/customizations/integration → base/integration/mcp}/.DS_Store +0 -0
  16. api_logic_server_cli/prototypes/base/integration/mcp/README_mcp.md +15 -0
  17. api_logic_server_cli/prototypes/base/integration/mcp/mcp_client_executor.py +296 -0
  18. api_logic_server_cli/prototypes/base/integration/mcp/mcp_schema.txt +47 -0
  19. api_logic_server_cli/prototypes/base/integration/mcp/mcp_server_discovery.json +9 -0
  20. api_logic_server_cli/prototypes/base/integration/mcp/test_notes.txt +37 -0
  21. api_logic_server_cli/prototypes/basic_demo/README.md +251 -91
  22. api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/mcp_discovery.py +1 -44
  23. api_logic_server_cli/prototypes/basic_demo/customizations/database/db.sqlite +0 -0
  24. api_logic_server_cli/prototypes/basic_demo/customizations/database/models.py +27 -12
  25. api_logic_server_cli/prototypes/basic_demo/customizations/database/system/SAFRSBaseX.py +5 -2
  26. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/Zmcp_client_executor.py +294 -0
  27. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_tool_context.json +25 -0
  28. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/test_notes.txt +37 -0
  29. api_logic_server_cli/prototypes/basic_demo/customizations/logic/declare_logic.py +1 -20
  30. api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/email_request.py +47 -0
  31. api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/mcp_client_executor_request.py +320 -0
  32. api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/simple_constraints.py +25 -0
  33. api_logic_server_cli/prototypes/basic_demo/customizations/ui/admin/admin.yaml +39 -32
  34. api_logic_server_cli/prototypes/basic_demo/iteration/database/db.sqlite +0 -0
  35. api_logic_server_cli/prototypes/basic_demo/iteration/ui/admin/admin.yaml +39 -44
  36. api_logic_server_cli/prototypes/manager/.vscode/launch.json +21 -0
  37. api_logic_server_cli/prototypes/manager/{README.md → READMEz.md} +4 -4
  38. api_logic_server_cli/prototypes/manager/REAMDE.md +1057 -0
  39. api_logic_server_cli/prototypes/manager/system/genai/mcp_learning/mcp.prompt +27 -0
  40. api_logic_server_cli/prototypes/manager/system/install-ApiLogicServer-dev/install-ApiLogicServer-dev.sh +2 -1
  41. {apilogicserver-14.5.3.dist-info → apilogicserver-14.5.14.dist-info}/METADATA +1 -1
  42. {apilogicserver-14.5.3.dist-info → apilogicserver-14.5.14.dist-info}/RECORD +46 -42
  43. {apilogicserver-14.5.3.dist-info → apilogicserver-14.5.14.dist-info}/WHEEL +1 -1
  44. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_client_executor.py +0 -350
  45. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/3_executor_test_agent.py +0 -52
  46. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/README_functon.md +0 -201
  47. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/ai_plugin.json +0 -17
  48. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/nw-swagger_3.json +0 -1731
  49. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/snippets.txt +0 -5
  50. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3 genai_demo_with_get.json +0 -1731
  51. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3.json +0 -1782
  52. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3_genai_demo.json +0 -264
  53. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3_genai_demo_with_update.json +0 -1782
  54. api_logic_server_cli/prototypes/genai_demo/logic/logic_discovery/auto_discovery.py +0 -52
  55. {apilogicserver-14.5.3.dist-info → apilogicserver-14.5.14.dist-info}/entry_points.txt +0 -0
  56. {apilogicserver-14.5.3.dist-info → apilogicserver-14.5.14.dist-info}/licenses/LICENSE +0 -0
  57. {apilogicserver-14.5.3.dist-info → apilogicserver-14.5.14.dist-info}/top_level.txt +0 -0
@@ -1,34 +1,38 @@
1
1
  ---
2
2
  title: Instant Microservices - with Logic and Security
3
3
  notes: gold is proto (-- doc); alert for apostrophe
4
- version: 0.7 from pip
4
+ version: 0.21 from pip
5
5
  ---
6
6
 
7
7
  See how to build a complete database system -- in minutes instead of weeks or months:
8
8
 
9
9
  1. **An API**, and, we'll add ui and logic to make it a microservice...
10
- 2. **Logic and Security:** multi-table constraints and derivations, and role-based security
11
- 3. **An Admin App:** and finally, a multi-page, multi-table web app
10
+ 2. **Logic and Security:** multi-table constraints and derivations, role-based security, and application integration
11
+ 3. **An Admin App:** a multi-page, multi-table web app
12
+ 4. **Customizable:** use your IDE to customize with declarative rules and standard Python
12
13
 
13
- We'll use API Logic Server (open source), providing:
14
+  
14
15
 
15
- | Key Feature | Providing | Why It Matters |
16
- | :---------------- | :------------------------------------------------------------------ | :-------------------------------------------------- |
17
- | **Automation** | Instant Project Creation:<br>An API and an Admin web app | Unblock UI App Dev<br>Instant Agile Collaboration |
18
- | **Customization** | Declarative logic and security <br> 5 rules vs. 200 lines of Python | 40X less backend code |
19
- | **Iteration** | Revising the data model, and <br>Adding rules plus Python | Iterative development <br> Extensiblity with Python |
16
+ We'll illustrate [API Logic Server](https://www.genai-logic.com/product/key-features){:target="_blank" rel="noopener"} basic GenAI-Logic operation: creating projects from new or existing databases, adding logic and security, and customizing your project using your IDE and Python.
20
17
 
21
- The entire process takes 10 minutes, instead of several weeks using traditional development.
18
+ The entire process takes 20 minutes, instead of several weeks using traditional development.
22
19
 
23
20
  You can use this article in several ways:
24
21
 
25
- - Conceptual Overview - focus on the basic process. Operational details are moved to the Appendix to retain focus on the concepts.
26
- - Self-demo - you can create this system yourself.
27
- - Self-demo with video - you can also use [this video](https://www.youtube.com/watch?v=sD6RFp8S6Fg) (it's the same system, but the database is created with ChatGPT).
22
+ * Conceptual Overview - the main article focuses on the concepts and basic process. Operational details are moved to the Appendix to retain focus.
23
+
24
+ * Self-demo - [install](Install-Express.md){:target="_blank" rel="noopener"} and create this system yourself.
25
+
26
+ * Self-demo with video - you can also use [this video](https://www.youtube.com/watch?v=sD6RFp8S6Fg) (it's the same system, but the database is created with ChatGPT).
28
27
 
29
28
  &nbsp;
30
29
 
31
- ## 1. Automation: Instant Project
30
+ ## 1. Automation: Project Creation
31
+
32
+ API Logic Server can create projects from existing databases, or use GenAI to create projects with new databases. See the sub-sections below.
33
+
34
+ &nbsp;
35
+ ### Create From Existing Database
32
36
 
33
37
  This project was created with a command like:
34
38
 
@@ -36,41 +40,78 @@ This project was created with a command like:
36
40
  $ ApiLogicServer create --project_name=basic_demo --db_url=basic_demo
37
41
  ```
38
42
 
39
- > Note: the `db_url` value is [an abbreviation](https://apilogicserver.github.io/Docs/Data-Model-Examples/). You would normally supply a SQLAlchemy URI.
43
+ > Note: the `db_url` value is [an abbreviation](https://apilogicserver.github.io/Docs/Data-Model-Examples/){:target="_blank" rel="noopener"} for a test database provided as part of the installation. You would normally supply a SQLAlchemy URI to your existing database.
40
44
 
41
- This creates a project by reading your schema. The database is Customer, Orders, Items and Product, as shown in the Appendix.
45
+ This creates a project by reading your schema. The database is Customer, Orders, Items and Product, as shown in the Appendix.
46
+
47
+ &nbsp;
48
+
49
+ ### Create With New Database
50
+
51
+ You can create a project from a prompt using GenAI, either by [WebGenAI](WebGenAI.md), or the the [GenAI CLI](WebGenAI-CLI.md){:target="_blank" rel="noopener"} as shown here.
52
+
53
+ Use the GenAI CLI with or without signup:
54
+
55
+ 1. If you have signed up (see *Obtain a OpenAI API Key*, below), this will create and open a project called `genai_demo` from `genai_demo.prompt` (available in left Explorer pane):
56
+
57
+ ```bash
58
+ als genai --using=system/genai/examples/genai_demo/genai_demo.prompt --project-name=genai_demo
59
+ ```
60
+
61
+
62
+
63
+ 2. ***Or,*** you can simulate the process (no signup) using:
64
+
65
+ ```bash
66
+
67
+ als genai --repaired-response=system/genai/examples/genai_demo/genai_demo.response_example --project-name=genai_demo
68
+
69
+ ```
70
+
71
+ &nbsp;
72
+ ### Open in your IDE and Run
42
73
 
43
74
  You can open with VSCode, and run it as follows:
44
75
 
45
76
  1. **Create Virtual Environment:** as shown in the Appendix.
77
+
46
78
  2. **Start the Server:** F5 (also described in the Appendix).
79
+
47
80
  3. **Start the Admin App:** either use the links provided in the IDE console, or click [http://localhost:5656/](http://localhost:5656/). The screen shown below should appear in your Browser.
48
81
 
49
82
  The sections below explore the system that has been created (which would be similar for your own database).
83
+ <br><br>
50
84
 
51
- &nbsp;
85
+ !!! pied-piper ":bulb: Automation: Instant API, Admin App (enable UI dev, agile collaboration)"
86
+
87
+ ### a. API with Swagger
88
+
89
+ The system creates an API with end points for each table, with filtering, sorting, pagination, optimistic locking and related data access -- **[self-serve](https://apilogicserver.github.io/Docs/API-Self-Serve/), ready for custom app dev.**
52
90
 
53
- ### API with Swagger
91
+ <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/api-swagger.jpeg?raw=true">
54
92
 
55
- The system creates an API with end points for each table, with filtering, sorting, pagination, optimistic locking and related data access -- **[self-serve](https://apilogicserver.github.io/Docs/API-Self-Serve/), ready for custom app dev.**
93
+ ### b. Admin App
56
94
 
57
- ![api-swagger](https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/api-swagger.jpeg?raw=true)
95
+ It also creates an Admin App: multi-page, multi-table -- ready for **[business user agile collaboration](https://apilogicserver.github.io/Docs/Tech-AI/),** and back office data maintenance. This complements custom UIs created with the API.
58
96
 
59
- ### Admin App
97
+ You can click Customer 2, and see their Orders, and Items.
60
98
 
61
- It also creates an Admin App: multi-page, multi-table apps -- ready for **[business user agile collaboration](https://apilogicserver.github.io/Docs/Tech-AI/),** and back office data maintenance. This complements custom UIs created with the API.
99
+ <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/admin-app-initial.jpeg?raw=true">
62
100
 
63
- You can click Customer 2, see their Orders, and Items.
101
+ &nbsp;
102
+
103
+ ## 2. Declare Logic And Security
64
104
 
65
- ![admin-app-initial](https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/api-swagger.jpeg?raw=true)
105
+ While API/UI automation is a great start, it's critical to enforce logic and security. You do this in your IDE. Here's how.
66
106
 
67
- ## 2. Customize in your IDE
107
+ The following `add_customizations` process simulates:
68
108
 
69
- While API/UI automation is a great start, it's critical to enforce logic and security. Here's how.
109
+ * Adding security to your project, and
110
+ * Using your IDE to declare logic and security in `logic/declare_logic.sh` and `security/declare_security.py`.
70
111
 
71
- The follwing *add customizations* process simulates adding security to your project, and using your IDE to declare logic and security in `logic/declare_logic.sh` and `security/declare_security.py`. You can diff these files to their created versions, and/or examine the declared logic.
112
+ > Declared security and logic are shown in the screenshots below.<br>It's quite short - 5 rules, 7 security settings.
72
113
 
73
- In a terminal window for your project:
114
+ To add customizations, in a terminal window for your project:
74
115
 
75
116
  **1. Stop the Server** (Red Stop button, or Shift-F5 -- see Appendix)
76
117
 
@@ -79,12 +120,11 @@ In a terminal window for your project:
79
120
  ```bash
80
121
  als add-cust
81
122
  ```
82
-
83
123
  &nbsp;
84
124
 
85
125
  ### Declare Security
86
126
 
87
- The *add customizations* process above has simulated the `ApiLogicServer add-auth` command, and using your IDE to declare security in `logic/declare_logic.sh`.
127
+ The `add_customizations` process above has simulated the `ApiLogicServer add-auth` command, and using your IDE to declare security in `logic/declare_logic.sh`.
88
128
 
89
129
  To see security in action:
90
130
 
@@ -96,9 +136,25 @@ To see security in action:
96
136
 
97
137
  **4. Click Customers**
98
138
 
99
- In the IDE Console Log, observe the how the logging assists in debugging, by showing which Grants (`+ Grant:`) are applied:
139
+ &nbsp;
140
+
141
+ !!! pied-piper ":bulb: Security: Authentication, Role-based Filtering, Logging"
142
+
143
+ #### 1. Login now required
144
+
145
+ #### 2. Role-Based Filtering
146
+
147
+ Observe you now see fewer customers, since user `s1` has role `sales`. This role has a declared filter, as shown in the screenshot below.
100
148
 
101
- <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/security-filters.jpeg?raw=true">
149
+ #### 3. Transparent Logging
150
+
151
+ The screenhot below illustrates security declaration and operation:
152
+
153
+ * The declarative Grants in the upper code panel, and
154
+
155
+ * The logging in the lower panel, to assist in debugging by showing which Grants (`+ Grant:`) are applied:
156
+
157
+ <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/security-filters.jpeg?raw=true">
102
158
 
103
159
  &nbsp;
104
160
 
@@ -108,11 +164,13 @@ Logic (multi-table derivations and constraints) is a significant portion of a sy
108
164
 
109
165
  Rules are declared in Python, simplified with IDE code completion. The screen below shows the 5 rules for **Check Credit Logic.**
110
166
 
111
- The *add customizations* process above has simulated the process of using your IDE to declare logic in `logic/declare_logic.sh`.
167
+ The `add_customizations` process above has simulated the process of using your IDE to declare logic in `logic/declare_logic.sh`.
112
168
 
113
169
  To see logic in action:
114
170
 
115
- **1. Test: Start the Server, and use the Admin App to add an Order and Item**
171
+ **1. In the admin app, Logout (upper right), and login as admin, p**
172
+
173
+ **2. Use the Admin App to add an Order and Item for `Customer 1`** (see Appendix)
116
174
 
117
175
  Observe the rules firing in the console log, as shown in the next screenshot.
118
176
 
@@ -120,37 +178,36 @@ Logic provides significant improvements over procedural logic, as described belo
120
178
 
121
179
  &nbsp;
122
180
 
123
- #### a. Complexity Scaling
181
+ !!! pied-piper ":bulb: Logic: Multi-table Derivations and Constraint Rules, 40X More Concise"
124
182
 
125
- The screenshot below shows our logic declarations, and the logging for inserting an `Item`. Each line represents a rule firing, and shows the complete state of the row.
183
+ #### a. Chaining
126
184
 
127
- Note that it's `Multi-Table Transaction`, as indicating by the indentation. This is because - like a spreadsheet - **rules automatically chain, *including across tables.***
185
+ The screenshot below shows our logic declarations, and the logging for inserting an `Item`. Each line represents a rule firing, and shows the complete state of the row.
128
186
 
129
- <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/logic-chaining.jpeg?raw=true">
187
+ Note that it's a `Multi-Table Transaction`, as indicated by the indentation. This is because - like a spreadsheet - **rules automatically chain, *including across tables.***
130
188
 
131
- #### b. 40X More Concise
189
+ <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/logic-chaining.jpeg?raw=true">
132
190
 
133
- The 5 spreadsheet-like rules represent the same logic as 200 lines of code, [shown here](https://github.com/valhuber/LogicBank/wiki/by-code). That's a remarkable 40X decrease in the backend half of the system.
191
+ #### b. 40X More Concise
134
192
 
135
- &nbsp;
193
+ The 5 spreadsheet-like rules represent the same logic as 200 lines of code, [shown here](https://github.com/valhuber/LogicBank/wiki/by-code). That's a remarkable 40X decrease in the backend half of the system.
194
+ <br><br>
136
195
 
137
- #### c. Automatic Re-use
196
+ #### c. Automatic Re-use
138
197
 
139
- The logic above, perhaps conceived for Place order, applies automatically to all transactions: deleting an order, changing items, moving an order to a new customer, etc.
198
+ The logic above, perhaps conceived for Place order, applies automatically to all transactions: deleting an order, changing items, moving an order to a new customer, etc. This reduces code, and promotes quality (no missed corner cases).
199
+ <br><br>
140
200
 
141
- &nbsp;
201
+ #### d. Automatic Optimizations
142
202
 
143
- #### d. Automatic Optimizations
203
+ SQL overhead is minimized by pruning, and by elimination of expensive aggregate queries. These can result in orders of magnitude impact.
204
+ <br><br>
144
205
 
145
- SQL overhead is minimized by pruning, and by elimination of expensive aggregate queries. These can result in orders of magnitude impact.
206
+ #### e. Transparent
146
207
 
147
- &nbsp;
148
-
149
- #### e. Transparent
208
+ Rules are an executable design. Note they map exactly to our natural language design (shown in comments) - readable by business users.
150
209
 
151
- Rules are an executable design. Note they map exactly to our natural language design (shown in comments) - readable by business users.
152
-
153
- Optionally, you can use the Behave TDD approach to define tests, and the Rules Report will show the rules that execute for each test. For more information, [click here](https://apilogicserver.github.io/Docs/Behave-Logic-Report/).
210
+ Optionally, you can use the Behave TDD approach to define tests, and the Rules Report will show the rules that execute for each test. For more information, [click here](https://apilogicserver.github.io/Docs/Behave-Logic-Report/).
154
211
 
155
212
  &nbsp;
156
213
 
@@ -160,11 +217,17 @@ Not only are spreadsheet-like rules 40X more concise, they meaningfully simplify
160
217
 
161
218
  >> Give a 10% discount for carbon-neutral products for 10 items or more.
162
219
 
163
- The follwing `apply_iteration` process simulates an iteration:
220
+ &nbsp;
221
+
222
+ The following `add_iteration` process simulates an iteration:
223
+
224
+ * acquires a new database with `Product.CarbonNeutral`
225
+
226
+ * issues the `ApiLogicServer rebuild-from-database` command that rebuilds your project (the database models, the api), while preserving the customizations we made above.
164
227
 
165
- - acquires a new database with `Product.CarbonNeutral`
166
- - and a revised `ui/admin/admin.yaml` that shows this new column
167
- - revised logic - in `logic/declare_logic.py`, we replace the 2 lines for the `models.Item.Amount` formula with this (next screenshot shows revised logic executing with breakpoint):
228
+ * acquires a revised `ui/admin/admin.yaml` that shows this new column in the admin app
229
+
230
+ * acquires this revised logic - in `logic/declare_logic.py`, we replaced the 2 lines for the `models.Item.Amount` formula with this (next screenshot shows revised logic executing with breakpoint):
168
231
 
169
232
  ```python
170
233
  def derive_amount(row: models.Item, old_row: models.Item, logic_row: LogicRow):
@@ -176,70 +239,77 @@ The follwing `apply_iteration` process simulates an iteration:
176
239
  Rule.formula(derive=models.Item.Amount, calling=derive_amount)
177
240
  ```
178
241
 
179
- In a terminal window for your project:
242
+ &nbsp;
243
+
244
+ To add this iteration, repeat the process above - in a terminal window for your project:
180
245
 
181
246
  **1. Stop the Server** (Red Stop button, or Shift-F5 -- see Appendix)
182
247
 
183
- **2. Apply Iteration**
248
+ **2. Add Iteration**
184
249
 
185
250
  ```bash
186
251
  als add-cust
187
- als rebuild-from-database
188
252
  ```
189
-
190
253
  &nbsp;
191
254
 
192
- **3. Set the breakpoint as shown**
255
+ **3. Set the breakpoint as shown in the screenshot below**
193
256
 
194
- &nbsp;
257
+ **4. Test: Start the Server, login as Admin**
195
258
 
196
- **4. Test: Start the Server, and use the Admin App to update your Order by adding a `Green` Item**
259
+ **5. Use the Admin App to update your Order by adding 12 `Green` Items**
197
260
 
198
- At the breakpoint, note you can use standard debugger services to debug your logic (examine `Item` attributes, step, etc).
261
+ At the breakpoint, observe you can use standard debugger services to debug your logic (examine `Item` attributes, step, etc).
199
262
 
200
- ![logic-debugging](https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/logic-debugging.jpeg?raw=true)!
263
+ <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/logic-debugging.jpeg?raw=true">
201
264
 
202
265
  &nbsp;
203
266
 
204
- This simple example illustrates some significant aspects of iteration, described in the sub-sections bdelow.
267
+ This simple example illustrates some significant aspects of iteration, described in the sub-sections below.
205
268
 
206
- &nbsp;
269
+ !!! pied-piper ":bulb: Iteration: Automatic Invocation/Ordering, Extensible, Rebuild Preserves Customizations"
207
270
 
208
- ### a. Maintenance Automation
271
+ ### a. Dependency Automation
209
272
 
210
- Along with perhaps documentation, one of the tasks programmers most loathe is maintenance. That's because it's not about writing code, but it's mainly archaeology - deciphering code someone else wrote, just so you can add 4 or 5 lines that will hopefully be called and function correctly.
273
+ Along with perhaps documentation, one of the tasks programmers most loathe is maintenance. That's because it's not about writing code, but it's mainly archaeology - deciphering code someone else wrote, just so you can add 4 or 5 lines that will hopefully be called and function correctly.
211
274
 
212
- Rules change that, since they **self-order their execution** (and pruning) based on system-discovered dependencies. So, to alter logic, you just "drop a new rule in the bucket", and the system will ensure it's called in the proper order, and re-used over all the Use Cases to which it applies.
275
+ Rules change that, since they **self-order their execution** (and pruning) based on system-discovered dependencies. So, to alter logic, you just "drop a new rule in the bucket", and the system will ensure it's called in the proper order, and re-used over all the Use Cases to which it applies. Maintenance is **faster, and higher quality.**
276
+ <br><br>
213
277
 
214
- &nbsp;
278
+ ### b. Extensibile with Python
215
279
 
216
- ### b. Extensibile with Python
280
+ In this case, we needed to do some if/else testing, and it was convenient to add a pinch of Python. Using "Python as a 4GL" is remarkably simple, even if you are new to Python.
217
281
 
218
- In this case, we needed to do some if/else testing, and it was convenient to add a pinch of Python. Using "Python as a 4GL" is remarkably simple, even if you are new to Python.
282
+ Of course, you have the full object-oriented power of Python and its many libraries, so there are *no automation penalty* restrictions.
283
+ <br>
219
284
 
220
- Of course, you have the full object-oriented power of Python and its many libraries, so there are *no automation penalty* restrictions.
285
+ ### c. Debugging: IDE, Logging
221
286
 
222
- &nbsp;
287
+ The screenshot above illustrates that debugging logic is what you'd expect: use your IDE's debugger. This "standard-based" approach applies to other development activities, such as source code management, and container-based deployment.
288
+ <br><br>
223
289
 
224
- ### c. Debugging: IDE, Logging
290
+ ### d. Customizations Retained
225
291
 
226
- The screenshot above illustrates that debugging logic is what you'd expect: use your IDE's debugger. This "standard-based" approach applies to other development activities, such as source code management, and container-based deployment.
292
+ Note we rebuilt the project from our altered database, illustrating we can **iterate, while *preserving customizations.***
227
293
 
228
294
  &nbsp;
229
295
 
230
- ### d. Customizations Retained
296
+ ## 4. API Customization: Standard
297
+
298
+ Of course, we all know that all businesses the world over depend on the `hello world` app. This is provided in `api/customize_api`. Observe that it's:
299
+
300
+ * standard Python
301
+
302
+ * using Flask
231
303
 
232
- Note we rebuilt the project from our altered database, illustrating we can **iterate, while *preserving customizations.***
304
+ * and, for database access, SQLAlchemy. Note all updates from custom APIs also enforce your logic.
233
305
 
234
306
  &nbsp;
235
307
 
236
- ## 4. API Customization: Standard
308
+ ### Messaging With Kafka
237
309
 
238
- Of course, we all know that all businesses the world over depend on the `hello world` app. This is provided in `api/customize_api`. Observe that it's:
310
+ Along with APIs, messaging is another technology commonly employed for application integration. See the screenshot below; for more information, see [Sample Integration](Sample-Integration.md##produce-ordershipping-message){:target="_blank" rel="noopener"}.
239
311
 
240
- - standard Python
241
- - using Flask
242
- - and, for database access, SQLAlchemy. Note all updates from custom APIs also enforce your logic.
312
+ <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/integration/order-to-shipping.jpg?raw=true">
243
313
 
244
314
  &nbsp;
245
315
 
@@ -255,11 +325,13 @@ API Logic Server also creates scripts for deployment. While these are ***not re
255
325
 
256
326
  ## Summary
257
327
 
258
- ![summary](https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/summary.jpeg?raw=true)
328
+ <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/summary.jpeg?raw=true">
259
329
 
260
- In minutes - not days or weeks - you've used API Logic Server to convert an idea into **working software,** added **logic and security,** and **iterated** to meet new requirements.
261
-
262
- To dive deeper, you can install [API Logic Server](https://apilogicserver.github.io/Docs) and execute this demo - or create a system from your own databases.
330
+ !!! pied-piper ":bulb: Instant Creation, Rules, Open Standards"
331
+
332
+ In minutes - not days or weeks - you've used API Logic Server to convert an idea into **working software**, customized using **rule-based logic and security**, and **iterated** to meet new requirements.
333
+
334
+ To dive deeper, you can install [API Logic Server](https://apilogicserver.github.io/Docs) and execute this demo - or create a system from your own databases.
263
335
 
264
336
  &nbsp;
265
337
 
@@ -267,9 +339,39 @@ To dive deeper, you can install [API Logic Server](https://apilogicserver.github
267
339
 
268
340
  ## Appendix: Database Schema
269
341
 
342
+ Initial version:
343
+
344
+ <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/basic_demo_data_model.jpeg?raw=true" width="500">
270
345
 
346
+ End version:
347
+
348
+ <img src="https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/basic_demo_data_model_end.png?raw=true" width="500">
349
+
350
+ &nbsp;
351
+
352
+ ## Appendix: Quick Basic Demo
353
+
354
+ This is a "cheat sheet" for experienced ALS users, e.g., to show your colleagues:
355
+
356
+ ```bash title="Quick Basic Demo"
357
+
358
+ # Microservice Automation
359
+ # Admin App, API, Project
360
+ als create --project-name=basic_demo --db-url=basic_demo
361
+
362
+ # Logic, Security and MCP example
363
+ # see logic (logic/declare_logic.py, logic/cocktail-napkin.jpg); add an Order and Item
364
+ # see security (security/declare_security.py); compare customers, s1 vs. admin
365
+ als add-cust
366
+ als add-auth --db_url=auth
367
+
368
+ # Python Extensibility, Kafka Integration, Rebuild Iteration
369
+ # see logic/declare_logic.py (breakpoint for Kafka)
370
+ # Swagger: ServicesEndPoint.OrderB2B
371
+ als add-cust
372
+ als rebuild-from-database --db_url=sqlite:///database/db.sqlite
373
+ ```
271
374
 
272
- ![basic_demo_data_model](https://github.com/ApiLogicServer/Docs/blob/main/docs/images/basic_demo/basic_demo_data_model.jpeg?raw=true" width="500")
273
375
  &nbsp;
274
376
 
275
377
  ## Appendix: Procedures
@@ -284,7 +386,16 @@ You can use either VSCode or Pycharm.
284
386
 
285
387
  Python employs a virtual environment for project-specific dependencies. Create one as shown below, depending on your IDE.
286
388
 
287
- For VSCode, there is nothing to do. Your `venv` has been created automatically.
389
+ For VSCode:
390
+
391
+ Establish your `venv`, and run it via the first pre-built Run Configuration. To establish your venv:
392
+
393
+ ```bash
394
+ python -m venv venv; venv\Scripts\activate # win
395
+ python3 -m venv venv; . venv/bin/activate # mac/linux
396
+
397
+ pip install -r requirements.txt
398
+ ```
288
399
 
289
400
  For PyCharm, you will get a dialog requesting to create the `venv`; say yes.
290
401
 
@@ -307,19 +418,28 @@ For PyCharm, start the server with CTL-D, Stop with red stop button.
307
418
  To enter a new Order:
308
419
 
309
420
  1. Click `Customer 1``
421
+
310
422
  2. Click `+ ADD NEW ORDER`
423
+
311
424
  3. Set `Notes` to "hurry", and press `SAVE AND SHOW`
425
+
312
426
  4. Click `+ ADD NEW ITEM`
427
+
313
428
  5. Enter Quantity 1, lookup "Product 1", and click `SAVE AND ADD ANOTHER`
429
+
314
430
  6. Enter Quantity 2000, lookup "Product 2", and click `SAVE`
431
+
315
432
  7. Observe the constraint error, triggered by rollups from the `Item` to the `Order` and `Customer`
433
+
316
434
  8. Correct the quantity to 2, and click `Save`
317
435
 
436
+
318
437
  **4. Update the Order**
319
438
 
320
439
  To explore our new logic for green products:
321
440
 
322
441
  1. Access the previous order, and `ADD NEW ITEM`
442
+
323
443
  2. Enter quantity 11, lookup product `Green`, and click `Save`.
324
444
 
325
445
  &nbsp;
@@ -334,4 +454,44 @@ $ sqlite3 database/db.sqlite
334
454
  > .exit
335
455
  ```
336
456
 
337
- The SQLite DBMS is installed with API Logic Server, but the **CLI** is not provided on all systems. If it's not installed, [you can install it like this](https://apilogicserver.github.io/Docs/Database-Connectivity/#sqlite).
457
+ The SQLite DBMS is installed with API Logic Server, but the **CLI** is not provided on all systems. If it's not installed, [you can install it like this](https://apilogicserver.github.io/Docs/Database-Connectivity/#sqlite).
458
+
459
+ ## Appendix: Setup Codespaces
460
+
461
+ Codespaces enables you to run in the cloud: VSCode via your Browser, courtesy GitHub. You can use codespaces on your GenAI project:
462
+
463
+ __1. Open your project on GitHub__
464
+
465
+ ![API Logic Server Intro](images/sample-ai/genai/open-github.png)
466
+
467
+ __2. Open it in Codespaces (takes a minute or 2):__
468
+
469
+ ![API Logic Server Intro](images/sample-ai/genai/start-codespaces.png)
470
+
471
+ > You will now see your project - running in VSCode, _in the Browser._ But that's just what you _see..._
472
+
473
+ > Behind the scenes, Codespaces has requisitioned a cloud machine, and loaded your project - with a _complete development environment_ - Python, your dependencies, git, etc.
474
+
475
+ > You are attached to this machine in your Browser, running VSCode.
476
+
477
+ > :trophy: Pretty remarkable.
478
+
479
+ __3. Start the Server and open the App in the Browser__
480
+
481
+ * Use the pre-defined Launch Configuration
482
+
483
+ ![API Logic Server Intro](images/git-codespaces/start-codespaces.png)
484
+
485
+
486
+ We think you'll find Codespaces pretty amazing - check it out!
487
+
488
+ &nbsp;
489
+
490
+ ## Appendix: Obtain an OpenAI ApiKey
491
+
492
+ To obtain a ChatGPT API Key
493
+ <br>GenAI-Logic uses OpenAI, which requires an Open API Key:
494
+
495
+ 1. Obtain one from [here](https://platform.openai.com/account/api-keys) or [here](https://platform.openai.com/api-keys)
496
+
497
+ 2. Authorize payments [here](https://platform.openai.com/settings/organization/billing/overview)
@@ -62,49 +62,6 @@ def add_service(app, api, project_dir, swagger_host: str, PORT: str, method_deco
62
62
  pass
63
63
 
64
64
 
65
- @app.route('/mcp_server_executor', methods=['GET'])
66
- def mcp_server_executor(path=None):
67
- ''' sample response printed in mcp_client_executor.py:
68
- FIXME - incorrect.
69
- But do provide: https://localhost:5656/.well-known/mcp.json
70
- ```
71
- MCP MCP Response (simulated):
72
- {
73
- "get_json": {
74
- "filter": {
75
- "filter": {
76
- "credit_limit": {
77
- "gt": 4000
78
- }
79
- },
80
- "headers": {
81
- "Accept": "application/vnd.api+json",
82
- "Authorization": "Bearer your_token"
83
- },
84
- "type": "Customer",
85
- "url": "http://localhost:5656/api/Customer"
86
- }
87
- },
88
- "name": "mcp_server_executor",
89
- "openapiUrl": "TUNNEL_URL/api/openapi.json",
90
- "serverUrl": "TUNNEL_URL/api"
91
- }
92
- ```
93
- '''
94
- get_json = request.get_json()
95
- app_logger.info(f"mcp_server_executor sees mcp request: \n{json.dumps(get_json, indent=4)}")
96
-
97
- # process verb, filter here (stub for now)
98
- filter_json = get_json['filter'] # {"credit_limit": {"gt": 4000}} # todo: bunch'o parsing here
99
-
100
- filter_json = {"name": "credit_limit", "op": "gt", "val":4000} # https://github.com/thomaxxl/safrs/wiki/JsonApi-filtering
101
- filter = json.dumps(filter_json) # {"name": "credit_limit", "op": "gt", "val": 4000}
102
- get_uri = get_json['url'] + '?filter=' + filter # get_uri = "http://localhost:5656/api/Customer?filter[credit_limit]=1000"
103
- response = requests.get(url=get_uri, headers= request.headers)
104
-
105
- return response.json(), 200, {'Content-Type': 'application/json; charset=utf-8'}
106
-
107
-
108
65
  @app.route('/.well-known/mcp.json', methods=['GET'])
109
66
  def mcp_discovery(path=None):
110
67
  ''' called by mcp_client_executor for discovery, eg:
@@ -128,7 +85,7 @@ def add_service(app, api, project_dir, swagger_host: str, PORT: str, method_deco
128
85
  test: curl -X GET "http://localhost:5656/.well-known/mcp.json"
129
86
  '''
130
87
  # return docs/mcp_schema.json
131
- schema_path = os.path.join(project_dir, "docs", "mcp_schema.json")
88
+ schema_path = os.path.join(project_dir, "docs/mcp_learning/mcp_schema.json")
132
89
  try:
133
90
  with open(schema_path, "r") as schema_file:
134
91
  schema = json.load(schema_file)