ApiLogicServer 16.1.3__py3-none-any.whl → 16.1.18__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.
- api_logic_server_cli/api_logic_server.py +2 -1
- api_logic_server_cli/genai/genai_svcs.py +2 -2
- api_logic_server_cli/prototypes/base/.github/.copilot-instructions.md +558 -52
- api_logic_server_cli/prototypes/base/.github/.copilot-instructions.md.backup +1257 -0
- api_logic_server_cli/prototypes/base/.github/welcome.md +23 -9
- api_logic_server_cli/prototypes/base/docs/training/{logic_bank_api.prompt → logic_bank_api.md} +125 -4
- api_logic_server_cli/prototypes/base/logic/logic_discovery/readme_logic_discovery.md +15 -0
- api_logic_server_cli/prototypes/base/logic/readme_logic.md +1 -1
- api_logic_server_cli/prototypes/manager/.github/welcome.md +14 -10
- api_logic_server_cli/prototypes/manager/readme_vibe.md +376 -0
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/.github/.copilot-instructions.md +395 -47
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/.github/welcome.md +40 -0
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/customizations/logic/declare_logic.py +1 -1
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/docs/system-creation-vibe.md +1 -1
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/iteration/logic/declare_logic.py +1 -1
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/logic/logic_discovery/{check_credit.py → place_order/check_credit.py} +2 -2
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/readme_ai_mcp.md +2 -2
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/readme_vibe.md +1 -1
- api_logic_server_cli/prototypes/manager/samples/prompts/genai_demo.prompt +1 -1
- api_logic_server_cli/prototypes/manager/system/ApiLogicServer-Internal-Dev/copilot-dev-context.md +27 -0
- api_logic_server_cli/prototypes/manager/system/ApiLogicServer-Internal-Dev/propagate_copilot_changes.py +102 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_formal.prompt +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/postgres/genai_demo_pg.prompt +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/reference/declare_logic.py +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/reference/genai_demo_logic.txt +1 -1
- api_logic_server_cli/prototypes/nw/Tutorial.md +1 -1
- api_logic_server_cli/prototypes/nw/integration/Sample-Integration.md +65 -48
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/METADATA +1 -1
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/RECORD +36 -32
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/WHEEL +1 -1
- /api_logic_server_cli/prototypes/base/docs/training/{logic_bank_patterns.prompt → logic_bank_patterns.md} +0 -0
- /api_logic_server_cli/prototypes/base/docs/training/{probabilistic_logic.prompt → probabilistic_logic.md} +0 -0
- /api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/logic/logic_discovery/{app_integration.py → place_order/app_integration.py} +0 -0
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/entry_points.txt +0 -0
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/licenses/LICENSE +0 -0
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/top_level.txt +0 -0
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
---
|
|
2
|
-
use: welcome for GenAI-Logic Projects
|
|
2
|
+
use: Standard welcome for GenAI-Logic Projects
|
|
3
|
+
note: Edit this for a project-specific Copilot welcome
|
|
3
4
|
---
|
|
4
5
|
|
|
5
|
-
## Welcome to
|
|
6
|
+
## Welcome to Your GenAI-Logic Project
|
|
6
7
|
|
|
7
|
-
This is a complete, working microservice auto-generated from a database schema
|
|
8
|
+
This is a complete, working microservice auto-generated from a database schema.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
**What's been created:**
|
|
10
11
|
- **Admin Web Application** - Live at `http://localhost:5656`
|
|
11
|
-
- **REST API Endpoints** - All database tables exposed at
|
|
12
|
+
- **REST API Endpoints** - All database tables exposed at `/api/*`
|
|
12
13
|
- **Database Models** - Complete SQLAlchemy ORM in `database/models.py`
|
|
13
|
-
- **Authentication System** - JWT-based auth framework
|
|
14
|
-
- **Business Logic Engine** - Declarative rules system
|
|
14
|
+
- **Authentication System** - JWT-based auth framework ready to configure
|
|
15
|
+
- **Business Logic Engine** - Declarative rules system in `logic/declare_logic.py`
|
|
15
16
|
|
|
16
17
|
---
|
|
17
18
|
|
|
18
|
-
To start your application
|
|
19
|
+
**To start your application:** ***Press F5***
|
|
19
20
|
|
|
20
21
|
---
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
**What can I help you with?**
|
|
24
|
+
|
|
25
|
+
Ask me to ***'show me what you can help me with'*** for a complete list of services, or jump right in:
|
|
26
|
+
|
|
27
|
+
1. **Add business logic** - Translate requirements into declarative rules
|
|
28
|
+
2. **Configure security** - Set up role-based access control (RBAC)
|
|
29
|
+
3. **Customize the Admin UI** - Edit `ui/admin/admin.yaml`
|
|
30
|
+
4. **Create custom API endpoints** - Add routes in `api/customize_api.py`
|
|
31
|
+
5. **Build React apps** - Generate custom UIs with `genai-logic genai-add-app`
|
|
32
|
+
6. **Add automated tests** - Create Behave scenarios for requirements traceability
|
|
33
|
+
7. **Integrate with other systems** - Add Kafka events, webhooks, or B2B APIs
|
|
34
|
+
8. **Understand the architecture** - Explore what was auto-generated and why
|
|
35
|
+
|
|
36
|
+
Ready to customize your project?
|
api_logic_server_cli/prototypes/base/docs/training/{logic_bank_api.prompt → logic_bank_api.md}
RENAMED
|
@@ -1,15 +1,73 @@
|
|
|
1
1
|
---
|
|
2
2
|
# LogicBank API Reference
|
|
3
|
-
# Version: 1.0.
|
|
4
|
-
# Last Updated:
|
|
3
|
+
# Version: 1.0.3
|
|
4
|
+
# Last Updated: January 29, 2026
|
|
5
5
|
# Description: The Logic Rosetta Stone: simplified API for creating declarative business logic rules
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
=============================================================================
|
|
9
|
+
💎 CORE PRINCIPLE: Path-Independent Rules = Automatic Reuse
|
|
10
|
+
=============================================================================
|
|
11
|
+
|
|
12
|
+
**What you're really doing:** Distilling path-independent rules from path-dependent logic.
|
|
13
|
+
|
|
14
|
+
**Path-dependent (procedural):** Separate code for each execution path
|
|
15
|
+
- Add item → recalc amounts
|
|
16
|
+
- Change quantity → recalc amounts
|
|
17
|
+
- Change customer → adjust both balances
|
|
18
|
+
- Ship order → adjust balance
|
|
19
|
+
- Delete item → recalc amounts
|
|
20
|
+
|
|
21
|
+
**Path-independent (declarative):** ONE rule works for ALL paths
|
|
22
|
+
```python
|
|
23
|
+
Rule.sum(derive=models.Customer.balance, as_sum_of=models.Order.amount_total, where=lambda row: row.date_shipped is None)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Automatic reuse over use cases:** Whereas reuse is typically a high-order design skill, declarative rules provide *automatic reuse* - write the relationship once, it works for insert/update/delete/parent changes. No use case explosion.
|
|
27
|
+
|
|
28
|
+
=============================================================================
|
|
29
|
+
|
|
8
30
|
Here is the simplified API for LogicBank:
|
|
9
31
|
|
|
10
32
|
PREREQUISITE: For general patterns (event handler signatures, logging, request pattern, anti-patterns),
|
|
11
33
|
see docs/training/logic_bank_patterns.prompt
|
|
12
34
|
|
|
35
|
+
=============================================================================
|
|
36
|
+
🗂️ CRITICAL: Directory Structure = Requirements Traceability
|
|
37
|
+
=============================================================================
|
|
38
|
+
|
|
39
|
+
**Pattern Recognition:**
|
|
40
|
+
- Context phrases ("When X", "For Y", "On Z") → directory: logic/logic_discovery/x/
|
|
41
|
+
- After context, each colon-terminated phrase → file: phrase.py
|
|
42
|
+
- Prefixes like "Use case:", "Requirement:" are optional (just noise words)
|
|
43
|
+
- No context phrase → single file (flat structure OK)
|
|
44
|
+
|
|
45
|
+
**Naming:** Convert to snake_case, remove articles
|
|
46
|
+
- "When Placing Orders" / "On Placing Orders" → place_order/
|
|
47
|
+
- "Check Credit:" → check_credit.py
|
|
48
|
+
- "Use case: App Integration:" → app_integration.py
|
|
49
|
+
|
|
50
|
+
**Requirements Traceability:** File structure provides direct link from use case to implementation
|
|
51
|
+
```
|
|
52
|
+
Prompt: "On Placing Orders, Check Credit: ..."
|
|
53
|
+
Result: logic/logic_discovery/place_order/check_credit.py
|
|
54
|
+
Trace: Use Case Name → File Path → Rules → Logic Report
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Examples:**
|
|
58
|
+
```
|
|
59
|
+
Prompt: "When Placing Orders, Check Credit: ... App Integration: ..."
|
|
60
|
+
Result: logic/logic_discovery/place_order/{__init__.py, check_credit.py, app_integration.py}
|
|
61
|
+
|
|
62
|
+
Prompt: "For Customer Management, Validate Credit: ... Calculate Loyalty: ..."
|
|
63
|
+
Result: logic/logic_discovery/customer_management/{__init__.py, validate_credit.py, calculate_loyalty.py}
|
|
64
|
+
|
|
65
|
+
Prompt: "Check Credit: ..." (no context)
|
|
66
|
+
Result: logic/logic_discovery/check_credit.py (flat)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
=============================================================================
|
|
70
|
+
|
|
13
71
|
Translate the user prompt into a series of calls to Rule methods, described here.
|
|
14
72
|
|
|
15
73
|
Do not generate import statements.
|
|
@@ -360,5 +418,68 @@ RIGHT (do this instead):
|
|
|
360
418
|
if_condition=lambda row: row.date_shipped is not None,
|
|
361
419
|
with_args={"topic": "order_shipping"})
|
|
362
420
|
|
|
363
|
-
|
|
364
|
-
|
|
421
|
+
=============================================================================
|
|
422
|
+
🗂️ FILE ORGANIZATION: Complete Example with Directory Structure
|
|
423
|
+
=============================================================================
|
|
424
|
+
|
|
425
|
+
When given a prompt with context phrase and multiple use cases, create organized structure:
|
|
426
|
+
|
|
427
|
+
Example Prompt:
|
|
428
|
+
```
|
|
429
|
+
When Placing Orders, implement Requirement: Check Credit:
|
|
430
|
+
|
|
431
|
+
1. The Customer's balance is less than the credit limit
|
|
432
|
+
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
|
|
433
|
+
3. The Order's amount_total is the sum of the Item amount
|
|
434
|
+
4. The Item amount is the quantity * unit_price
|
|
435
|
+
5. The Product count_suppliers is the sum of the Product Suppliers
|
|
436
|
+
6. Item unit_price copied from the Product
|
|
437
|
+
|
|
438
|
+
Use case: App Integration
|
|
439
|
+
|
|
440
|
+
1. Send the Order to Kafka topic 'order_shipping' if the date_shipped is not None.
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
Response Structure:
|
|
444
|
+
```
|
|
445
|
+
logic/logic_discovery/
|
|
446
|
+
place_order/
|
|
447
|
+
__init__.py
|
|
448
|
+
check_credit.py
|
|
449
|
+
app_integration.py
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
File: logic/logic_discovery/place_order/__init__.py
|
|
453
|
+
```python
|
|
454
|
+
# Empty file - makes this a Python package for auto-discovery
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
File: logic/logic_discovery/place_order/check_credit.py
|
|
458
|
+
```python
|
|
459
|
+
"""
|
|
460
|
+
Check Credit Use Case - Business Logic Rules
|
|
461
|
+
|
|
462
|
+
Natural Language Requirements:
|
|
463
|
+
1. The Customer's balance is less than the credit limit
|
|
464
|
+
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
|
|
465
|
+
3. The Order's amount_total is the sum of the Item amount
|
|
466
|
+
4. The Item amount is the quantity * unit_price
|
|
467
|
+
5. The Product count_suppliers is the sum of the Product Suppliers
|
|
468
|
+
6. Item unit_price copied from the Product
|
|
469
|
+
|
|
470
|
+
version: 1.0
|
|
471
|
+
date: [Current Date]
|
|
472
|
+
"""
|
|
473
|
+
|
|
474
|
+
from logic_bank.logic_bank import Rule
|
|
475
|
+
from database import models
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
def declare_logic():
|
|
479
|
+
"""Business logic rules for Check Credit use case."""
|
|
480
|
+
|
|
481
|
+
Rule.sum(derive=models.Customer.balance, as_sum_of=models.Order.amount_total, where=lambda row: row.date_shipped is None)
|
|
482
|
+
Rule.sum(derive=models.Order.amount_total, as_sum_of=models.Item.amount)
|
|
483
|
+
Rule.formula(derive=models.Item.amount, as_expression=lambda row: row.quantity * row.unit_price)
|
|
484
|
+
Rule.copy(derive=models.Item.unit_price, from_parent=models.Product.unit_price)
|
|
485
|
+
Rule.count(derive=models.Product.count_suppliers, as_count_of=models.ProductSupplier)
|
|
@@ -4,6 +4,21 @@ but that can lead to a lot of rules in 1 file.
|
|
|
4
4
|
A *best practice* is to create logic files in this directory,
|
|
5
5
|
named after the use case (e.g., `check_credit.py`).
|
|
6
6
|
|
|
7
|
+
## Organizing Related Use Cases
|
|
8
|
+
|
|
9
|
+
For complex scenarios with multiple related use cases, you can organize them hierarchically:
|
|
10
|
+
|
|
11
|
+
- **Flat structure** (simple cases): `check_credit.py`, `validate_order.py`
|
|
12
|
+
- **Hierarchical structure** (complex workflows):
|
|
13
|
+
- `place_order/check_credit.py` - Credit validation for order placement
|
|
14
|
+
- `place_order/app_integration.py` - External integrations for order placement
|
|
15
|
+
- `ship_order/validate_inventory.py` - Inventory checks for shipping
|
|
16
|
+
|
|
17
|
+
**When to use hierarchical structure:**
|
|
18
|
+
- The prompt describes a parent use case with sub-cases (e.g., "On Placing Orders, Check Credit:")
|
|
19
|
+
- Multiple related operations share a common workflow (e.g., order placement, customer onboarding)
|
|
20
|
+
- You want to group related logic files for better organization
|
|
21
|
+
|
|
7
22
|
The easiest way to to copy/paste `use_case.py` to a new file, then
|
|
8
23
|
add your logic either by Natural Language (use your Coding Assistant, such as CoPilot),
|
|
9
24
|
or your IDE's code completion.
|
|
@@ -15,7 +15,7 @@ This describes how to use Logic; for more information, [see here](https://apilog
|
|
|
15
15
|
You can provide prompts like this to CoPilot. This is a good approach for new users:
|
|
16
16
|
|
|
17
17
|
```text title="Declare Logic in Natural Language"
|
|
18
|
-
Create Business Logic for
|
|
18
|
+
Create Business Logic for on Placing Orders, Check Credit:
|
|
19
19
|
1. The Customer's balance is less than the credit limit
|
|
20
20
|
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
|
|
21
21
|
3. The Order's amount_total is the sum of the Item amount
|
|
@@ -12,32 +12,36 @@ Welcome! This is the **Project Manager** - your workspace for creating and manag
|
|
|
12
12
|
|
|
13
13
|
## Getting Started
|
|
14
14
|
|
|
15
|
-
**If you're new here**, start with the 20-minute basic_demo tutorial - it's the best way to see what GenAI-Logic can do:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
genai-logic create --project_name=basic_demo --db_url=basic_demo
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
After it runs, the project will auto-open with its own README and I'll guide you through a hands-on tour.
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
15
|
**If you're returning**, here's what I can help you with:
|
|
26
16
|
|
|
27
17
|
**Creating New Projects:**
|
|
18
|
+
|
|
28
19
|
1. **Create from existing database** - Generate project from your database schema
|
|
29
20
|
2. **Create with GenAI** - Describe database + logic in natural language, get complete working system
|
|
30
21
|
3. **Create manually** - I'll help you design and build a database, then generate the project
|
|
31
22
|
|
|
32
23
|
**Working with Existing Projects:**
|
|
24
|
+
|
|
33
25
|
4. **Guide through basic_demo** - Take the interactive 30-45 min hands-on tour
|
|
34
26
|
5. **Customize projects** - Add logic, security, custom APIs, React apps, tests
|
|
35
27
|
6. **Review project structure** - Understand what was auto-generated
|
|
36
28
|
7. **Debug issues** - Help troubleshoot problems in your projects
|
|
37
29
|
|
|
38
30
|
**Learning & Examples:**
|
|
31
|
+
|
|
39
32
|
8. **Explore sample databases** - See what's in `samples/dbs/`
|
|
40
33
|
9. **Review GenAI examples** - Learn from `system/genai/examples/`
|
|
41
34
|
10. **Understand architecture** - Explain how the system works
|
|
42
35
|
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
**If you're new here**, start with the 20-minute basic_demo tutorial - it's the best way to see what GenAI-Logic can do:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
genai-logic create --project_name=basic_demo --db_url=basic_demo
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
After it runs, the project will auto-open with its own README and I'll guide you through a hands-on tour.
|
|
45
|
+
|
|
46
|
+
|
|
43
47
|
**What would you like to work on?**
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Vibe MCP / Microservice
|
|
3
|
+
do_process_code_block_titles: True
|
|
4
|
+
version: 1.1 from docsite, for readme 10/28/2025
|
|
5
|
+
Propagation: Build copies to api_logic_server_cli/prototypes/basic_demo/readme_vibe → BLT copies to Manager samples/basic_demo_sample/readme_vibe
|
|
6
|
+
Guided_Tour: See tutor for AI guided tour instructions (user says "Guide me through basic_demo")
|
|
7
|
+
---
|
|
8
|
+
<style>
|
|
9
|
+
-typeset h1,
|
|
10
|
+
-content__button {
|
|
11
|
+
display: none;
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
|
|
15
|
+
# Vibe an MCP Microservice
|
|
16
|
+
|
|
17
|
+
This illustrates [GenAI-Logic](https://apilogicserver.github.io/Docs/Sample-Basic-Demo-Vibe) automation to create an MCP system using **Vibe:**
|
|
18
|
+
> **1) Natural Language**, **2) Declarative** (*what not now*), **3) Trusted error correction** with the coding assistant
|
|
19
|
+
|
|
20
|
+
<br>
|
|
21
|
+
|
|
22
|
+
**🤖 Bootstrap Copilot by pasting the following into the chat:**
|
|
23
|
+
``` bash title='🤖 Bootstrap Copilot by pasting the following into the chat'
|
|
24
|
+
Please load `.github/.copilot-instructions.md`
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
> **Important:** be sure CoPilot is in "Agent" Mode. "Ask" will not work. Also, we get consistently good results with `Claude Sonnet 4.5`.
|
|
28
|
+
|
|
29
|
+
<br>
|
|
30
|
+
|
|
31
|
+
**How to Use This Demo:**
|
|
32
|
+
|
|
33
|
+
This demo teaches AI-assisted development patterns. Each step is a **natural language prompt** you copy/paste into Copilot chat. The prompts are self-documenting - they explain what they do.
|
|
34
|
+
|
|
35
|
+
**Vibe Philosophy:** AI makes errors. That's expected. When something fails, tell Copilot: *"Error X occurred, fix it"*. Copilot is exceptionally good at finding and correcting its own mistakes.
|
|
36
|
+
|
|
37
|
+
**Recommended Path:** If you're new to GenAI-Logic, start with the [Standard Demo](https://apilogicserver.github.io/Docs/Sample-Basic-Demo) (creates `basic_demo` with guided tutor) to learn platform fundamentals. Then return here to explore AI-assisted development with `basic_demo_vibe`.
|
|
38
|
+
|
|
39
|
+
<br>
|
|
40
|
+
|
|
41
|
+
<details markdown>
|
|
42
|
+
|
|
43
|
+
<summary>Demo Overview: Vibe an MCP API, Custom Client and Business Logic; pre-reqs </summary>
|
|
44
|
+
|
|
45
|
+
<br>Here we will use Vibe to:
|
|
46
|
+
|
|
47
|
+
1. **[Create From Existing DB](#1-create-from-existing-db)** - Provides a MCP-enabled API and an Admin App
|
|
48
|
+
- [Project Opens: Run](#1a-project-opens-run) - Launch and verify your system
|
|
49
|
+
|
|
50
|
+
2. **[Custom UI: GenAI, Vibe](#2-custom-ui-genai-vibe)** - Create a custom (React) client
|
|
51
|
+
|
|
52
|
+
3. **[Declare Business Logic](#3-declare-business-logic)** - Add rules with natural language
|
|
53
|
+
|
|
54
|
+
4. **[Enterprise Connectivity: B2B](#4-enterprise-connectivity-b2b)** - Create integration endpoints
|
|
55
|
+
|
|
56
|
+
5. **[MCP: Logic, User Interface](#5-mcp-logic-user-interface)** - Implement Model Context Protocol
|
|
57
|
+
|
|
58
|
+
6. **[Iterate: Rules and Python](#6-iterate-rules-and-python)** - Advanced customization patterns<br><br>
|
|
59
|
+
|
|
60
|
+
Pre-reqs:
|
|
61
|
+
|
|
62
|
+
1. Install
|
|
63
|
+
2. OpenAI API Key is useful but not required; [click here](WebGenAI-CLI#configuration).
|
|
64
|
+
|
|
65
|
+
* The React App has pre-built apps (`ui/my-react-app`) you can use; they require `npm install; npm start`
|
|
66
|
+
* The `integration/mcp/mcp_client_executor.py` has `create_tool_context_from_llm` set to bypass LLM calls and use saved context; alter as required.
|
|
67
|
+
3. NodeJS to run the react app
|
|
68
|
+
|
|
69
|
+
The entire process takes 20 minutes; usage notes:
|
|
70
|
+
|
|
71
|
+
* Most find it **more convenient** to view this in your Browser; [click here](https://apilogicserver.github.io/Docs/Sample-Basic-Tour)
|
|
72
|
+
* A slide show summary is available [on our Web Site](https://www.genai-logic.com/product/tour)
|
|
73
|
+
* Tip: look for **readme files** in created projects
|
|
74
|
+
|
|
75
|
+

|
|
76
|
+
|
|
77
|
+
</details>
|
|
78
|
+
|
|
79
|
+
<br>
|
|
80
|
+
|
|
81
|
+
## 1. Create From Existing DB
|
|
82
|
+
|
|
83
|
+
**Create a project from an existing database (open the disclosure box for details):**
|
|
84
|
+
```bash title="Create a project from an existing database (open the disclosure box for details)"
|
|
85
|
+
Create a database project named basic_demo_vibe from samples/dbs/basic_demo.sqlite
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
<details markdown>
|
|
89
|
+
|
|
90
|
+
<summary> The database is Customer, Orders, Items and Product; you can also create the database</summary>
|
|
91
|
+
|
|
92
|
+

