Manager
Welcome to GenAI-Logic
What is GenAI-Logic:
-
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.
-
Customize with Declarative Rules and Python in your IDE, standard container deployment
This is the start page for the GenAI-Logic Manager. The Manager is a good place to manage projects, create notes and resources, etc.
🤖 Bootstrap Copilot by pasting the following into the chat:
Please load `.github/.copilot-instructions.md`.
Important: be sure CoPilot is in "Agent" Mode. "Ask" will not work. Also, we get consistently good results with
Claude Sonnet 4.5.
🚀 First Time Here? Start with basic_demo
Create basic_demo (auto-opens with guided tour option):
Inside the project: Say to your AI assistant: "Guide me through basic_demo" (30-45 min hands-on tour)
This tour teaches you the product basics: API creation, declarative rules, security, and Python customization. It's fail-safe (uses add-cust to restore if you make mistakes) and is the recommended starting point.
For detailed self-paced exploration: See Sample-Basic-Demo
📚 Demo Catalog
0. Product Basics (Start Here)
Learn core concepts with the guided tour:
| Demo | Command | What You'll Learn | Duration |
|---|---|---|---|
| basic_demo | genai-logic create --project_name=basic_demo --db_url=sqlite:///samples/dbs/basic_demo.sqlite | • Instant API + Admin App from database • Declarative business logic (40X more concise) • Role-based security • Python extensibility • Iteration with add-cust |
30-45 min (guided tour) |
After creation: Say "Guide me through basic_demo" to your AI assistant
1. Strategic Use Cases (From genai-logic.com)
Explore the three key use cases from our home page:
| Use Case | Demo | Command | What You'll Learn |
|---|---|---|---|
| AI Rules | basic_demo_ai_rules_supplier | Sample-ai-rules_supplier | Optimal Supplier |
| Use Case 1: Governed MCP Server | basic_demo_mcp_send_email | Sample-Basic-Demo-Vibe.md | Bus Users compose new service to send email to overdue customers, subject to email opt-out |
| Use Case 2: Vibe Development Backend | basic_demo_vibe | Admin-Vibe-Sample | Cars and Maps |
| Use Case 3: Business Users | webgenai | See WebGenAI | WebG + download |
| Use Case 1.X: Governed MCP Server (basic) | basic_demo_ai_mcp_copilot | TBD | test rules via Copilot access to MCP Server |
2. Additional Demos
Advanced examples and specialized patterns:
| Demo | Command | What You'll Learn |
|---|---|---|
| mcp_ai | TBD | • Advanced MCP patterns • Complex AI integrations • Production MCP deployment |
Explore GenAI CLI
1. New Database - using GenAI Microservice Automation (Experiment with AI - Signup optional)
You can do this with or without signup:
- If you have signed up (see Get an OpenAI Key, below), this will create a new database and project called
genai_demo, and open the project. It's created usinggenai_demo.prompt, visible in left Explorer pane:
- Or, you can simulate the process (no signup) using:
als genai --repaired-response=system/genai/examples/genai_demo/genai_demo.response_example --project-name=genai_demo
Verify it's operating properly:
- Run Configurations are provided to start the server
- Verify the logic by navigating to a Customer with an unshipped order, and altering one of the items to have a very large quantity
- Observe the constraint operating on the rollup of order amount_totals.
- View the logic in
logic/declare_logic.py - Put a breakpoint on the
as_condition. Observe the console log to see rule execution for this multi-table transaction.
- View the logic in
What Just Happened? Next Steps...
genai processing is shown below (internal steps denoted in grey):
-
You create your.prompt file, and invoke
als genai --using=your.prompt. genai then creates your project as follows:a. Submits your prompt to the
ChatGPT APIb. Writes the response to file, so you can correct and retry if anything goes wrong
c. Extracts model.py from the response
d. Invokes
als create-from-model, which creates the database and your project -
Your created project is opened in your IDE, ready to execute and customize.
a. Review
Tutorial, Explore Customizations.

