Skip to content

Create an executable project (API and Admin App) from a database or natural language prompt with 1 command, customize with declarative rules and Python in your IDE, containerize and deploy.

License

BSD-3-Clause, Unknown licenses found

Licenses found

BSD-3-Clause
LICENSE
Unknown
license.json
Notifications You must be signed in to change notification settings

ApiLogicServer/ApiLogicServer-src

Repository files navigation

API Logic Server

Downloads Latest Version Supported Python versions

Create instant microservices from your database or natural language prompt - working API + Admin App + Logic in 5 seconds, with 40X code reduction through declarative rules.

Create instant microservices (MCP-enabled API + Admin App + Business Logic) from your database or a natural language prompt:

ApiLogicServer create --project_name=my_app --db_url=mysql://...

API Logic Server Architecture


⚑ Quick Start (2 minutes)

# 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 you get in 5 seconds:

  • πŸš€ JSON:API - Endpoints for every table with filtering, pagination, related data
  • πŸ“± Instant Admin App UI - Multi-page React app with automatic joins (runs immediately)
  • 🎨 Custom Apps via API - Use the API with your favorite vibe tools (Cursor, Bolt, Lovable, etc.) OR leverage GenAI-Logic training for Copilot to build custom UIs (see this article)
  • 🧠 Logic Engine - Spreadsheet-like rules (40X more concise than code)
  • πŸ” Security - Row-level authorization, JWT authentication
  • 🐳 Docker-ready - Pre-configured containers for deployment

Mix and match: Use the instant Admin App for backoffice tasks AND build custom UIs with vibe tools for advanced features like cards and maps - all powered by the same logic-enabled API.

πŸ“– 8-minute video demo | πŸ“š Full Documentation | 🏠 Home


🎯 Why API Logic Server?

Built on 40+ years of proven technology (Wang PACE β†’ Versata β†’ API Logic Server):

  • 6,000+ production deployments validated the declarative approach
  • Fortune 500 companies relied on this architecture for mission-critical systems
  • Now open source and modernized for cloud-native Python/React stack

The Problem It Solves

Traditional Approach API Logic Server
Weeks to create API endpoints 5 seconds (automated)
200+ lines of update logic code 5 rules (40X reduction - to see an A/B Comparision, click here
Manual screen painting Automated from data model, plus vibe-enabled custom UIs
Hard to integrate systems MCP-enabled APIs
Opaque procedural code Declarative living documentation

πŸ’‘ When to Use API Logic Server

βœ… Ideal Use Cases

API Logic Server excels at data-centric business applications where the complexity is in multi-table calculations, constraints, and derivations:

  • πŸ”Œ Application Integration - Instant APIs for legacy databases (modernization without rewrite)
  • ⚑ Rapid Prototyping - Working backend in minutes for validation
  • πŸ€– GenAI Backends - Natural language β†’ working microservice
  • 🏒 Backoffice Apps - Admin dashboards for data maintenance
  • πŸ”— Microservices - Decompose monoliths with instant services
  • πŸ“Š Business Rule Automation - Complex calculations, cascading updates, constraint checking
  • πŸ”„ CRUD-Heavy Applications - Order management, inventory, customer systems
  • πŸ›οΈ Legacy Modernization - MCP-enable existing databases, create modern API layer while legacy apps continue running

Sweet Spot: Applications where business logic complexity >> UI complexity

⚠️ Not Recommended For

API Logic Server is optimized for data-centric business logic, but less suited for:

  • Real-time streaming systems - Use Kafka/Flink for high-throughput event processing
  • Complex UI/UX interactions - Works great as the backend, but not a UI framework
  • Machine learning pipelines - Use TensorFlow/PyTorch for ML workflows
  • Low-level system programming - Traditional languages better suited
  • Document/content management - Use specialized CMS platforms
  • Simple static websites - Overkill for basic content delivery

For these scenarios, traditional approaches are more appropriate. API Logic Server can still serve as the backend for hybrid architectures.


❓ Frequently Asked Questions

Q: How is this different from low-code platforms (Retool, OutSystems, Hasura)?

A: Unlike pure low-code platforms, API Logic Server generates standard Python projects you own, extend and deploy. Screen creation is by vibe tools rather than screen painting. Unlike API generators, it includes sophisticated multi-table logic automation (40X code reduction). Read detailed comparison β†’

Q: Isn't this just vendor lock-in?

A: It's free and open source. The declarative rules sit on top of standard (readable, version-controlled) Python β€” you can always drop down to procedural code. If you ever need to migrate away, you can either keep using the rules engine (it's just a library) or replace declarative rules with equivalent procedural code using standard SQLAlchemy events.

