Metadata-Version: 2.4
Name: ApiLogicServer
Version: 17.1.0
Author-email: Val Huber <apilogicserver@gmail.com>
License: "Commons Clause" License Condition v1.0
        
        The Software is provided to you by the Licensor under the License, as defined
        below, subject to the following condition.
        
        Without limiting other conditions in the License, the grant of rights under the
        License will not include, and the License does not grant to you, the right to
        Sell the Software.
        
        For purposes of the foregoing, "Sell" means practicing any or all of the rights
        granted to you under the License to provide to third parties, for a fee or other
        consideration (including without limitation fees for hosting or consulting/support
        services related to the Software), a product or service whose value derives,
        entirely or substantially, from the functionality of the Software. Any license
        notice or attribution required by the License must also include this Commons
        Clause License Condition notice.
        
        Software: ApiLogicServer
        License: Apache 2.0
        Licensor: Val Huber
        
        ---
        
                                         Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
        TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
        1. Definitions.
        
           "License" shall mean the terms and conditions for use, reproduction, and
           distribution as defined by Sections 1 through 9 of this document.
        
           "Licensor" shall mean the copyright owner or entity authorized by the
           copyright owner that is granting the License.
        
           "Legal Entity" shall mean the union of the acting entity and all other
           entities that control, are controlled by, or are under common control with
           that entity.
        
           "You" (or "Your") shall mean an individual or Legal Entity exercising
           permissions granted by this License.
        
           "Source" form shall mean the preferred form for making modifications,
           including but not limited to software source code, documentation source,
           and configuration files.
        
           "Object" form shall mean any form resulting from mechanical transformation
           or translation of a Source form, including but not limited to compiled
           object code, generated documentation, and conversions to other media types.
        
           "Work" shall mean the work of authorship made available under the License,
           as indicated by a copyright notice that is included in or attached to the
           work (an example is provided in the Appendix below).
        
           "Derivative Works" shall mean any work, whether in Source or Object form,
           that is based on (or derived from) the Work and for which the editorial
           revisions, annotations, elaborations, or other modifications represent, as
           a whole, an original work of authorship.
        
           "Contribution" shall mean any work of authorship submitted to the Licensor
           for inclusion in the Work by the copyright owner or by an individual or
           Legal Entity authorized to submit on behalf of the copyright owner.
        
           "Contributor" shall mean Licensor and any Legal Entity on behalf of whom a
           Contribution has been received by the Licensor and subsequently incorporated
           within the Work.
        
        2. Grant of Copyright License. Subject to the terms and conditions of this
           License (including the Commons Clause condition above), each Contributor
           hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
           royalty-free, irrevocable copyright license to reproduce, prepare Derivative
           Works of, publicly display, publicly perform, sublicense, and distribute the
           Work and such Derivative Works in Source or Object form.
        
        3. Grant of Patent License. Subject to the terms and conditions of this License
           (including the Commons Clause condition above), each Contributor hereby grants
           to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
           irrevocable patent license to make, have made, use, offer to sell, sell,
           import, and otherwise transfer the Work.
        
        4. Redistribution. You may reproduce and distribute copies of the Work or
           Derivative Works thereof in any medium, with or without modifications, and
           in Source or Object form, provided that you meet the following conditions:
        
           (a) You must give any other recipients of the Work or Derivative Works a
               copy of this License; and
        
           (b) You must cause any modified files to carry prominent notices stating
               that You changed the files; and
        
           (c) You must retain, in the Source form of any Derivative Works that You
               distribute, all copyright, patent, trademark, and attribution notices
               from the Source form of the Work; and
        
           (d) If the Work includes a "NOTICE" text file, you must include a readable
               copy of the attribution notices contained within such NOTICE file.
        
        5. Submission of Contributions. Any Contribution intentionally submitted for
           inclusion in the Work shall be under the terms of this License, without any
           additional terms or conditions.
        
        6. Trademarks. This License does not grant permission to use the trade names,
           trademarks, service marks, or product names of the Licensor.
        
        7. Disclaimer of Warranty. The Work is provided on an "AS IS" BASIS, WITHOUT
           WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. You are
           solely responsible for determining the appropriateness of using the Work.
        
        8. Limitation of Liability. In no event shall any Contributor be liable for
           any damages arising from this License or out of the use or inability to
           use the Work, even if advised of the possibility of such damage.
        
        9. Accepting Warranty or Additional Liability. You may choose to offer
           warranty or liability obligations consistent with this License, but only on
           Your own behalf and sole responsibility, not on behalf of any other
           Contributor.
        
        Copyright 2020, Val Huber
        