You can iterate the logic and data model
The approach for an iteration is to create a new project from an existing one:
- add another prompt to an existing projects
docsdirectory, specifying your changes - use
als genai, specifying--usingexisting projectsdocsdirectory, and--project-nameas the output project
Logic iterations are particuarly useful. For example, here we take the basic check-credit logic, and add:
Provide a 10% discount when buying more than 10 carbon neutral products.
The Item carbon neutral is copied from the Product carbon neutral
Explore genai_demo_iteration_discount. It's an iteration of basic_demo (see system/genai/examples/genai_demo/genai_demo_iteration_discount/002_create_db_models.prompt). This will add carbon_neutral to the data model, and update the logic to provide the discount:
Iterate Business Logic:
# Iterate with data model and logic
als genai --project-name='genai_demo_with_discount' --using=system/genai/examples/genai_demo/genai_demo_iteration_discount
# open Docs/db.dbml
You can perform model iterations: add new columns/tables, while keeping the prior model intact. First, we create a project with no logic, perhaps just to see the screens (this step is optional, provided just to illustrate that iterations create new projects from existing ones):
Iterate Without Logic:
# Step 1 - create without logic
als genai --project-name='genai_demo_no_logic' --using=system/genai/examples/genai_demo/genai_demo_no_logic.prompt
# open Docs/db.dbml
Then, we would create another prompt in the docs directory with our model changes. We've already created these for you in system/genai/examples/genai_demo/genai_demo_iteration - we use that to alter the data model (see system/genai/examples/genai_demo/genai_demo_iteration/004_iteration_renames_logic.prompt):
Iterate With Logic:
# Iterate with data model and logic
als genai --project-name='genai_demo_with_logic' --using=system/genai/examples/genai_demo/genai_demo_iteration
# open Docs/db.dbml
Explore genai_demo_iteration - observe the --using is a directory of prompts. These include the prompts from the first example, plus an iteration prompt (004_iteration_renames_logic.prompt) to rename tables and add logic.
You can declare informal logic
You can declare rules using dot notation, or more informally:
Informal Logic (no dot notation):
Multi-Rule Logic
You can add new columns/tables, while keeping the prior model intact:
Multi-Rule Logic:
You can ask AI to suggest logic (great way to learn!)
You can create a project, and ask GenAI for logic suggestions:
1. Create Project, without Rules:
# 1. Create Project, without Rules
als genai --project-name='genai_demo_no_logic' --using=system/genai/examples/genai_demo/genai_demo_no_logic.prompt
2. Request Rule Suggestions:
# 2. Request Rule Suggestions
cd genai_demo_no_logic
als genai-logic --suggest
You can review the resultant logic suggestions in the genai_demo_no_logic project:
- See and edit:
docs/logic_suggestions/002_logic_suggestions.prompt(used in step 3, below)- This corresponds to the Logic Editor - Logic View in the WebGenAI web app
3. See the rules for the logic:
# 3. See the rule code for the logic
als genai-logic --suggest --logic='*'
Important notes about suggestions and generated code:
* --suggest --logic='*' is intended to enable you to identify logic that does not translate into proper code
* The example above was pretty good, but sometimes the results are downright silly:
* Just run suggest again, or
* Repair docs/logic_suggestions/002_logic_suggestions.prompt
Also...
* It is not advised to paste the code into logic/declare_logic.py
* The suggested logic may result in new data model attributes
* These are created automatically by running als genai (next step)
The logic suggestions directory now contains the prompts to create a new project with the suggested logic.
When you are ready to proceed:
1. Execute the following to create a new project (iteration), with suggested logic:
4. Create a new project with the Rule Suggestions:
# 4. Create a new project with the Rule Suggestions
cd .. # important - back to manager root dir
als genai --project-name='genai_demo_with_logic' --using=genai_demo_no_logic/docs/logic_suggestions
Observe:
1. The created project has the rule suggestions in logic/declare_logic.py
2. A revised Data Model in database/models.py that includes attributes introduced by the logic suggestions
3. Revised test database, initialized to reflect the derivations in the suggested logic
Internal Note: this sequence available in the run configs (s1/s4).
Fixup - update data model with new attributes from rules
Fixes project issues by updating the Data Model and Test Data:
when adding rules, such as using suggestions, you may introduce new attributes.
If these are missing, you will see exceptions when you start your project.
The genai-utils --fixup fixes such project issues by updating the Data Model and Test Data:
- Collects the latest model, rules, and test data from the project.
- Calls ChatGPT (or similar) to resolve missing columns or data in the project.
- Saves the fixup request/response under a 'fixup' folder.
- You then use this to create a new project
Setup
After starting the Manager:
0. Create Project Requiring Fixup:
# 0. Create a project requiring fixup
als genai --repaired-response=system/genai/examples/genai_demo/genai_demo_fixup_required.json --project-name=genai_demo_fixup_required
If you run this project, you will observe that it fails with:
Logic Bank Activation Error -- see https://apilogicserver.github.io/Docs/WebGenAI-CLI/#recovery-options
Invalid Rules: [AttributeError("type object 'Customer' has no attribute 'balance'")]
Missing Attrs (try als genai-utils --fixup): ['Customer.balance: constraint']
Fixup
To Fix it: 1. Run FixUp to add missing attributes to the fixup response data model:
# 1. Run FixUp to add missing attributes to the data model
cd genai_demo_fixup_required
als genai-utils --fixup
Finally, use the created fixup files to rebuild the project: 2. Rebuild the project from the fixup response data model:
# 2. Rebuild the project from the fixup response data model
cd ../
als genai --repaired-response=genai_demo_fixup_required/docs/fixup/response_fixup.json --project-name=fixed_project
The created project may still report some attributes as missing.
(ChatGPT seems to often miss attributes mentioned in sum/count where clauses.) To fix:
- Note the missing attributes(s) from the log
- Add them to
docs/003_suggest.prompt - Rebuild the project:
als genai --project-name='genai_demo_with_logic' --using=genai_demo_no_logic/docs
Internal Note: this sequence available in the run configs (f1/f2).
Create from WebGenAI, and import (merge) subsequent changes
You can use WebGenAI to create a project, and export it.
You (or colleagues) can make changes to both the WebGenAI project (on the web), and your downloaded project. You can import the WebGenAI project, and the system will merge changes to the data model and rules automatically.
This is possible since the logic is declarative, so ordering is automatic. This eliminates the troublesome merge issues so prevalent in procedural code. For more on import, click here.
The Manager pre-installs a sample project you can use to explore import:
cd system/genai/examples/genai_demo/wg_dev_merge/dev_demo_no_logic_fixed
als genai-utils --import-genai --using=../wg_demo_no_logic_fixed
Customer.balance and Product.carbon_neutral
2. The test data has been updated to include these attributes, with proper values
Rebuild the test data
Fixes project issues by rebuilding the database to conform to the derivation rules:
- Create genai_demo:
- Rebuild:
You can also execute directly, and iterate
You can add new columns/tables, while keeping the prior model intact:
Iterate:
AI somtimes fails - here's how to recover
AI results are not consistent, so the model file may need corrections. You can find it at system/genai/temp/model.py. You can correct the model file, and then run:
als create --project-name=genai_demo --from-model=system/genai/temp/create_db_models.py --db-url=sqlite
Or, correct the chatgpt response, and
als genai --repaired-response=system/genai/examples/genai_demo/genai_demo.response_example --project-name=genai_demo
We have seen failures such as:
- duplicate definition of
DECIMAL - unclosed parentheses
- data type errors in test data creation
- wrong engine import: from logic_bank import Engine, constraint
- bad test data creation: with Engine() as engine...
- Bad load code (no session)
Postgresql Example
You can test this as follows:
- Use our docker image:
- And try:
als genai --using=system/genai/examples/postgres/genai_demo_pg.prompt --db-url=postgresql://postgres:p@localhost/genai_demo
Provisos:
- You have to create the database first; we are considering automating that: https://stackoverflow.com/questions/76294523/why-cant-create-database-if-not-exists-using-sqlalchemy
2. New Database - using Copilot (Signup optional)
You can use Copilot chat (if extension installed; if not, skip to step 3):
- Create a model, eg:
Show Me How to Use Copilot
>Paste this into the Copilot prompt:
Use SQLAlchemy to create a sqlite database named sample_ai.sqlite, with customers, orders, items and product
Hints: use autonum keys, allow nulls, Decimal types, foreign keys, no check constraints.
Include a notes field for orders.
Create a few rows of only customer and product data.
Enforce the Check Credit requirement (do not generate check constraints):
1. Customer.Balance <= CreditLimit
2. Customer.Balance = Sum(Order.AmountTotal where date shipped is null)
3. Order.AmountTotal = Sum(Items.Amount)
4. Items.Amount = Quantity * UnitPrice
5. Store the Items.UnitPrice as a copy from Product.UnitPrice