Q: Can I customize the generated app?

A: Absolutely. You can override the UI, extend APIs, and plug in your own logic β€” using standard Python, SQLAlchemy, and any Vibe tool. The generated project is a starting point, not a black box. See customization patterns β†’

Q: What happens when logic doesn't fit the declarative model?

A: The declarative engine handles over 95% of typical business logic (calculations, validations, cascading updates). For complex workflows, state machines, or external integrations, you write standard Python event handlers that coexist with declarative rules. The engine calls your code at the right time β€” no conflict, full extensibility.

Q: How long does it take developers to become productive?

A: Developers can start writing rules immediately using natural language, and the DSL syntax is intuitive. Understanding the engine's optimization strategies (pruning, chaining) takes a few days of practice. Most teams are fully productive within a week.

Q: What if I have questions or need help?

A: Join our Discord community for real-time help, check GitHub Discussions, or browse the comprehensive documentation.

β†’ More FAQs in detailed article


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Natural Language Prompt or Existing DB     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚ ApiLogicServer create
                ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Generated Project                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  πŸ“± Admin App (React)                       β”‚
β”‚  πŸ”Œ JSON:API (SAFRS)                        β”‚
β”‚  🧠 Logic (Rules Engine)                    β”‚
β”‚  πŸ’Ύ ORM (SQLAlchemy)                        β”‚
β”‚  πŸ” Security (JWT + Row-level)              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚
                ↓
        🐳 Docker Container

Technology Stack:

  • Python 3.10-3.13
  • Flask + SQLAlchemy
  • React + Material-UI
  • Docker + Docker Compose

πŸ“¦ What Gets Created

my_app/
β”œβ”€β”€ api/                    # JSON:API endpoints (for Admin App AND custom UIs)
β”‚   β”œβ”€β”€ expose_api_models.py
β”‚   └── customize_api.py    # Add custom endpoints
β”œβ”€β”€ ui/admin/              # Instant Admin App (ready to run)
β”‚   └── admin.yaml         # Declare UI behavior
β”œβ”€β”€ logic/                 # Business Logic (enforced on ALL API calls)
β”‚   └── declare_logic.py   # Spreadsheet-like rules
β”œβ”€β”€ security/              # Authentication & Authorization
β”‚   └── declare_security.py
β”œβ”€β”€ database/              # SQLAlchemy models
β”‚   └── models.py
β”œβ”€β”€ tests/                 # BDD tests (Behave)
β”œβ”€β”€ docs/
β”‚   └── training/          # GenAI-Logic training for Copilot
└── devops/
    └── docker/            # Deployment configs

Two UI approaches (use both!):

  1. Instant Admin App - Runs immediately for backoffice/internal users
  2. Custom UIs - Build with vibe tools (Cursor, Bolt, etc.) OR use GenAI-Logic Copilot training to create React/Vue/Angular apps that consume the API

πŸš€ Key Features

1️⃣ Declarative Logic (40X More Concise)

Before (200+ lines of Python):

# Manual cascade updates, balance calculations, constraint checking...
# Complex dependency tracking, old_row comparisons...
# Missed corner cases: reassign order, change quantity, delete order...
# (Imagine 200 lines of procedural code here)

After (5 declarative rules):

