Skip to main content

Metadata Catalog

The metadata catalog is the central definition of datasources available to Reveal SDK AI. It tells the AI what data connections exist, what provider each one uses, and optionally describes their databases, tables, and fields. Both the Chat and Metadata Service features rely on the catalog to understand your data landscape.

How It Works

The metadata system has three distinct responsibilities:

ConcernPurpose
Metadata CatalogWhat datasources exist and how they are structured
Metadata ManagerWhere generated metadata files are written on disk
Metadata ServiceWhen metadata generation runs (startup, schedule)

The catalog is the only piece you must configure. The manager and service have sensible defaults and are optional.


Catalog Schema

The catalog is a JSON object with a Datasources array. Each entry defines a datasource with its provider and optional schema details.

Minimal Example

At minimum, each datasource needs an Id and a Provider:

{
"Datasources": [
{
"Id": "MyDatabase",
"Provider": "SQLServer"
}
]
}

Full Schema

{
"Datasources": [
{
"Id": "MyDatabase",
"Provider": "SQLServer",
"Databases": [
{
"Name": "Northwind",
"DiscoveryMode": "Default",
"Tables": [
{
"Name": "dbo.Orders",
"Description": "Customer purchase orders",
"Fields": [
{
"Name": "OrderDate",
"Alias": "Order Date",
"Description": "Date the order was placed"
}
]
}
]
}
]
}
]
}

Schema Reference

Datasource

PropertyTypeRequiredDescription
IdstringYesUnique identifier for the datasource. Used as the datasourceId in API requests.
ProviderstringYesThe data provider type (see Provider Types below)
DatabasesarrayNoList of database schemas available in this datasource

Database

PropertyTypeRequiredDescription
NamestringYesThe name of the database
DiscoveryModestringNo"Default" (discover all tables) or "Restricted" (only listed tables). Defaults to "Default".
TablesarrayNoList of table schemas in this database

Table

PropertyTypeRequiredDescription
NamestringYesThe fully qualified table name (e.g., "dbo.Orders")
DescriptionstringNoHuman-readable description. Helps the AI understand what the table contains.
FieldsarrayNoList of field schemas in this table

Field

PropertyTypeRequiredDescription
NamestringYesThe actual column name in the database
AliasstringNoDisplay alias for the field (e.g., "Order Date" for "OrderDate")
DescriptionstringNoHuman-readable description. Helps the AI understand what the field represents.

Provider Types

Common provider values:

ProviderDescription
SQLServerMicrosoft SQL Server
PostgreSQLPostgreSQL
MySQLMySQL
OracleOracle (Service Name)
OracleSIDOracle (SID)
SSASSQL Server Analysis Services
SSASHTTPSQL Server Analysis Services (HTTP)
SnowflakeSnowflake
BigQueryGoogle BigQuery
AmazonAthenaAmazon Athena
AmazonRedshiftAmazon Redshift
MongoDBMongoDB
WebServiceWeb Service / REST API / Excel files

Catalog Sources

The catalog can be loaded from a JSON file on disk or from a completely custom provider (e.g., database-backed).

Option 1: JSON File on Disk

Store the catalog in a standalone JSON file. This is the simplest approach and is useful when you want to manage datasource definitions separately from application settings, share them across environments, or generate them from a CI/CD pipeline.

1. Create a catalog file:

config/catalog.json
{
"Datasources": [
{
"Id": "NorthwindDB",
"Provider": "SQLServer",
"Databases": [
{
"Name": "Northwind",
"DiscoveryMode": "Restricted",
"Tables": [
{ "Name": "dbo.Orders", "Description": "Customer purchase orders" },
{ "Name": "dbo.Customers", "Description": "Customer contact information" },
{ "Name": "dbo.Products", "Description": "Product catalog" }
]
}
]
}
]
}

2. Point the builder at the file:

Program.cs
builder.Services.AddRevealAI()
.UseMetadataCatalogFile("config/catalog.json")
.AddOpenAI();

Both absolute and relative paths are supported. Relative paths are resolved against the application's current working directory.

Option 2: Custom Provider

Implement IMetadataCatalogProvider to load datasource definitions from any source — a database, an API, a key vault, or anything else.

1. Implement the interface:

DatabaseCatalogProvider.cs
using Reveal.Sdk.AI.Metadata.Catalog;

public class DatabaseCatalogProvider : IMetadataCatalogProvider
{
private readonly IMyDatasourceRepository _repository;

public DatabaseCatalogProvider(IMyDatasourceRepository repository)
{
_repository = repository;
}

public async Task<MetadataCatalog> GetCatalogAsync()
{
var datasources = await _repository.GetAllDatasourcesAsync();

return new MetadataCatalog
{
Datasources = datasources.Select(ds => new DatasourceSchema
{
Id = ds.Id,
Provider = Enum.Parse<Provider>(ds.ProviderType)
}).ToList()
};
}
}

2. Register the provider:

Program.cs
builder.Services.AddRevealAI()
.UseMetadataCatalogProvider<DatabaseCatalogProvider>()
.AddOpenAI();

Your provider class is resolved through dependency injection, so you can inject any services you need in the constructor.


Metadata Manager Options

The Metadata Manager controls where generated metadata files are written on disk. These files are ephemeral — they are generated automatically and can be regenerated at any time.

appsettings.json
{
"RevealAI": {
"MetadataManager": {
"OutputPath": "D:\\metadata\\output"
}
}
}
PropertyTypeRequiredDescription
OutputPathstringNoDirectory where generated metadata files are stored. Defaults to {user-home}/reveal/ai/metadata.

Metadata Service Options

The Metadata Service controls when metadata is generated. You can trigger generation at application startup, on a recurring schedule, or both.

appsettings.json
{
"RevealAI": {
"MetadataService": {
"GenerateOnStartup": true,
"CronSchedule": "0 0 * * *"
}
}
}
PropertyTypeRequiredDescription
GenerateOnStartupbooleanNoWhen true, generates metadata when the application starts. Defaults to false.
CronSchedulestringNoCron expression for recurring metadata generation (e.g., "0 0 * * *" for daily at midnight).

Complete Configuration Example

Here is a complete example showing a catalog file, appsettings.json for the manager and service options, and the Program.cs setup:

config/catalog.json
{
"Datasources": [
{
"Id": "NorthwindDB",
"Provider": "SQLServer",
"Databases": [
{
"Name": "Northwind",
"DiscoveryMode": "Restricted",
"Tables": [
{
"Name": "dbo.Orders",
"Description": "Customer purchase orders",
"Fields": [
{ "Name": "OrderDate", "Alias": "Order Date", "Description": "Date the order was placed" },
{ "Name": "ShipCountry", "Alias": "Ship Country" }
]
},
{
"Name": "dbo.Customers",
"Description": "Customer contact information"
}
]
}
]
},
{
"Id": "SalesExcel",
"Provider": "WebService"
}
]
}
appsettings.json
{
"RevealAI": {
"OpenAI": {
"ApiKey": "sk-your-api-key-here"
},
"MetadataManager": {
"OutputPath": "D:\\metadata\\output"
},
"MetadataService": {
"GenerateOnStartup": true,
"CronSchedule": "0 0 * * *"
}
}
}
Program.cs
builder.Services.AddRevealAI()
.UseMetadataCatalogFile("config/catalog.json")
.AddOpenAI();