-
Paste the copilot response into a new
sample_ai.pyfile -
Create your project:
-
This will create your database, create an API Logic Project from it, and launch your IDE.
-
Create business logic
- You can create logic with either your IDE (and code completion), or Natural Language
-
To use Natural Language:
- Use the CoPilot chat,
- Paste the logic above
-
Copy it to
logic/declare_logic.pyafterdiscover_logic()- Alert: Table and Column Names may require correction to conform to the model
- Alert: you may to apply defaulting, and initialize derived attributes in your database
3. New Database - using ChatGPT in the Browser (Signup not required)
A final option for GenAI is to use your Browser with ChatGPT.
Please see this doc
Appendices
Procedures
Quick Basic Demo - Cheat Sheet
This demo creates and customizes a project, starting from a database:
Quick Basic Demo:
# Microservice Automation
# Admin App, API, Project
als create --project-name=basic_demo --db-url=basic_demo
# Logic and Securityf
# see logic (logic/declare_logic.py, logic/cocktail-napkin.jpg); add an Order and Item
# see security (security/declare_security.py); compare customers, s1 vs. admin
als add-cust
als add-auth --db_url=auth
# Python Extensibility, Kafka Integration, Rebuild Iteration
# see logic/declare_logic.py (breakpoint for Kafka)
# Swagger: ServicesEndPoint.OrderB2B
als add-cust
als rebuild-from-database --db_url=sqlite:///database/db.sqlite
Quick GenAI Demo - Cheat Sheet
This demo creates and customizes a project, starting from a prompt:
Quick GenAI Demo:
# Microservice Automation from GenAI Prompt
# Admin App, API, Project
als genai --using=system/genai/examples/genai_demo/genai_demo.prompt
# Or, Microservice Automation from Saved Response
# Admin App, API, Project
als genai --repaired-response=system/genai/temp/chatgpt_retry.response
# Logic and Security
# - see logic (logic/declare_logic.py, logic/cocktail-napkin.jpg); add an Order and Item
# - see security (security/declare_security.py); compare customers, s1 vs. admin
# Python Extensibility, Kafka Integration, Rebuild Iteration
# - see logic/declare_logic.py (breakpoint for Kafka)
# - Swagger: ServicesEndPoint.OrderB2B
als add-cust
Detail Procedures
Specific procedures for running the demo are here, so they do not interrupt the conceptual discussion above.
You can use either VSCode or Pycharm.
1. Establish your Virtual Environment
Python employs a virtual environment for project-specific dependencies. Create one as shown below, depending on your IDE.
For VSCode:
Establish your venv, and run it via the first pre-built Run Configuration. To establish your venv:
python -m venv venv; venv\Scripts\activate # win
python3 -m venv venv; . venv/bin/activate # mac/linux
pip install -r requirements.txt
For PyCharm, you will get a dialog requesting to create the venv; say yes.
See here for more information.
2. Start and Stop the Server
Both IDEs provide Run Configurations to start programs. These are pre-built by ApiLogicServer create.
For VSCode, start the Server with F5, Stop with Shift-F5 or the red stop button.
For PyCharm, start the server with CTL-D, Stop with red stop button.
3. Entering a new Order
To enter a new Order:
-
Click `Customer 1``
-
Click
+ ADD NEW ORDER -
Set
Notesto "hurry", and pressSAVE AND SHOW -
Click
+ ADD NEW ITEM -
Enter Quantity 1, lookup "Product 1", and click
SAVE AND ADD ANOTHER -
Enter Quantity 2000, lookup "Product 2", and click
SAVE -
Observe the constraint error, triggered by rollups from the
Itemto theOrderandCustomer -
Correct the quantity to 2, and click
Save
4. Update the Order
To explore our new logic for green products:
-
Access the previous order, and
ADD NEW ITEM -
Enter quantity 11, lookup product
Green, and clickSave.
Setup Codespaces
Codespaces enables you to run in the cloud: VSCode via your Browser, courtesy GitHub.
Using codespaces on your GenAI project
1. Open your project on GitHub

2. Open it in Codespaces (takes a minute or 2):

You will now see your project - running in VSCode, in the Browser. But that's just what you see...
Behind the scenes, Codespaces has requisitioned a cloud machine, and loaded your project - with a complete development environment - Python, your dependencies, git, etc.
You are attached to this machine in your Browser, running VSCode.
Pretty remarkable.
3. Start the Server and open the App in the Browser
- Use the pre-defined Launch Configuration

We think you'll find Codespaces pretty amazing - check it out!
Get an OpenAI ApiKey
GenAI-Logic uses OpenAI, which requires an OpenAI Key:
Pre-created Samples
Explore Pre-created Samples
The samples folder has pre-created important projects you will want to review at some point (Important: look for readme files):
-
nw_sample_nocust - northwind (customers, orders...) database
- This reflects the results you can expect with your own databases
-
nw_sample - same database, but with with customizations added. It's a great resource for exploring how to customize your projects.
- Hint: use your IDE to search for
#als
- Hint: use your IDE to search for
-
tutorial - short (~30 min) walk-through of using API Logic Server using the northwind (customers, orders...) database
You can always re-create the samples
Re-create them as follows:
- Open a terminal window (Terminal > New Terminal), and paste the following CLI command: