ApiLogicServer 15.0.37__py3-none-any.whl → 15.0.40__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 (55) hide show
  1. api_logic_server_cli/api_logic_server.py +2 -2
  2. api_logic_server_cli/api_logic_server_info.yaml +2 -2
  3. api_logic_server_cli/genai/genai_svcs.py +4 -3
  4. api_logic_server_cli/prototypes/base/.copilot-instructions.md +10 -0
  5. api_logic_server_cli/prototypes/base/.vscode/.copilot-instructions.md +178 -0
  6. api_logic_server_cli/prototypes/base/README_PROJECT.md +43 -0
  7. api_logic_server_cli/prototypes/base/api_logic_server_run.py +20 -8
  8. api_logic_server_cli/prototypes/base/docs/training/react_map.prompt.md +13 -0
  9. api_logic_server_cli/prototypes/base/docs/training/react_tree.prompt.md +10 -0
  10. api_logic_server_cli/prototypes/base/integration/mcp/readme-mcp.md +9 -0
  11. api_logic_server_cli/prototypes/base/logic/logic_discovery/readme_logic_discovery.md +9 -0
  12. api_logic_server_cli/prototypes/base/logic/logic_discovery/use_case.py +27 -0
  13. api_logic_server_cli/prototypes/base/logic/{readme_declare_logic.md → readme_logic.md} +70 -1
  14. api_logic_server_cli/prototypes/base/readme.md +30 -5
  15. api_logic_server_cli/prototypes/base/security/readme_security.md +17 -0
  16. api_logic_server_cli/prototypes/manager/.copilot-instructions.md +13 -0
  17. api_logic_server_cli/prototypes/manager/.vscode/.copilot-instructions.md +58 -0
  18. api_logic_server_cli/prototypes/manager/.vscode/ApiLogicServer.code-workspace +2 -2
  19. api_logic_server_cli/prototypes/manager/README.md +13 -1
  20. api_logic_server_cli/prototypes/manager/system/Manager_workspace.code-workspace +3 -3
  21. api_logic_server_cli/prototypes/nw/api/api_discovery/authentication_expose_api_models.py +53 -0
  22. api_logic_server_cli/prototypes/nw/api/api_discovery/auto_discovery.py +27 -0
  23. api_logic_server_cli/prototypes/nw/api/api_discovery/count_orders_by_month.html +76 -0
  24. api_logic_server_cli/prototypes/nw/api/api_discovery/count_orders_by_month.sql +1 -0
  25. api_logic_server_cli/prototypes/nw/api/api_discovery/dashboard_services.py +143 -0
  26. api_logic_server_cli/prototypes/nw/api/api_discovery/mcp_discovery.py +97 -0
  27. api_logic_server_cli/prototypes/nw/api/api_discovery/new_service.py +21 -0
  28. api_logic_server_cli/prototypes/nw/api/api_discovery/newer_service.py +21 -0
  29. api_logic_server_cli/prototypes/nw/api/api_discovery/number_of_sales_per_category.html +76 -0
  30. api_logic_server_cli/prototypes/nw/api/api_discovery/number_of_sales_per_category.sql +1 -0
  31. api_logic_server_cli/prototypes/nw/api/api_discovery/ontimize_api.py +495 -0
  32. api_logic_server_cli/prototypes/nw/api/api_discovery/sales_by_category.html +76 -0
  33. api_logic_server_cli/prototypes/nw/api/api_discovery/sales_by_category.sql +1 -0
  34. api_logic_server_cli/prototypes/nw/api/api_discovery/system.py +77 -0
  35. api_logic_server_cli/prototypes/nw/database/database_discovery/graphics_services.py +173 -0
  36. api_logic_server_cli/prototypes/nw/ui/admin/home.js +5 -0
  37. api_logic_server_cli/prototypes/nw/ui/reference_react_app/DEPARTMENT_TREE_VIEW.md +66 -0
  38. api_logic_server_cli/prototypes/nw/ui/reference_react_app/README.md +21 -4
  39. api_logic_server_cli/prototypes/nw/ui/reference_react_app/package.json +4 -0
  40. api_logic_server_cli/prototypes/nw/ui/reference_react_app/public/index.html +3 -0
  41. api_logic_server_cli/prototypes/nw/ui/reference_react_app/src/App.js +8 -1
  42. api_logic_server_cli/prototypes/nw/ui/reference_react_app/src/CustomLayout.js +20 -0
  43. api_logic_server_cli/prototypes/nw/ui/reference_react_app/src/Department.js +511 -24
  44. api_logic_server_cli/prototypes/nw/ui/reference_react_app/src/DepartmentTree.js +147 -0
  45. api_logic_server_cli/prototypes/nw/ui/reference_react_app/src/Employee.js +230 -18
  46. api_logic_server_cli/prototypes/nw/ui/reference_react_app/src/LandingPage.js +264 -0
  47. api_logic_server_cli/prototypes/nw/ui/reference_react_app/src/Supplier.js +359 -121
  48. api_logic_server_cli/prototypes/nw/ui/reference_react_app/src/index.js +1 -0
  49. {apilogicserver-15.0.37.dist-info → apilogicserver-15.0.40.dist-info}/METADATA +1 -1
  50. {apilogicserver-15.0.37.dist-info → apilogicserver-15.0.40.dist-info}/RECORD +54 -25
  51. api_logic_server_cli/prototypes/base/docs/training/admin_app_unused.md +0 -156
  52. {apilogicserver-15.0.37.dist-info → apilogicserver-15.0.40.dist-info}/WHEEL +0 -0
  53. {apilogicserver-15.0.37.dist-info → apilogicserver-15.0.40.dist-info}/entry_points.txt +0 -0
  54. {apilogicserver-15.0.37.dist-info → apilogicserver-15.0.40.dist-info}/licenses/LICENSE +0 -0
  55. {apilogicserver-15.0.37.dist-info → apilogicserver-15.0.40.dist-info}/top_level.txt +0 -0