Project-URL: Homepage, https://www.genai-logic.com
Project-URL: Docs, https://apilogicserver.github.io/Docs/Doc-Home/
Project-URL: Source, https://github.com/ApiLogicServer/ApiLogicServer-src
Project-URL: Issues, https://github.com/ApiLogicServer/ApiLogicServer-src/issues
Keywords: Flask,SQLAlchemy,Rules,WebApp,Microservice,ReactAdmin,Angular
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyJWT>=2.12.0
Requires-Dist: python-dateutil==2.8.2
Requires-Dist: SQLAlchemy-Utils==0.38.2
Requires-Dist: logicbankutils==0.6.0
Requires-Dist: inflect==5.0.2
Requires-Dist: inflection==0.5.1
Requires-Dist: Flask>=3.1.3
Requires-Dist: Flask-Cors>=6.0.0
Requires-Dist: Flask-RESTful>=0.3.9
Requires-Dist: flask-restful-swagger-2>=0.35
Requires-Dist: Flask-SQLAlchemy==3.0.3
Requires-Dist: flask-swagger-ui>=4.11.1
Requires-Dist: flask_bcrypt==1.0.1
Requires-Dist: itsdangerous>=2.2.0
Requires-Dist: Jinja2>=3.1.6
Requires-Dist: MarkupSafe==2.1.3
Requires-Dist: six==1.16.0
Requires-Dist: SQLAlchemy>=2.0.48
Requires-Dist: Werkzeug>=3.0.0
Requires-Dist: safrs>=3.1.7
Requires-Dist: Flask-Admin==1.5.7
Requires-Dist: Flask-JWT-Extended>=4.7.1
Requires-Dist: Flask-Login>=0.6.3
Requires-Dist: Flask-OpenID==1.3.0
Requires-Dist: python-dotenv==1.2.2
Requires-Dist: email-validator==1.1.1
Requires-Dist: LogicBank>=1.31.02
Requires-Dist: cryptography>=46.0.7; (platform_system != "Windows" or platform_machine != "ARM64") and platform_machine != "aarch64"
Requires-Dist: cryptography<47,>=46.0.7; platform_machine == "aarch64"
Requires-Dist: rsa
Requires-Dist: PyMySQL>=1.1.1
Requires-Dist: oracledb==2.1.2; python_version < "3.13" and platform_machine != "aarch64" and platform_machine != "ARM64"
Requires-Dist: oracledb>=2.5.0; python_version >= "3.13" and platform_machine != "aarch64" and platform_machine != "ARM64"
Requires-Dist: requests>=2.33.0
Requires-Dist: chardet<6
Requires-Dist: gunicorn==22.0.0
Requires-Dist: psycopg2-binary>=2.9.5; python_version < "3.13"
Requires-Dist: psycopg[binary]>=3.1.0; python_version >= "3.13" and (platform_system != "Windows" or platform_machine != "ARM64")
Requires-Dist: dotmap==1.3.25
Requires-Dist: WTForms==2.3.3
Requires-Dist: behave==1.2.6
Requires-Dist: alembic==1.7.7
Requires-Dist: python-ulid==2.7.0
Requires-Dist: psutil>=6.1.0
Requires-Dist: GeoAlchemy2==0.12.5
Requires-Dist: confluent-kafka>=2.6.0; platform_system != "Windows" or platform_machine != "ARM64"
Requires-Dist: translate==3.6.1
Requires-Dist: libretranslatepy==2.1.1
Requires-Dist: reportlab==4.2.0
Requires-Dist: xlsxwriter==3.2.0
Requires-Dist: natsort==8.4.0
Requires-Dist: astor==0.8.1
Requires-Dist: colorama==0.4.6
Requires-Dist: openai==1.55.3
Dynamic: license-file