Rule.constraint(derive=Customer.Balance <= Customer.CreditLimit)
Rule.sum(derive=Customer.Balance, as_sum_of=Order.AmountTotal, 
         where=lambda row: row.ShippedDate is None)
Rule.sum(derive=Order.AmountTotal, as_sum_of=OrderDetail.Amount)
Rule.formula(derive=OrderDetail.Amount, 
             as_expression=lambda row: row.Quantity * row.UnitPrice)
Rule.copy(derive=OrderDetail.UnitPrice, from_parent=Product.UnitPrice)

Rules automatically handle all dependencies:

  • βœ… Chain up (OrderDetail β†’ Order β†’ Customer)
  • βœ… Chain down (Product price change cascades)
  • βœ… Old row comparisons (moved orders adjust both customers)
  • βœ… All 9 use cases (add, update, delete, reassign...)

2️⃣ Self-Serve APIs

Consumers select their own attributes and related data - no custom API development required:

# Get customer with orders and order details
GET /api/Customer/ALFKI?include=OrderList,OrderList.OrderDetailList&fields[Customer]=CompanyName,Balance

# Filter and sort
GET /api/Customer?filter[Balance][$gt]=1000&sort=-Balance&page[size]=10

Features:

  • Filtering, sorting, pagination
  • Related data (automatic joins)
  • Optimistic locking
  • Swagger documentation
  • Logic enforcement on all updates

3️⃣ GenAI Integration

Create from Natural Language

genai-logic genai --using=prompt.txt

Example prompt:

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.

Result: Working microservice with logic in 10 seconds!

AI-Assisted Development

Every created project includes:

  • πŸ€– Copilot instructions (.copilot-instructions.md)
  • πŸ“š Training materials (docs/training/)
  • πŸ” Logic from natural language (translate English β†’ rules)
# Paste into Copilot: "Create logic for check credit"
# Copilot generates the 5 rules above!

4️⃣ Living Documentation

Automated test generation from your rules:

# Generate Behave tests from declared logic
genai-logic add-tests

# Run tests
behave

# Generate documentation
python behave_logic_report.py

Output: Complete traceability from requirements β†’ tests β†’ rules β†’ execution trace.


🎬 Video Overview (8 min)

See how Microservice Automation creates and runs a microservice - a multi-page app and an API:

GenAI Automation


🀝 Contributing

We welcome contributions! Areas of interest:

Area Current Ideas for Contribution
API JSON:API, Swagger GraphQL, gRPC support
Deployment Docker, Azure AWS (ECS/Lambda), Kubernetes/Helm charts
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 issues for current requests.

Development Setup

For development (extending API Logic Server itself):

# Clone and install dev version
git clone https://github.com/ApiLogicServer/ApiLogicServer-src.git
cd ApiLogicServer-src

# Install dependencies
python -m pip install -r requirements.txt

# Run build/test automation
python test/build_and_test.py

See dev installation docs for complete setup.


πŸ“š Documentation


πŸ“– Key Documentation Pages

Getting Started

Core Concepts

Advanced Topics


🌟 Examples and Samples

See all sample projects

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

πŸ† Technology Lineage

API Logic Server builds on proven technology with 40+ years of production validation:

Wang Labs PACE (1980s-1990s)

  • Inventor: Val Huber (Designer and Co-inventor with Ron Ross of declarative rules)
  • Scale: 6,000+ production deployments
  • Innovation: First commercial declarative business rules system
  • Platform: Minicomputers β†’ Visual Basic

Versata (1990s-2010s)

  • Leadership: Val Huber (CTO)
  • Customers: Fortune 500 companies
  • Scale: $3.4 billion company (IPO: VSTA)
  • Innovation: Evolved rules for J2EE enterprise applications
  • Platform: Java Enterprise Edition

API Logic Server (2020-present)

  • Leadership: Val Huber (Architect and Lead Developer)
  • Innovation: Modern cloud-native Python/React implementation
  • Platform: Open source, Docker, microservices architecture
  • Unique: Combined with GenAI for natural language logic