|
|
93
|
+
|
|
94
|
+
**Or, create a *new* database** with this prompt:
|
|
95
|
+
```bash
|
|
96
|
+
Create a system with customers, orders, items and products.
|
|
97
|
+
|
|
98
|
+
Include a notes field for orders.
|
|
99
|
+
|
|
100
|
+
on Placing Orders, Check Credit
|
|
101
|
+
1. The Customer's balance is less than the credit limit
|
|
102
|
+
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
|
|
103
|
+
3. The Order's amount_total is the sum of the Item amount
|
|
104
|
+
4. The Item amount is the quantity * unit_price
|
|
105
|
+
5. The Item unit_price is copied from the Product unit_price
|
|
106
|
+
|
|
107
|
+
Use case: App Integration
|
|
108
|
+
1. Send the Order to Kafka topic 'order_shipping' if the date_shipped is not None.
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
<br>
|
|
112
|
+
|
|
113
|
+
In either case, the database model is customer, orders and items:
|
|
114
|
+
|
|
115
|
+

|
|
116
|
+
|
|
117
|
+
</details>
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
### 1a. Project Opens: Run
|
|
122
|
+
|
|
123
|
+
The project should automatically open a new window in VSCode. <br>
|
|
124
|
+
|
|
125
|
+
**🤖 Again, bootstrap Copilot by pasting the following into the chat:**
|
|
126
|
+
``` bash title='🤖 Again, bootstrap Copilot by pasting the following into the chat'
|
|
127
|
+
Please load `.github/.copilot-instructions.md`.
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Run it as follows:
|
|
131
|
+
|
|
132
|
+
1. **Start the Server:** F5
|
|
133
|
+
2. **Start the Admin App:** browse to [http://localhost:5656/](http://localhost:5656/). The Admin App screen shown below should appear in your Browser.
|
|
134
|
+
3. **Verify as shown below**
|
|
135
|
+
|
|
136
|
+
<details markdown>
|
|
137
|
+
|
|
138
|
+
<summary>API: filtering, sorting, pagination, optimistic locking,related data access... see Swagger </summary>
|
|
139
|
+
|
|
140
|
+
Your API is MCP enabled, and ready for custom app dev. For more information, [click here](https://apilogicserver.github.io/Docs/API-Self-Serve).
|
|
141
|
+
|
|
142
|
+

|
|
143
|
+
</details>
|
|
144
|
+
|
|
145
|
+
<br>
|
|
146
|
+
|
|
147
|
+
<details markdown>
|
|
148
|
+
|
|
149
|
+
<summary>Admin App: multi-page, multi-table, automatic joins, lookups, cascade add - collaboration-ready</summary>
|
|
150
|
+
|
|
151
|
+
For more information, [click here](https://apilogicserver.github.io/Docs/Admin-Tour).
|
|
152
|
+
|
|
153
|
+
The Admin App is 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.
|
|
154
|
+
|
|
155
|
+
Explore the app - click Customer Alice, and see their Orders, and Items.
|
|
156
|
+
|
|
157
|
+

|
|
158
|
+
</details>
|
|
159
|
+
|
|
160
|
+
<br>
|
|
161
|
+
|
|
162
|
+
## 2. Custom UI: GenAI, Vibe
|
|
163
|
+
|
|
164
|
+
The app above is suitable for collaborative iteration to nail down the requirements, and back office data maintenance. It's also easy to make simple customizations, using the yaml file. For more custom apps, use Vibe:
|
|
165
|
+
|
|
166
|
+
**Create a custom react app - customize in your IDE directly or with Vibe:**
|
|
167
|
+
```bash title="Create a custom react app - customize in your IDE directly or with Vibe"
|
|
168
|
+
Create a new react app using genai-add-app,
|
|
169
|
+
wait for it to complete,
|
|
170
|
+
then update the Product list to provide users an option to see results in a list or in cards.
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
<details markdown>
|
|
175
|
+
|
|
176
|
+
<summary>Vibe Automation provides a running start (and can make errors)</summary>
|
|
177
|
+
|
|
178
|
+
* Instead of creating data mockups, you have a **running API server with real data**
|
|
179
|
+
* Instead of starting from scratch, you have a **running multi-page app**
|
|
180
|
+
* And, you'll have projects that are **architecturally correct:** shared logic, enforced in the server, available for both User Interfaces and services.
|
|
181
|
+
* Then, use you favorite Vibe tools with your running API:
|
|
182
|
+
|
|
183
|
+
> Note: AI makes errors. Part of Vibe is to accept that, and insist that AI find and fix them. CoPilot is generally exceptionally good at this.
|
|
184
|
+
|
|
185
|
+
</details>
|
|
186
|
+
|
|
187
|
+
<br>
|
|
188
|
+
|
|
189
|
+
> Below is an example from Northwind: [click here](https://apilogicserver.github.io/Docs/Admin-Vibe-Sample)
|
|
190
|
+
|
|
191
|
+

|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
<br>
|
|
195
|
+
|
|
196
|
+
## 3. Declare Business Logic
|
|
197
|
+
|
|
198
|
+
Logic (multi-table derivations and constraints) is a significant portion of a system, typically nearly half. GenAI-Logic provides **spreadsheet-like rules** that dramatically simplify and accelerate logic development.
|
|
199
|
+
|
|
200
|
+
Rules are declared in Python, simplified with IDE code completion. The screen below shows the 5 rules for **Check Credit Logic.**
|
|
201
|
+
|
|
202
|
+
**1. Stop the Server** (Red Stop button, or Shift-F5 -- see Appendix)
|
|
203
|
+
|
|
204
|
+
**2. Add Business Logic**
|
|
205
|
+
|
|
206
|
+
**Check Credit Logic (instead of 220 lines of code):**
|
|
207
|
+
```bash title="Check Credit Logic (instead of 220 lines of code)"
|
|
208
|
+
Use case: Check Credit
|
|
209
|
+
1. The Customer's balance is less than the credit limit
|
|
210
|
+
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
|
|
211
|
+
3. The Order's amount_total is the sum of the Item amount
|
|
212
|
+
4. The Item amount is the quantity * unit_price
|
|
213
|
+
5. The Item unit_price is copied from the Product unit_price
|
|
214
|
+
|
|
215
|
+
Use case: App Integration
|
|
216
|
+
1. Send the Order to Kafka topic 'order_shipping' if the date_shipped is not None.
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+

|
|
220
|
+
|
|
221
|
+
To test the logic:
|
|
222
|
+
|
|
223
|
+
**1. Use the Admin App to access the first order for `Customer Alice`**
|
|
224
|
+
|
|
225
|
+
**2. Edit its first item to a very high quantity**
|
|
226
|
+
|
|
227
|
+
The update is properly rejected because it exceeds the credit limit. Observe the rules firing in the console log - see Logic In Action, below.
|
|
228
|
+
|
|
229
|
+
<br>
|
|
230
|
+
|
|
231
|
+
<details markdown>
|
|
232
|
+
|
|
233
|
+
<summary>Logic is critical - half the effort; Declarative is 40X More Concise, Maintainable </summary>
|
|
234
|
+
|
|
235
|
+
<br>Logic is critical to your system - it represents nearly *half the effort.* Instead of procedural code, [***declare logic***](Logic#declaring-rules) with WebGenAI, or in your IDE using code completion or Natural Language as shown above.
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
**a. 40X More Concise**
|
|
239
|
+
|
|
240
|
+
The 5 spreadsheet-like rules represent the same logic as 200 lines of code, [shown here](https://apilogicserver.github.io/Docs/Logic-Why). That's a remarkable 40X decrease in the backend half of the system.
|
|
241
|
+
|
|
242
|
+
> 💡 No FrankenCode<br>Note the rules look like syntactically correct requirements. They are not turned into piles of unmanageable "frankencode" - see [models not frankencode](https://www.genai-logic.com/faqs#h.3fe4qv21qtbs).
|
|
243
|
+
|
|
244
|
+
**b. Maintainable: Debugging, Logging**
|
|
245
|
+
|
|
246
|
+
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.
|
|
247
|
+
|
|
248
|
+
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.***
|
|
249
|
+
|
|
250
|
+

|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
</details>
|
|
254
|
+
|
|
255
|
+
<br>
|
|
256
|
+
|
|
257
|
+
## 4. Enterprise Connectivity: B2B
|
|
258
|
+
|
|
259
|
+
To fit our system into the Value Chain,
|
|
260
|
+
we need a custom API to accept orders from B2B partners, and forward paid orders to shipping via Kafka.
|
|
261
|
+
|
|
262
|
+
**Create the Custom B2B API Endpoint:**
|
|
263
|
+
``` bash title="Create the Custom B2B API Endpoint"
|
|
264
|
+
Create a B2B order API called 'OrderB2B' that accepts orders from external partners.
|
|
265
|
+
|
|
266
|
+
The external format should map:
|
|
267
|
+
- 'Account' field to find customers by name
|
|
268
|
+
- 'Notes' field to order notes
|
|
269
|
+
- 'Items' array where each item maps 'Name' to find products and 'QuantityOrdered' to item quantity
|
|
270
|
+
|
|
271
|
+
The API should create complete orders with automatic lookups and inherit all business logic rules.
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
The Kafka logic was created earlier, so we are ready to test.
|
|
275
|
+
|
|
276
|
+
You can use Swagger (note the test data is provided), or use CLI:
|
|
277
|
+
|
|
278
|
+
**Test the B2B Endpoint:**
|
|
279
|
+
``` bash title="Test the B2B Endpoint"
|
|
280
|
+
curl -X POST http://localhost:5656/api/OrderB2BEndPoint/OrderB2B -H "Content-Type: application/json" -d '{"meta":{"args":{"data":{"Account":"Alice","Notes":"RUSH order for Q4 promotion","date_shipped":"2025-08-04","Items":[{"Name":"Widget","QuantityOrdered":5},{"Name":"Gadget","QuantityOrdered":3}]}}}}'
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Observe the logic execution in the VSCode debug window.
|
|
284
|
+
|
|
285
|
+
<br>
|
|
286
|
+
|
|
287
|
+
## 5. MCP: Logic, User Interface
|
|
288
|
+
|
|
289
|
+
The server is automatically mcp-enabled, but we also require a user-interface to enable business users to send email, subject to business logic for customer email opt-outs. Build it as follows:<br><br>
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
**1. Stop the Server:** click the red stop icon 🟥 or press <kbd>Shift</kbd>+<kbd>F5</kbd>.
|
|
293
|
+
|
|
294
|
+
**2. Create the SysEmail Table to Track Sent Emails**
|
|
295
|
+
|
|
296
|
+
**Add a Table to Track Sent Emails:**
|
|
297
|
+
``` bash title="Add a Table to Track Sent Emails"
|
|
298
|
+
Create a table SysEmail in `database/db.sqlite` as a child of customer,
|
|
299
|
+
with columns id, message, subject, customer_id and CreatedOn.
|
|
300
|
+
```
|
|
301
|
+
Follow the suggestions to update the admin app.
|
|
302
|
+
|
|
303
|
+
<br>
|
|
304
|
+
|
|
305
|
+
**3. Create an MCP Client Executor to process MCP Requests:**
|
|
306
|
+
|
|
307
|
+
**Create an MCP Client Executor (don:**
|
|
308
|
+
``` bash title="Create an MCP Client Executor (don't run yet)"
|
|
309
|
+
Create the mcp client executor
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
MCP Clients accept MCP Requests, invoke the LLM to obtain a series of API calls to run, and runs them. For more on MCP, [click here](https://apilogicserver.github.io/Docs/Integration-MCP).
|
|
313
|
+
|
|
314
|
+
<br>
|
|
315
|
+
|
|
316
|
+
**4. Create the email service using a Request Table**
|
|
317
|
+
|
|
318
|
+
**Create the email service using SysEmail as a Request Table:**
|
|
319
|
+
``` bash title="Create the email service using SysEmail as a Request Table"
|
|
320
|
+
Add an after_flush event on SysEmail to produce a log message "email sent",
|
|
321
|
+
unless the customer has opted out.
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Inserts into SysEmail will now send mails (stubbed here with a log message). Request objects are a common rule pattern - for more information, [click here](Integration-MCP#3b-logic-request-pattern).
|
|
325
|
+
|
|
326
|
+
<br>
|
|
327
|
+
|
|
328
|
+
<details markdown>
|
|
329
|
+
|
|
330
|
+
<summary>Creates logic like this </summary>
|
|
331
|
+
|
|
332
|
+
<br>When sending email, we require ***business rules*** to ensure it respects the opt-out policy:
|
|
333
|
+
|
|
334
|
+

|
|
335
|
+
|
|
336
|
+
</details>
|
|
337
|
+
|
|
338
|
+
<br>
|
|
339
|
+
|
|
340
|
+
**5. Restart the Server** - F5
|
|
341
|
+
|
|
342
|
+
<br>
|
|
343
|
+
|
|
344
|
+
**6. Start the Admin App**
|
|
345
|
+
|
|
346
|
+
<br>
|
|
347
|
+
|
|
348
|
+
**7. Click SysMCP >> Create New, and enter:**
|
|
349
|
+
|
|
350
|
+
**Test the MCP using the Admin App:**
|
|
351
|
+
```text title="Test the MCP using the Admin App"
|
|
352
|
+
List the orders date_shipped is null and CreatedOn before 2023-07-14,
|
|
353
|
+
and send a discount email (subject: 'Discount Offer')
|
|
354
|
+
to the customer for each one.
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
<br>
|
|
358
|
+
|
|
359
|
+

|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
<details markdown>
|
|
363
|
+
|
|
364
|
+
<summary>More on MCP; Observe the log </summary>
|
|
365
|
+
|
|
366
|
+
<br>For more on MCP, [click here](https://apilogicserver.github.io/Docs/Integration-MCP).
|
|
367
|
+
|
|
368
|
+

|
|
369
|
+
|
|
370
|
+
</details>
|
|
371
|
+
|
|
372
|
+
<br>
|
|
373
|
+
|
|
374
|
+
## 6. Iterate: Rules and Python
|
|
375
|
+
|
|
376
|
+
This is addressed in the related CLI-based demo - to continue, [click here](Sample-Basic-Demo#5-iterate-with-rules-and-python).
|