oracle-ai-developer-hub

Generative UI Data Chat

Copyright (c) 2026 Oracle and/or its affiliates.

A Next.js and OpenUI reference app showing how Oracle AI Database 26ai can back a data chatbot experience that returns typed UI components instead of plain text. The model chooses a query strategy and rendering shape, the server validates that plan, Oracle executes SQL/vector/hybrid retrieval, and React renders the result with @openuidev/react-ui as charts, tables, KPI cards, source cards, or mixed insight views.

Demo

https://github.com/user-attachments/assets/34cb03eb-5648-4fa0-9cba-8de8faebaa81

Architecture

Browser (Next.js App Router)
  |-- Chat transcript and composer
  |-- OpenUI / @openuidev/react-ui generative UI renderer
  |-- Oracle query trace
        |
Next.js Node runtime API route (/api/chat)
  |-- OpenAI-compatible LLM call (OCI GenAI proxy or hosted endpoint)
  |-- Zod validation for the plan and response envelope
  |-- SQL / vector / hybrid query executors
        |
Oracle AI Database 26ai
  |-- Revenue, account, and active-user tables
  |-- Contract chunks with VECTOR embeddings
  |-- Oracle Text index for hybrid evidence search

What This Demonstrates

Prerequisites

Quick Start

All commands assume you are in apps/generative-ui-data-chat.

npm install
cp .env.example .env.local
bash scripts/setup_db.sh
npm run db:seed
npm run dev

Open http://localhost:3000.

Environment Variables

Variable Required Description
LLM_BASE_URL Yes OpenAI-compatible base URL, for example http://localhost:9999/v1 for an OCI GenAI proxy.
LLM_API_KEY Yes API key or proxy token.
LLM_MODEL No Model id. Defaults to xai.grok-4.3; override with any OCI-hosted model id exposed by your proxy, for example meta.llama-3.3-70b-instruct.
ORACLE_USER Yes App user. Local default: DATA_CHAT.
ORACLE_PASSWORD Yes App password. Local default: DataChatPwd_2026.
ORACLE_CONNECTION_STRING Yes Local default: 127.0.0.1:1522/FREEPDB1.
ORACLE_ADMIN_PWD Local setup only Admin password used by the Docker setup script.

Demo Prompts

API Contract

POST /api/chat
Content-Type: application/json

{ "message": "Revenue trend over the last 12 months" }

Response:

{
  "answer": {
    "title": "Revenue trend",
    "summary": "Revenue ended at ...",
    "components": [
      {
        "type": "lineChart",
        "title": "Revenue over the last 12 months",
        "xKey": "month",
        "yKey": "revenue",
        "data": []
      }
    ]
  },
  "queryTrace": [
    {
      "strategy": "sql",
      "label": "Revenue trend",
      "statement": "SELECT ...",
      "elapsedMs": 42,
      "rowCount": 13
    }
  ]
}

Supported component types are lineChart, areaChart, barChart, horizontalBarChart, pieChart, comparisonTable, kpiCard, sourceCards, and mixedInsight.

Database Notes

The seed script creates:

The demo uses deterministic 8-dimensional vectors so it can run without a separate embedding service. In a production implementation, replace those seed vectors with embeddings generated by OCI Generative AI, ONNX in-database embeddings, or another approved embedding model.

Development

npm run test
npm run build

V1 Limitations

License

Licensed under the Universal Permissive License (UPL), Version 1.0. See LICENSE.