# GenAI-Logic (API Logic Server)

[![Downloads](https://pepy.tech/badge/apilogicserver)](https://pepy.tech/project/apilogicserver)
[![Latest Version](https://img.shields.io/pypi/v/apilogicserver.svg)](https://pypi.python.org/pypi/apilogicserver/)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/apilogicserver.svg)](https://pypi.python.org/pypi/apilogicserver/)

One prompt — or your existing database — builds a working API and Admin App, then you declare business logic in **5 readable rules instead of 200 lines of AI-generated code** to enforce it.

On opening the project (or using Codespaces, below), the readme provides a First Time tour.  You'll see that enforcement yourself in a few minutes: those rules run at **one commit point**, no matter which path the transaction came in on — API, MCP, agent, Kafka. **No bypass.**

And you're not reading alone: your AI assistant is a partner throughout. Ask it anything — architecture, rules, debugging, deployment, or how the system works.

## See it work — no install

**[Open in GitHub Codespaces →](https://codespaces.new/ApiLogicServer/codespaces_mgr)**

This opens a ready-to-go Manager workspace in your browser — no local Python, no clone, nothing to install. Inside, the README walks you through a short guided demo: one prompt creates a real project, you trigger a business rule, then open the 200-line procedural version side-by-side with the 5-line declarative version that replaces it.

If you'd rather work locally, see [Quick Start](#-quick-start-local-install) below.

![API Logic Server Architecture](https://raw.githubusercontent.com/ApiLogicServer/Docs/main/docs/images/Architecture-What-Is.png)

---

## ⚡ Quick Start (local install)

```bash
# Install (Python 3.10-3.13)
python -m venv venv                      # windows: python -m venv venv
source venv/bin/activate                 # windows: venv\Scripts\activate
python -m pip install ApiLogicServer

# Start the Manager (opens readme with instructions)
genai-logic start

# Create project from your database (or use sample)
genai-logic create --project_name=my_app --db_url=

# Run it
cd my_app
python api_logic_server_run.py
```

**What's in the generated project:**
- **JSON:API** — endpoints for every table, with filtering, sorting, pagination, related data
- **Admin App** — multi-page React UI with automatic joins, runs immediately
- **Logic Engine** — declarative rules (5 lines instead of 200) enforced on every write path, from every caller
- **Security** — row-level authorization, JWT authentication
- **Custom UIs** — use the same API with vibe tools (Cursor, Bolt, Lovable) or GenAI-Logic's own Copilot training
- **Docker-ready** — pre-configured containers for deployment

**[📖 8-minute video demo](https://www.youtube.com/watch?v=Z4_NJIm5rFs&t=323s)** | **[📚 Full Documentation](https://apilogicserver.github.io/Docs/)** | **[🏠 Home](https://www.genai-logic.com)**

---

## Why rules instead of code

| | Without rules | With GenAI-Logic |
|---|---|---|
| Creating API endpoints | Days to weeks | Seconds, automated |
| Multi-table update logic | 200+ lines of procedural code, easy to miss a change path | 5 declarative rules — [see the A/B comparison](https://github.com/ApiLogicServer/basic_demo/blob/main/logic/procedural/declarative-vs-procedural-comparison.md) |
| Screen building | Manual, or proprietary low-code | Automated from the data model, plus vibe-tool custom UIs |
| System integration | Custom glue code per consumer | MCP-discoverable APIs out of the box |
| Auditing what the logic does | Reading procedural code | Reading the rules — they're the documentation |

Rules are declarative: declared once, auto-invoked at every commit from every caller, auto-ordered by the engine. You don't call them, so they can't be forgotten or bypassed — every write, from any path (API, custom endpoint, Kafka consumer, agent), goes through the same commit-time enforcement. No second door.

This isn't new theory — it's the same paradigm (Val Huber, co-inventor with Ron Ross) from Wang Labs PACE and Versata, validated across 6,000+ production deployments over 40 years, now open source and rebuilt for Python/React.

---

## When to use it

**Good fit** — data-centric business applications where the complexity is in multi-table calculations, constraints, and derivations:
- Application integration — instant APIs for legacy databases, modernization without a rewrite
- Rapid prototyping — a working backend in minutes
- GenAI backends — natural language → working microservice
- Backoffice / admin apps, CRUD-heavy systems (orders, inventory, customers)
- Microservice decomposition of a monolith

**Not the right tool** — real-time streaming (use Kafka/Flink), ML pipelines, low-level systems programming, document/content management, or simple static sites. GenAI-Logic can still be the backend in a hybrid architecture for these.

---

## FAQ

**How is this different from low-code platforms (Retool, OutSystems, Hasura)?**
It generates standard Python projects you own, extend, and deploy — not a proprietary screen-painter. Unlike plain API generators, it includes multi-table logic automation. [Detailed comparison →](https://medium.com/@valjhuber/declarative-genai-the-architecture-behind-enterprise-vibe-automation-1b8a4fe4fbd7)

**Is this vendor lock-in?**
No — Apache 2.0 + Commons Clause (free for internal use). Rules sit on top of standard, readable, version-controlled Python and SQLAlchemy events. You can keep using the rules engine as a library, or replace rules with equivalent procedural code at any time.

**Can I customize the generated app?**
Yes. Override the UI, extend the API, add your own logic — standard Python and SQLAlchemy, any vibe tool. The generated project is a starting point, not a black box. [Customization patterns →](https://apilogicserver.github.io/Docs/Logic/)

**What happens when logic doesn't fit the declarative model?**
The engine handles the large majority of typical business logic (calculations, validations, cascading updates). For workflows, state machines, or external integrations, you write standard Python event handlers that coexist with the rules — the engine calls your code at the right time.

**How long until a team is productive?**
Rules can be written immediately in natural language; the DSL itself is intuitive. Understanding the engine's optimization strategy (pruning, chaining) takes a few days. Most teams are productive within a week.

**Where do I get help?**
[Discord](https://discord.gg/fNRTTVFT) for real-time help, [GitHub Discussions](https://github.com/ApiLogicServer/ApiLogicServer-src/discussions), or the [full documentation](https://apilogicserver.github.io/Docs/).

**[→ More FAQs](https://medium.com/@valjhuber/declarative-genai-the-architecture-behind-enterprise-vibe-automation-1b8a4fe4fbd7#faqs)**

---

## Architecture

```
┌─────────────────────────────────────────────┐
│  Natural Language Prompt or Existing DB     │
└───────────────┬─────────────────────────────┘
                │ genai-logic create
                ↓
┌─────────────────────────────────────────────┐
│         Generated Project                    │
├─────────────────────────────────────────────┤
│  Admin App (React)                          │
│  JSON:API (SAFRS)                           │
│  Logic (Rules Engine)                       │
│  ORM (SQLAlchemy)                           │
│  Security (JWT + Row-level)                 │
└─────────────────────────────────────────────┘
                │
                ↓
        Docker Container
```

**Stack:** Python 3.10-3.13, Flask + SQLAlchemy, React + Material-UI, Docker.

**What gets created:**
```
my_app/
├── api/                    # JSON:API endpoints (Admin App AND custom UIs)
│   ├── expose_api_models.py
│   └── customize_api.py    # custom endpoints
├── ui/admin/                # instant Admin App
│   └── admin.yaml
├── logic/                   # business logic, enforced on every write
│   └── declare_logic.py
├── security/
│   └── declare_security.py
├── database/
│   └── models.py
├── tests/                   # BDD tests (Behave)
├── docs/training/           # GenAI-Logic training for Copilot
└── devops/docker/
```

---

## GenAI Integration

Create from natural language:
```bash
genai-logic genai --using=prompt.txt
```

```text
Create a system for customers, orders, items and products.
Customer balance is sum of unshipped order totals.
Order total is sum of item amounts.
Item amount is quantity * unit price.
Copy product price to item unit price.
Constraint: customer balance cannot exceed credit limit.
```

That's a working microservice — database, API, Admin App, and 5 declarative rules enforcing the credit check — in about 10 seconds.

Every created project also includes AI tutoring: open it and your Copilot/Claude assistant explains what's built and what to do next (`.github/.copilot-instructions.md`), backed by training material in `docs/training/`. Ask it to translate a new requirement and it writes the rules, not procedural code, because that training tells it to.

**Living documentation:** `genai-logic add-tests` generates Behave tests from your declared rules; running them produces a report tracing requirement → test → rule → execution — so the rules stay the source of truth, not a Word doc that drifts.

---

## 🎬 Video Overview (8 min)

[![GenAI Automation](https://raw.githubusercontent.com/ApiLogicServer/Docs/main/docs/images/sample-ai/copilot/genai-automation-video.png)](https://www.youtube.com/watch?v=Z4_NJIm5rFs&t=323s "Microservice Automation")

---

## Examples and Samples

**[See all sample projects](https://apilogicserver.github.io/Docs/Data-Model-Examples/)**

| Sample | Description | Database |
|--------|-------------|----------|
| **basic_demo** | Check credit rules, Behave testing | SQLite (Northwind) |
| **genai_demo** | Created from natural language | SQLite |
| **classicmodels** | Sales, employees, offices | MySQL |
| **chinook** | Music store (artists, albums, tracks) | SQLite/PostgreSQL |
| **postgres-nw** | Northwind on PostgreSQL | PostgreSQL |
| **sqlserver** | Adventure Works | SQL Server |

---

## Supported Databases

SQLite, PostgreSQL, MySQL/MariaDB, SQL Server, Oracle, and any other SQLAlchemy-supported database.

---

## Security

Authentication (SQL-based, Keycloak, or custom providers), role-based authorization with row-level filtering, multi-tenant global filters, JWT tokens, Swagger-integrated security docs. [Security Overview →](https://apilogicserver.github.io/Docs/Security-Overview/)

---

## Contributing

| Area | Current | Ideas for contribution |
|------|---------|----------------------|
| **API** | JSON:API, Swagger | GraphQL, gRPC |
| **Deployment** | Docker, Azure | AWS (ECS/Lambda), Kubernetes/Helm |
| **Logic** | Rules engine | Additional rule types, performance tuning |
| **UI** | Admin App (React) | Custom UI frameworks, mobile SDK |
| **GenAI** | Web version, CLI | Enhanced natural language understanding |

**[See open issues](https://github.com/ApiLogicServer/ApiLogicServer-src/issues)**

**Developing API Logic Server itself:**
```bash
git clone https://github.com/ApiLogicServer/ApiLogicServer-src.git
cd ApiLogicServer-src
python -m pip install -r requirements.txt
python test/build_and_test.py
```
**[Dev installation docs →](https://apilogicserver.github.io/Docs/Architecture-Internals/)**

---

## Documentation

- **[Full Documentation](https://apilogicserver.github.io/Docs/)**
- **[Quick Start Tutorial](https://apilogicserver.github.io/Docs/Tutorial/)** (20 minutes)
- **[Logic: Why](https://apilogicserver.github.io/Docs/Logic-Why/)** — the case for declarative logic
- **[Logic Documentation](https://apilogicserver.github.io/Docs/Logic/)** — rule types and patterns
- **[API Self-Serve](https://apilogicserver.github.io/Docs/API-Self-Serve/)** — consumer-driven APIs
- **[Security Guide](https://apilogicserver.github.io/Docs/Security-Overview/)**
- **[Behave Testing](https://apilogicserver.github.io/Docs/Behave/)**
- **[Natural Language Logic](https://apilogicserver.github.io/Docs/WebGenAI-CLI/)**
- **[Integration Patterns](https://apilogicserver.github.io/Docs/Sample-Integration/)** — Kafka, B2B, MCP
- **[Database Changes](https://apilogicserver.github.io/Docs/Database-Changes/)**
- **[Deployment](https://apilogicserver.github.io/Docs/DevOps-Containers/)**
- **[Architecture](https://apilogicserver.github.io/Docs/Architecture-What-Is/)**
- **[Issue Tracker](https://github.com/ApiLogicServer/ApiLogicServer-src/issues)**

---

## Background

The declarative rules paradigm here has 40+ years of production history:

- **Wang Labs PACE** (1980s-90s) — Val Huber co-invented the paradigm with Ron Ross; 6,000+ production deployments on minicomputers and Visual Basic.
- **Versata** (1990s-2010s) — Val Huber as CTO; evolved the engine for J2EE; Fortune 500 customers; $3.4B company (IPO: VSTA).
- **API Logic Server / GenAI-Logic** (2020-present) — Val Huber, architect and lead developer; modern Python/React, open source, combined with GenAI for natural-language logic authoring.

In-depth context, written by Val Huber on Medium:

| Article | Topic |
|---------|-------|
| **[Welcome to GenAI-Logic](https://medium.com/@valjhuber/welcome-to-genai-logic-a610ba14bd72)** | Vision and overview — start here |
| **[Declarative GenAI Architecture](https://medium.com/@valjhuber/declarative-genai-the-architecture-behind-enterprise-vibe-automation-1b8a4fe4fbd7)** | NL → DSL → Engines, the FrankenCode problem, FAQ |
| **[Declarative Logic: Living in a Procedural World](https://medium.com/@valjhuber/declarative-logic-living-in-a-procedural-world-6c5b20552c6b)** | How declarative rules work inside Python |
| **[Living With Logic in the Enterprise](https://medium.com/@valjhuber/living-with-logic-7e202782d0c5)** | Debugging, testing, performance, real deployments |
| **[Business User / IT Collaboration](https://medium.com/@valjhuber/declarative-genai-business-user-it-collaboration-c5547776ff7d)** | Logic as a contract between business and IT |
| **[Vibe an MCP Server](https://medium.com/@valjhuber/vibe-an-mcp-server-declarative-genai-logic-dec16719c004)** | Creating MCP-enabled services |
| **[Probabilistic and Deterministic Logic](https://medium.com/@valjhuber/probabilistic-and-deterministic-logic-9a38f98d24a8)** | AI at runtime + deterministic rules |
| **[Enterprise Vibe Automation](https://medium.com/@valjhuber/enterprise-vibe-automation-b40c8f750a1d)** | Full-stack automation from prompts |

---

## Connect

- **Home:** [genai-logic.com](https://www.genai-logic.com)
- **Discord:** [Join the community](https://discord.gg/fNRTTVFT)
- **Issues:** [GitHub Issues](https://github.com/ApiLogicServer/ApiLogicServer-src/issues)
- **Discussions:** [GitHub Discussions](https://github.com/ApiLogicServer/ApiLogicServer-src/discussions)
- **Docs:** [apilogicserver.github.io/Docs](https://apilogicserver.github.io/Docs/)
- **Blog:** [Medium](https://medium.com/@valjhuber)

---

## Acknowledgments

Built on Flask, SQLAlchemy, SAFRS, React, Material-UI, and Behave — and on the work of Val Huber and Ron Ross in originating the declarative rules paradigm at Wang Labs PACE, carried forward at Versata. Thanks to everyone who's filed issues, sent PRs, and given feedback.

## License

MIT — see [LICENSE](LICENSE).

---

**[⭐ Star this repo](https://github.com/ApiLogicServer/ApiLogicServer-src)** if you find it useful.