@@ -12,10 +12,10 @@ ApiLogicServer CLI: given a database url, create [and run] customizable ApiLogic
12
12
  Called from api_logic_server_cli.py, by instantiating the ProjectRun object.
13
13
  '''
14
14
 
15
- __version__ = "15.00.37" # last public release: 15.00.36 (15.00.12)
15
+ __version__ = "15.00.40" # last public release: 15.00.36 (15.00.12)
16
16
  recent_changes = \
17
17
  f'\n\nRecent Changes:\n' +\
18
- "\t07/02/2024 - 15.00.37: minor bug in mgr symlink creation, nw cards, mgr readme diagnostics, mcp printer \n"\
18
+ "\t07/08/2024 - 15.00.40: copilot uSvc vibe, fix mgr symlink creation, nw cards, mgr readme diagnostics, mcp printer, bug[98] \n"\
19
19
  "\t06/30/2024 - 15.00.33: Tech Preview: genai-logic genai-add-app --vibe, bug [96, 97] \n"\
20
20
  "\t06/10/2024 - 15.00.12: MCP Security, win fixes for readme, graphics quotes \n"\
21
21
  "\t06/08/2024 - 15.00.10: MCP, optional shortening of stacktrace lines, bugfix[92] \n"\
@@ -1,3 +1,3 @@
1
- last_created_date: July 01, 2025 14:38:20
1
+ last_created_date: July 08, 2025 21:48:29
2
2
  last_created_project_name: samples/nw_sample_nocust
3
- last_created_version: 15.00.35
3
+ last_created_version: 15.00.39
@@ -906,10 +906,11 @@ def call_chatgpt(messages: List[Dict[str, str]], api_version: str, using: str, r
906
906
  request_path.parent.mkdir(parents=True, exist_ok=True)
907
907
  return request_path
908
908
 
909
- def string_to_lines(dict_long_string: dict) -> dict:
909
+ def string_to_lines(dict_long_string: list) -> dict:
910
910
  result = dict_long_string
911
- if isinstance(result[1]['content'], str):
912
- result[1]['content'] = result[1]['content'].split('\n')
911
+ if len(result) > 1:
912
+ if isinstance(result[1]['content'], str):
913
+ result[1]['content'] = result[1]['content'].split('\n')
913
914
  return result
914
915
 
915
916
  try:
@@ -0,0 +1,10 @@
1
+ # Primary Copilot Instructions
2
+
3
+ **Note**: The main Copilot instructions are in `.vscode/.copilot-instructions.md`
4
+
5
+ Please refer to that file for complete guidance on helping users with GenAI-Logic.
6
+
7
+ ## Quick Reference for AI Assistants
8
+
9
+ When users ask "what do I do now?":
10
+ 1. Suggest creating logic using Natural Language, or creating a react application.
@@ -0,0 +1,178 @@
1
+ # GitHub Copilot Instructions for GenAI-Logic (aka API Logic Server) Projects
2
+
3
+ ## Project Type: Auto-Generated Microservice
4
+
5
+ This is a **GenAI-Logic (aka API Logic Server) project** - a complete, working microservice - auto-generated from a database schema.
6
+
7
+ ## ⚠️ IMPORTANT: What's Already Built
8
+
9
+ **DO NOT recreate these - they're already working:**
10
+
11
+ 1. **Admin Web Application** - Live at `http://localhost:5656`
12
+ 2. **REST API Endpoints** - All database tables exposed at `/api/*`
13
+ 3. **Database Models** - Complete SQLAlchemy ORM in `database/models.py`
14
+ 4. **Authentication System** - JWT-based auth framework
15
+ 5. **Business Logic Engine** - Declarative rules system
16
+
17
+ ## 🎯 Common Tasks
18
+
19
+ If the user asks "what do I do now?", these subsections are good suggestions.
20
+
21
+ List these as choices, do not just do all of them at once - that would be overwhelming.
22
+
23
+ ### 🚀 To Run This Project
24
+
25
+ Use F5 (pre-configured run configuration - supports debugger for server logic), or (when focused on client apps):
26
+
27
+ ```bash
28
+ python api_logic_server_run.py
29
+ # Then open: http://localhost:5656
30
+ ```
31
+
32
+ ### Adding Business Logic
33
+ Use `docs/training` to accept Natural Language logic, and translate it into rules like:
34
+
35
+ ```python
36
+ # Edit: logic/declare_logic.py
37
+ Rule.sum(derive=Customer.Balance, as_sum_of=Order.AmountTotal)
38
+ Rule.constraint(validate=Customer, as_condition=lambda row: row.Balance <= row.CreditLimit)
39
+ ```
40
+
41
+ Generally CoPilot solicits Natural Language logic for translation (see logic/logic_discovery/readme_logic_discovery.md),
42
+ but you can also offer to suggest rules.
43
+
44
+ ### Adding MCP
45
+
46
+ The API is automatically MCP-enabled.
47
+
48
+ To add MCP Client (requires OpenAI key):
49
+
50
+ ```bash
51
+ # Add MCP Client
52
+ genai-logic genai-add-mcp-client
53
+ ```
54
+
55
+ ### Configuring Admin UI
56
+
57
+ This is built when project is created - no need to add it.
58
+ Customize by editing the underlying yaml.
59
+
60
+ ```yaml
61
+ # Edit: ui/admin/admin.yaml
62
+ resources:
63
+ Customer:
64
+ attributes:
65
+ - name: CompanyName
66
+ search: true
67
+ sort: true
68
+ ```
69
+
70
+ ### Create and Customize React Apps
71
+
72
+ Complete customization is provided by generating a React Application (requires OpenAI key, Node):
73
+
74
+ ```bash
75
+ # Create: ui/admin/my-app-name
76
+ genai-logic genai-create-app --app-name=my-app-name --vibe
77
+ ```
78
+
79
+ Then, `npm install` and `npm start`
80
+
81
+ Temporary restriction: security must be disabled.
82
+
83
+ Customize using CoPilot chat, with `docs/training`.
84
+
85
+ ### Security - Role-Based Access Control
86
+
87
+ Configure:
88
+ ```
89
+ als add-auth --provider-type=sql --db-url=
90
+ als add-auth --provider-type=sql --db_url=postgresql://postgres:p@localhost/authdb
91
+
92
+ als add-auth --provider-type=keycloak --db-url=localhost
93
+ als add-auth --provider-type=keycloak --db-url=hardened
94
+
95
+ als add-auth --provider-type=None # to disable
96
+ ```
97
+
98
+ Keycloak quick start [(more information here:)](https://apilogicserver.github.io/Docs/Security-Keycloak/)
99
+ ```bash
100
+ cd devops/keycloak
101
+ docker compose up
102
+ als add-auth --provider-type=keycloak --db-url=localhost
103
+ ```
104
+
105
+ For more on KeyCloak: https://apilogicserver.github.io/Docs/Security-Keycloak/
106
+
107
+ Declaration:
108
+ ```python
109
+ # Edit: security/declare_security.py
110
+ Grant(on_entity=Customer, to_role=sales, filter=lambda: Customer.SalesRep == current_user())
111
+ ```
112
+
113
+ ### Adding Custom API Endpoints
114
+ ```python
115
+ # Edit: api/customize_api.py
116
+ @app.route('/api/custom-endpoint')
117
+ def my_endpoint():
118
+ return {"message": "Custom endpoint"}
119
+ ```
120
+
121
+ ### Customize Models - Add Derived attributes
122
+
123
+ Here is a sample derived attribute, `proper_salary`:
124
+
125
+ ```python
126
+
127
+ # add derived attribute: https://github.com/thomaxxl/safrs/blob/master/examples/demo_pythonanywhere_com.py
128
+ @add_method(models.Employee)
129
+ @jsonapi_attr
130
+ def __proper_salary__(self): # type: ignore [no-redef]
131
+ import database.models as models
132
+ import decimal
133
+ if isinstance(self, models.Employee):
134
+ rtn_value = self.Salary
135
+ if rtn_value is None:
136
+ rtn_value = decimal.Decimal('0')
137
+ rtn_value = decimal.Decimal('1.25') * rtn_value
138
+ self._proper_salary = int(rtn_value)
139
+ return self._proper_salary
140
+ else:
141
+ rtn_value = decimal.Decimal('0')
142
+ self._proper_salary = int(rtn_value)
143
+ return self._proper_salary
144
+
145
+ @add_method(models.Employee)
146
+ @__proper_salary__.setter
147
+ def _proper_salary(self, value): # type: ignore [no-redef]
148
+ self._proper_salary = value
149
+ print(f'_proper_salary={self._proper_salary}')
150
+ pass
151
+
152
+ models.Employee.ProperSalary = __proper_salary__
153
+
154
+ ```
155
+
156
+ When customizing SQLAlchemy models:
157
+
158
+ Don't use direct comparisons with database fields in computed properties
159
+ Convert to Python values first using float(), int(), str()
160
+ Use property() function instead of @jsonapi_attr for computed properties
161
+ Always add error handling for type conversions
162
+
163
+ ## 📁 Key Directories
164
+
165
+ - `logic/` - Business rules (declarative)
166
+ - `api/` - REST API customization
167
+ - `security/` - Authentication/authorization
168
+ - `database/` - Data models and schemas
169
+ - `ui/admin/` - Admin interface configuration
170
+ - `ui/app/` - Alternative Angular admin app
171
+
172
+ ## 💡 Helpful Context
173
+
174
+ - This uses Flask + SQLAlchemy + SAFRS for JSON:API
175
+ - Admin UI is React-based with automatic CRUD generation
176
+ - Business logic uses LogicBank (declarative rule engine)
177
+ - Everything is auto-generated from database introspection
178
+ - Focus on CUSTOMIZATION, not re-creation
@@ -0,0 +1,43 @@
1
+ # API Logic Server Project
2
+
3
+ This is an **auto-generated microservice** created by [API Logic Server](https://apilogicserver.github.io/).
4
+
5
+ ## 🚀 What's Included (Auto-Generated)
6
+
7
+ - **Complete Admin Web App** - Multi-table CRUD interface
8
+ - **JSON:API REST Endpoints** - All database tables exposed
9
+ - **Business Logic Engine** - Declarative rules system
10
+ - **Security Framework** - Authentication and authorization
11
+ - **Swagger Documentation** - Interactive API docs
12
+
13
+ ## Quick Start
14
+
15
+ ```bash
16
+ # Run the complete system
17
+ python api_logic_server_run.py
18
+
19
+ # Access admin app
20
+ open http://localhost:5656
21
+
22
+ # View API documentation
23
+ open http://localhost:5656/api
24
+ ```
25
+
26
+ ## 📖 Documentation
27
+
28
+ - [Getting Started Guide](./docs/COPILOT_GUIDE.md)
29
+ - [Main README](./readme.md)
30
+ - [API Logic Server Docs](https://apilogicserver.github.io/)
31
+
32
+ ## 🛠️ Customization
33
+
34
+ This is a **working system** - customize rather than recreate:
35
+
36
+ - **Business Logic**: `logic/declare_logic.py`
37
+ - **API Endpoints**: `api/customize_api.py`
38
+ - **Security Rules**: `security/declare_security.py`
39
+ - **Admin UI Config**: `ui/admin/admin.yaml`
40
+
41
+ ---
42
+
43
+ **Generated by API Logic Server** - Instant microservices from your database.
@@ -1,19 +1,31 @@
1
1
  #!/usr/bin/env python3
2
2
 
3
3
  ###############################################################################
4
+ # 🚀 API Logic Server - AUTO-GENERATED MICROSERVICE
4
5
  #
5
- # This file initializes and starts the API Logic Server, e.g.:
6
- # $ Use your IDE Run Configurations (for debug)
7
- # $ sh run.sh
8
- # $ python3 api_logic_server_run.py [--help]
9
- # $ gunicorn --log-level=info -b 0.0.0.0:5656 -w2 --reload api_logic_server_run:flask_app
6
+ # This file starts a COMPLETE, WORKING microservice with:
7
+ # Admin Web App at http://localhost:5656 (React-based, multi-table CRUD)
8
+ # JSON:API endpoints at http://localhost:5656/api/* (auto-generated from database)
9
+ # Swagger documentation at http://localhost:5656/api
10
+ # Business logic engine (declarative rules)
11
+ # ✅ Security framework (authentication/authorization)
10
12
  #
11
- # Then, access the Admin App and API via the Browser, eg:
12
- # http://api_logic_server_host:api_logic_server_port
13
+ # 🎯 TO RUN:
14
+ # Press F5 in VSCode, or run: python api_logic_server_run.py
15
+ #
16
+ # 🌐 TO ACCESS:
17
+ # Admin App: http://localhost:5656
18
+ # API Docs: http://localhost:5656/api
19
+ #
20
+ # 📝 TO CUSTOMIZE:
21
+ # See docs/COPILOT_GUIDE.md for GitHub Copilot guidance
22
+ # Logic: logic/declare_logic.py
23
+ # API: api/customize_api.py
24
+ # Security: security/declare_security.py
13
25
  #
14
26
  # You typically do not customize this file.
15
27
  #
16
- # (v api_logic_server_version, api_logic_server_created_on)
28
+ # (v 15.00.38, July 06, 2025 22:11:00)
17
29
  #
18
30
  # See Main Code (at end).
19
31
  # Use log messages to understand API and Logic activation.
@@ -0,0 +1,13 @@
1
+ I need to enhance a React Admin supplier page to include a professional, interactive world map view that displays suppliers on a real map with proper geography. Requirements:
2
+
3
+ 1. **Use a proper mapping library** (like Leaflet.js) - NOT custom SVG drawings
4
+ 2. **Real world map** with accurate geography, countries, and coastlines
5
+ 3. **Interactive controls**: pan, zoom, mouse wheel support
6
+ 4. **Clickable supplier markers** that navigate to supplier detail pages
7
+ 5. **Professional UI** with map legend and controls
8
+ 6. **Toggle between list and map view**
9
+ 7. **Position suppliers** by country with slight offsets to avoid overlap
10
+
11
+ The current supplier data has fields: Id, CompanyName, ContactName, City, Country, etc.
12
+
13
+ Please install the necessary mapping library dependencies and create a production-ready map component that looks professional like Google Maps, not a hand-drawn cartoon map.
@@ -0,0 +1,10 @@
1
+ Provide an option to see departments either as a list (as now), or as a tree. The tree expands to show related sub departments, as links. If I click on the dept name link, then open the department "show" to the right.
2
+
3
+ TECHNICAL CONSTRAINTS:
4
+
5
+ - Avoid recursion stack overflow: include proper termination conditions
6
+ - Handle mixed data types: use parseInt() for ID comparisons
7
+ - Prevent import conflicts: use aliases for Material-UI components
8
+ - Verify data relationships: check actual field names in backend
9
+ - Use incremental development: start simple, add complexity gradually
10
+ - Test each layer: tree logic → expansion → detail panel → tabs
@@ -0,0 +1,9 @@
1
+ GenAI-Logic APIs are pre-configured to support MCP - see `api/api_discovery/mcp_discovery.py`.
2
+
3
+ `integration/mcp/mcp_client_executor.py` provides an mcp client executor. You can enable an MCP User Interface:
4
+
5
+ ```bash
6
+ genai-logic genai-add-mcp-client
7
+ ```
8
+
9
+ For more information, [click here](https://apilogicserver.github.io/Docs/Integration-MCP/#mcp-client-executor-ui).
@@ -0,0 +1,9 @@
1
+ You can declare logic in `declare_logic.py`,
2
+ but that can lead to a lot of rules in 1 file.
3
+
4
+ A *best practice* is to create logic files in this directory,
5
+ named after the use case (e.g., `check_credit.py`).
6
+
7
+ The easiest way to to copy/paste `use_case.py` to a new file, then
8
+ add your logic either by Natural Language (use your Coding Assistant, such as CoPilot),
9
+ or your IDE's code completion.
@@ -0,0 +1,27 @@
1
+ import datetime
2
+ from decimal import Decimal
3
+ from logic_bank.exec_row_logic.logic_row import LogicRow
4
+ from logic_bank.extensions.rule_extensions import RuleExtension
5
+ from logic_bank.logic_bank import Rule
6
+ from database import models
7
+ import api.system.opt_locking.opt_locking as opt_locking
8
+ from security.system.authorization import Grant
9
+ import logging
10
+ from flask import jsonify
11
+
12
+
13
+ """ Best practice: create logic files for each use case """
14
+
15
+ app_logger = logging.getLogger(__name__)
16
+
17
+
18
+ def declare_logic():
19
+ """
20
+ Use GenAI to convert Natural Language into logic, paste here. See readme_logic_discovery_readme.md for an example.
21
+
22
+ Sample logic:
23
+ Rule.constraint(validate=models.Customer,
24
+ as_condition=lambda row: row.CompanyName != 'x',
25
+ error_msg="CompanyName cannot be 'x'")
26
+ """
27
+ pass
@@ -1,6 +1,6 @@
1
1
  This describes how to use Logic; for more information, [see here](https://apilogicserver.github.io/Docs/Logic-Why).
2
2
 
3
- > Key Takeway - Logic: Multi-table Derivation and Constraint Rules, Extensible with Python
3
+ > What is Logic: Multi-table Derivation and Constraint Rules, Extensible with Python
4
4
  <br>Rules are:
5
5
  <br>1. **Declared** in your IDE - 40X more concise
6
6
  <br>2. **Activated** on server start
@@ -10,6 +10,61 @@ This describes how to use Logic; for more information, [see here](https://apilog
10
10
 
11
11
  &nbsp;
12
12
 
13
+ ## 🚀 Quick Start, using the `basic_demo` sample database
14
+
15
+ You can provide prompts like this to CoPilot. This is a good approach for new users:
16
+
17
+ ```text title="Declare Logic in Natural Language"
18
+ Create Business Logic for Use Case = Check Credit:
19
+ 1. The Customer's balance is less than the credit limit
20
+ 2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
21
+ 3. The Order's amount_total is the sum of the Item amount
22
+ 4. The Item amount is the quantity * unit_price
23
+ 5. The Item unit_price is copied from the Product unit_price
24
+
25
+ Use case: App Integration
26
+ 1. Send the Order to Kafka topic 'order_shipping' if the date_shipped is not None.
27
+ ```
28
+
29
+ Basic process:
30
+ 1. Create a file such as `logic/logic_discovery/check_credit.py` (e.g., copy from `use_case.py`).
31
+ 2. Paste the prompt above into CoPilot - use `docs/training` to generate logic
32
+ 3. Paste the generated logic into `logic/logic_discovery/check_credit.py`
33
+
34
+ From the Natural Language, Copilot will create Python rules (you can also create these directly using code completion):
35
+ ```python
36
+ if os.environ.get("WG_PROJECT"):
37
+ # Inside WG: Load rules from docs/expprt/export.json
38
+ load_verify_rules()
39
+ else:
40
+ # Outside WG: load declare_logic function
41
+ from logic.logic_discovery.auto_discovery import discover_logic
42
+ discover_logic()
43
+
44
+ # Logic from GenAI: (or, use your IDE w/ code completion)
45
+ from database.models import Product, Order, Item, Customer, SysEmail
46
+
47
+ # Ensure the customer's balance is less than their credit limit
48
+ Rule.constraint(validate=Customer, as_condition=lambda row: row.balance <= row.credit_limit, error_msg="Customer balance ({row.balance}) exceeds credit limit ({row.credit_limit})")
49
+
50
+ # Derive the customer's balance as the sum of order totals where not yet shipped.
51
+ Rule.sum(derive=Customer.balance, as_sum_of=Order.amount_total, where=lambda row: row.date_shipped is None)
52
+
53
+ # Derive the order's total amount from the sum of item amounts.
54
+ Rule.sum(derive=Order.amount_total, as_sum_of=Item.amount)
55
+
56
+ # Calculate item amount based on quantity and unit price.
57
+ Rule.formula(derive=Item.amount, as_expression=lambda row: row.quantity * row.unit_price)
58
+
59
+ # Copy unit price from product to item.
60
+ Rule.copy(derive=Item.unit_price, from_parent=Product.unit_price)
61
+
62
+ # Send order details to Kafka if order is shipped.
63
+ Rule.after_flush_row_event(on_class=Order, calling=kafka_producer.send_row_to_kafka, if_condition=lambda row: row.date_shipped is not None, with_args={'topic': 'order_shipping'})
64
+
65
+ # End Logic from GenAI
66
+ ```
67
+
13
68
  ## Natural Language vs. IDE
14
69
 
15
70
  If you are using WebGenAI, you can specify rules in Natural Language. You can also augment them in the IDE using code completion. There are some important usage guidelines.
@@ -18,6 +73,20 @@ If you are using WebGenAI, you can specify rules in Natural Language. You can al
18
73
 
19
74
  &nbsp;
20
75
 
76
+ ## Using Discovery
77
+
78
+ You can declare logic in `declare_logic.py`,
79
+ but that can lead to a lot of rules in 1 file.
80
+
81
+ A *best practice* is to create logic files in `logic/logic_discovery`,
82
+ named after the use case (e.g., `check_credit.py`).
83
+
84
+ The easiest way to to copy/paste `use_case.py` to a new file, then
85
+ add your logic either by Natural Language (use your Coding Assistant, such as CoPilot),
86
+ or your IDE's code completion.
87
+
88
+ <br>
89
+
21
90
  ## Examples
22
91
  Examples from tutorial project:
23
92
  * Examples drawn from [tutorial project](https://github.com/ApiLogicServer/demo/blob/main/logic/declare_logic.py)
@@ -1,4 +1,29 @@
1
- # Quick Start
1
+ # API Logic Server - Auto-Generated Microservice
2
+
3
+ **🎯 What's Automatically Created:**
4
+ - ✅ **Admin Web App** - Multi-page React app at `http://localhost:5656`
5
+ * Customize at `ui/admin/admin.yaml`
6
+ * You can also create a fully customizabe react app: `gail genai-add-app --app-name=react-app --vibe`
7
+ - ✅ **JSON:API Endpoints** - REST API for all database tables at `/api/*`
8
+ - ✅ **Swagger Documentation** - Interactive API docs at `/api`
9
+ - ✅ **Business Logic Engine** - Declarative rules in `logic/declare_logic.py`
10
+ - ✅ **Security Framework** - Authentication/authorization in `security/`, using
11
+ ```
12
+ als add-auth --provider-type=sql --db-url=
13
+ als add-auth --provider-type=sql --db_url=postgresql://postgres:p@localhost/authdb
14
+
15
+ als add-auth --provider-type=keycloak --db-url=localhost
16
+ als add-auth --provider-type=keycloak --db-url=hardened
17
+
18
+ als add-auth --provider-type=None # to disable
19
+ ```
20
+ - ✅ **Database Models** - SQLAlchemy ORM in `database/models.py`
21
+
22
+ **🚀 Ready to Run:** This is a complete, working system. Just press F5 or run `python api_logic_server_run.py`
23
+
24
+ ---
25
+
26
+ # 🚀 Quick Start
2
27
 
3
28
  **Microservice Automation Complete -- run to verify:** for **VSCode** projects except those downloaded from Web/GenAI:
4
29
  1. `Press F5 to Run` (your venv is defaulted)
@@ -185,10 +210,10 @@ For information on Managing API Logic Projects, [click here](https://apilogicser
185
210
 
186
211
  | About | Info |
187
212
  |:-------------------------|:-----------------------------------|
188
- | Created | creation-date |
189
- | API Logic Server Version | api_logic_server_version |
190
- | Created in directory | api_logic_server_project_directory |
191
- | API Name | api_logic_server_api_name |
213
+ | Created | July 06, 2025 22:11:00 |
214
+ | API Logic Server Version | 15.00.38 |
215
+ | Created in directory | nw_database_project |
216
+ | API Name | api |
192
217
  | Execution begins with | `api_logic_server_run.py` |
193
218
 
194
219
 
@@ -0,0 +1,17 @@
1
+ You can add Role Based Access Control (RBAC) to your project, providing:
2
+
3
+ * authentication: based on sql tables for users / roles, and
4
+ * authorization: declarative for-filters for roles.
5
+
6
+ Common commands:
7
+
8
+ ```bash
9
+ ```
10
+ als add-auth --provider-type=sql --db-url=
11
+ als add-auth --provider-type=sql --db_url=postgresql://postgres:p@localhost/authdb
12
+
13
+ als add-auth --provider-type=keycloak --db-url=localhost
14
+ als add-auth --provider-type=keycloak --db-url=hardened
15
+
16
+ als add-auth --provider-type=None # to disable
17
+ ```
@@ -0,0 +1,13 @@
1
+ # Primary Copilot Instructions
2
+
3
+ **Note**: The main Copilot instructions are in `.vscode/.copilot-instructions.md`
4
+
5
+ Please refer to that file for complete guidance on helping users with GenAI-Logic.
6
+
7
+ ## Quick Reference for AI Assistants
8
+
9
+ When users ask "what do I do now?":
10
+ 1. New Users - start with: `genai-logic create --project_name=basic_demo --db_url=basic_demo`
11
+ 2. Suggest creating databases, explain sample databases
12
+ 2. Use CLI commands, not Docker scripts for project creation
13
+ 3. Follow the complete instructions in `.vscode/.copilot-instructions.md`
@@ -0,0 +1,58 @@
1
+ # GitHub Copilot Instructions for GenAI-Logic (aka API Logic Server) - Project Manager
2
+
3
+ ⚠️ **IMPORTANT FOR AI ASSISTANTS**: Always read and follow these instructions when helping users with this project.
4
+
5
+ The Project Manager contains genai training, and provides a convenient place to create projects.
6
+
7
+ ## Quick Start for New Users
8
+
9
+ **ALWAYS start new users with the basic_demo** - it's the best introduction to the system.
10
+
11
+ ## Creating Projects
12
+
13
+ There are multiple ways to create projects - see the subsections below.
14
+
15
+ ### Create Projects from an existing database
16
+
17
+ sqlite sample databases at `samples/dbs`.
18
+
19
+ ```bash
20
+ genai-logic create --project_name=nw --db_url=sqlite:///samples/dbs/nw.sqlite
21
+ ```
22
+
23
+ ### Create Projects with new databases (requires OpenAI key):
24
+
25
+ Describe database and logic in Natural Language.
26
+
27
+ See samples at `system/genai/examples`. For example:
28
+
29
+ ```bash
30
+ genai-logic genai --using=system/genai/examples/genai_demo/genai_demo.prompt --project-name=genai_demo
31
+ ```
32
+
33
+ ### Sample basic_demo
34
+
35
+ The best place to start is to create the `basic_demo`.
36
+
37
+ It's a small sqlite database, and provides a readme that explores the project, and how to customize it:
38
+
39
+ ```bash
40
+ genai-logic create --project_name=basic_demo --db_url=basic_demo
41
+ ```
42
+
43
+ ## AI Assistant Guidelines
44
+
45
+ When users ask "what do I do now?" or similar questions:
46
+
47
+ 1. **Always recommend starting with basic_demo** using the command above
48
+ 2. **Use CLI commands** (genai-logic) not Docker scripts for project creation
49
+ 3. **Refer to existing sample databases** in `samples/dbs/` for examples
50
+ 4. **Point to GenAI examples** in `system/genai/examples/` for AI-generated projects
51
+ 5. **Emphasize the 20-minute evaluation workflow** described in the main README
52
+
53
+ ## Available Databases
54
+ - `basic_demo` - Best for first-time users
55
+ - `nw.sqlite` - Northwind sample
56
+ - `chinook.sqlite` - Music store sample
57
+ - `classicmodels.sqlite` - Classic car models sample
58
+
@@ -9,7 +9,7 @@
9
9
  "workbench.editorAssociations": {
10
10
  "*.md": "vscode.markdown.preview.editor"
11
11
  },
12
- "workbench.colorTheme": "Office Theme (Word)",
13
- "workbench.preferredLightColorTheme": "Office Theme (Word)"
12
+ "workbench.colorTheme": "Arduino",
13
+ "workbench.preferredLightColorTheme": "Arduino"
14
14
  }
15
15
  }
@@ -15,12 +15,24 @@ Instructions: Copy in Sample-Basic-Demo (Replace "This illustrates" up to "Explo
15
15
 
16
16
  # Welcome to GenAI-Logic
17
17
 
18
- 1. ***Instant mcp-enabled microservices*** (APIs and Admin Apps), from a database or **GenAI prompt** -- one command and you are ready for MCP, Vibe and Business User Collaboration.
18
+ ## 🚀 New Users: Start Here!
19
+
20
+ **Bootstrap Copilot by pasting the following into the chat:**
21
+ ```
22
+ Please find and read all the readme files.
23
+ ```
24
+
25
+ <br>
26
+
27
+ ## What is GenAI-Logic
28
+
29
+ 1. ***Instant mcp-enabled microservice creation*** (APIs and Admin Apps), from a database or **GenAI prompt** -- one command and you are ready for MCP, Vibe and Business User Collaboration.
19
30
 
20
31
  2. ***Customize*** with **Declarative Rules** and Python in your IDE, standard container deployment
21
32
 
22
33
  You are in the [API Logic Server Manager](Manager.md). This is a good place to manage projects, create notes and resources, etc.
23
34
 
35
+
24
36
  &nbsp;
25
37
 
26
38
  # Product Tour (Start Here)
@@ -5,11 +5,11 @@
5
5
  }
6
6
  ],
7
7
  "settings": {
8
- "debug.console.wordWrap": false,
8
+ "debug.console.wornw graphsdWrap": false,
9
9
  "workbench.editorAssociations": {
10
10
  "*.md": "vscode.markdown.preview.editor"
11
11
  },
12
- "workbench.colorTheme": "Office Theme (Word)",
13
- "workbench.preferredLightColorTheme": "Office Theme (Word)"
12
+ "workbench.colorTheme": "Office Theme (Excel)",
13
+ "workbench.preferredLightColorTheme": "Office Theme (Excel)"
14
14
  }
15
15
  }