The same declarative rules paradigm, proven at scale, now open source and AI-enhanced.


πŸ“Š Comparison: Frameworks vs Low Code vs API Logic Server

Aspect Frameworks
(Django, Flask)
Low Code
(Retool, Appsmith)
API Logic Server
API Creation Manual (weeks) Limited/proprietary βœ… Automated (5 sec)
Logic Automation ❌ Manual code ❌ Limited βœ… Rules (40X)
App Automation ❌ Manual βœ… GUI builder βœ… From data model
Customization βœ… Full Python ⚠️ Proprietary βœ… Python + Rules
IDE βœ… Standard tools ❌ Proprietary βœ… VSCode, PyCharm
Deployment βœ… Any platform ⚠️ Vendor lock-in βœ… Docker, any cloud
GenAI Integration ❌ None ⚠️ Limited βœ… Full (DB + Logic)
Testing Manual Limited βœ… Auto-generated

πŸ’Ύ Supported Databases

  • SQLite (included samples)
  • PostgreSQL
  • MySQL / MariaDB
  • SQL Server
  • Oracle
  • Any SQLAlchemy-supported database

πŸ” Security Features

  • Authentication: SQL-based, Keycloak, or custom providers
  • Authorization: Role-based grants with row-level filtering
  • Multi-tenant: Global filters based on user attributes
  • JWT Tokens: Standard authentication flow
  • Swagger Security: Integrated with API documentation

See Security Overview


πŸ“„ License

MIT License - see LICENSE file


πŸ™ Acknowledgments

Built on the shoulders of giants:

Technology Pioneers:

  • Wang Labs PACE (1980s) - Original declarative rules concept (Val Huber, designer/co-inventor)
  • Versata (1990s-2010s) - $3.4B company, Fortune 500 deployments (Val Huber, CTO)
  • Ron Ross - Co-inventor of declarative rules paradigm

Open Source Foundation:

  • Flask - Web framework
  • SQLAlchemy - ORM layer
  • SAFRS - JSON:API implementation
  • React - Admin App UI
  • Material-UI - Component library
  • Behave - BDD testing framework

Community:

  • All contributors who have submitted issues, PRs, and feedback
  • The Python and React ecosystems

πŸ“ In-Depth Articles

These Medium articles provide comprehensive context on architecture, use cases, and the reasoning behind API Logic Server:

Article Topic Key Insights
Welcome to GenAI-Logic Vision & Overview Big picture: Does GenAI deliver business agility? Start here for context.
Declarative GenAI Architecture Technical Deep Dive NL β†’ DSL β†’ Engines pattern, FrankenCode problem, includes FAQ section
Declarative Logic: Living in a Procedural World Architecture Philosophy How declarative rules work in Python, the paradox resolved
Living With Logic in the Enterprise Production Patterns Debugging, testing, performance, customization in real deployments
Business User / IT Collaboration Team Dynamics How logic acts as a contract between business and IT
Vibe an MCP Server MCP Integration Creating MCP-enabled services with natural language
Probabilistic and Deterministic Logic AI + Rules Engineering reliability into agentic systems (AI at runtime + rules)
Enterprise Vibe Automation GenAI Workflows Full-stack automation from prompts

These articles represent significant research and real-world experience - they address common questions, architectural decisions, and lessons learned from 40+ years of declarative technology evolution.


πŸ“ž Connect

πŸ“– Recommended Reading

Start with the welcome article to understand the vision and architecture:


⭐ Star this repo if you find it useful!

Made with ❀️ by the API Logic Server team

About

Create an executable project (API and Admin App) from a database or natural language prompt with 1 command, customize with declarative rules and Python in your IDE, containerize and deploy.

Topics

Resources

License

BSD-3-Clause, Unknown licenses found

Licenses found

BSD-3-Clause
LICENSE
Unknown
license.json

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •