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.
https://github.com/user-attachments/assets/34cb03eb-5648-4fa0-9cba-8de8faebaa81
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
@openuidev/react-ui) supplies the app shell primitives, chart, table, cards, tags, callouts, follow-up buttons, and trace accordion styling.DataChatResponse JSON envelope, not markdown.LLM_BASE_URL to that proxy.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.
| 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. |
Revenue trend over the last 12 monthsTop 5 accounts by region in Q1Active users this monthWhich contracts mention auto-renewal?What's driving the dip in March?Can you analyse the data into a dashboard?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.
The seed script creates:
revenue_metricsaccountsactive_user_metricscontractscontract_chunkscontract_chunks.chunk_textcontract_chunks.embeddingThe 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.
npm run test
npm run build
Licensed under the Universal Permissive License (UPL), Version 1.0. See LICENSE.