Building a Neuro-Symbolic
Credit Card Approval System

From ORM Model to Production in Hours

🤖 AI-Driven Development Demo

The Starting Point: ORM Model

ORM Diagram

Domain model created in ORM tool → Generated verbalizations + JSON schema automatically
(Click image to zoom)

Generated Artifacts

CreditCardApp.json

{
  "name": "CreditCardApplication",
  "elements": [
    {
      "type": "EntityType",
      "name": "Applicant",
      "refMode": {
        "name": "ID",
        "dataType": "Integer"
      }
    },
    {
      "type": "EntityType",
      "name": "CardType",
      "refMode": {
        "name": "Name",
        "dataType": "Text"
      },
      "valueConstraint": {
        "allowedValues": [
          "Basic Card",
          "Rewards Card",
          "Premium Card"
        ]
      }
    },
    ...
  ]
}

ORM Verbalization

Each Applicant is identified by an ID which is an Integer.
Each CardType is identified by a Name which is Text.
Each CardType must be one of 'Basic Card', 'Rewards Card', 'Premium Card'.
Each CreditCardApplication is identified by an ID which is an Integer.
A CreditScoreValue is a kind of Integer.
Each CreditScoreValue must be in the range 0 to 850.
A DTIRatioValue is a kind of Decimal.
Each DTIRatioValue must be in the range 0.0 to 0.50.
An EmploymentYearsValue is a kind of Integer.
Each EmploymentYearsValue must be in the range 0 to 99.
An ExistingAccountsCountValue is a kind of Integer.
Each ExistingAccountsCountValue must be in the range 0 to 99.
Each Applicant must have exactly one CreditScoreValue.
Each Applicant must have exactly one DTIRatioValue.
Each CreditCardApplication must be for exactly one Applicant.
Each CreditCardApplication must be for exactly one CardType.
...

Exported from ORM tool → Ready for AI consumption

UI Mock (AI-Generated)

UI Mock

AI-generated interface → Modern, responsive design with real-time validation
(Click image to zoom)

Initial Specification

We will be building a CreditCardApplication approval API. 
This is a demo for neuro-symbolic AI.
The specifications are in the specification folder off the root.
See CreditCardApp.json for the data model and CreditCardApp.txt for the business rules.
It will use a combination of DuckDb, Prolog, Logica, and AI (LLMs and LTNs) to make decisions.
It will have a web interface that will submit to the API endpoint built with Python and FastAPI.
See CreditCardAppUI.html for the web interface mock.
It will use Python or Prolog to orchestrate the system; although, Python is the API entry point.
The decision to orchestrate from Prolog or Python should be based on the amount of data 
being passed and the complexity of the decision.
If Prolog is used, it will use SWI Prolog and Janus to interoperate with Python. 
It will use DuckDb to store the data.
It may use Prolog to make decisions.
It may use Logica to make decisions. See logica_starter_kit for examples.
It may use AI (LLMs and LTNs) to make decisions.
It should choose the best combination of DuckDb, Logica, Prolog, and AI to make decisions.
It is not required to use all of DuckDb, Logica, Prolog, and AI to make decisions.
It may suggest other technologies as well.
It should be able to run on a single machine.
It should be able to run on Google Cloud.

For LLMs, use Gemini 2.5 Flash and the Gemini API

Minimal human input required → Full application

The Initial Prompt

"Build a credit card approval API based on the ORM model (CreditCardApp.json) and business rules (CreditCardApp.txt). Use neuro-symbolic AI combining DuckDB, Logica, and AI (LLMs/LTNs). Include a web interface."

1 Initial Conversation
~98% AI-Generated Code

Data Model Deep Dive

ER Diagram

(Static SVG for demo stability. Click to zoom.)

Architecture Overview

High-Level Conceptual Architecture

(Click image to zoom)

Decision Flow

sequenceDiagram
    participant Client
    participant Engine as Decision Engine
    participant AIManager as AI Manager
    participant LLM
    participant LTN
    participant Logica
    participant DB

    Client->>Engine: process_application
    
    Note over Engine: Step 1 Create Records
    Engine->>DB: create_applicant
    Engine->>DB: create_application
    
    Note over Engine: Step 2 AI Analysis
    Engine->>AIManager: analyze_employment
    AIManager->>LLM: analyze_notes
    LLM-->>AIManager: analysis
    
    Engine->>AIManager: calculate_stability
    AIManager->>LTN: evaluate_constraints
    LTN-->>AIManager: score
    
    Note over Engine: Step 3 Business Rules
    Engine->>Logica: execute_rules
    Logica-->>Engine: results
    
    Note over Engine: Step 4 Final Decision
    Engine->>Engine: make_decision
    Engine->>DB: update_application
    
    Engine-->>Client: DecisionResponse
                    

AI Component Initialization

sequenceDiagram
    participant App as FastAPI App
    participant Engine as Decision Engine
    participant AIManager as AI Manager
    participant LLM
    participant LTN
    participant Config

    App->>Engine: init
    Engine->>AIManager: init
    AIManager->>Config: get_ai_config
    Config-->>AIManager: config
    
    Note over AIManager: Initialize LLM
    alt LLM Enabled
        AIManager->>LLM: init
        LLM->>Config: get gemini config
        alt API Key Available
            LLM-->>AIManager: available
        else No API Key
            LLM-->>AIManager: no_api_key
        end
    else LLM Disabled
        AIManager-->>AIManager: disabled
    end
    
    Note over AIManager: Initialize LTN
    alt LTN Enabled
        AIManager->>LTN: init
        alt Library Available
            LTN-->>AIManager: available
        else Import Failed
            LTN-->>AIManager: failed
        end
    else LTN Disabled
        AIManager-->>AIManager: disabled
    end
    
    AIManager-->>Engine: component_manager
    Engine-->>App: decision_engine
                    

Error Handling & Fallbacks

sequenceDiagram
    participant Client
    participant Engine
    participant AIManager
    participant LLM
    participant LTN
    participant Logica

    Client->>Engine: process_application
    
    Note over Engine: AI Analysis with Fallbacks
    Engine->>AIManager: analyze_employment_text
    AIManager->>LLM: analyze_employment_notes
    
    alt LLM Available
        LLM-->>AIManager: ai_analysis
        Note right of AIManager: method llm
    else LLM Failed
        AIManager->>AIManager: fallback_employment_analysis
        Note right of AIManager: method fallback
    end
    
    Engine->>AIManager: calculate_stability_score
    AIManager->>LTN: evaluate_stability_constraints
    
    alt LTN Available
        LTN-->>AIManager: ltn_score
        Note right of AIManager: method ltn
    else LTN Failed
        AIManager->>AIManager: fallback_stability_calculation
        Note right of AIManager: method fallback
    end
    
    Engine->>Logica: execute_rules
    
    alt Logica Available
        Logica-->>Engine: logica_results
        Note right of Engine: logica_used true
    else Logica Failed
        Engine->>Engine: apply_fallback_rules
        Note right of Engine: logica_used false
    end
    
    Engine-->>Client: DecisionResponse with fallback indicators
                    

Results & Demo

< 1 Day Time to Build
~98% AI Assistance
~4,150 Lines of Code
14 Core Files
Python + FastAPI DuckDB Logica Gemini 2.5 Flash LTN Tailwind CSS
✓Neuro-symbolic decision engine
✓Fallback mechanisms for AI services
✓Complete audit trail
✓Real-time credit limit calculation

Excludes: presentation, docs, starter kit examples, auxiliary scripts

🚀 Try the Live Demo