Add the canonical data product template
Moves the data product template from semprini-blog-dataproducts, as adapted to the semprini-data domain platform, into canonical_data_product/. Its worked example passed 9 of 9 checks on the domain platform on 2026-09-17. Adds agent-canonical-product, the blog's agent-product adapted to generate a product into a domain repository from a declaration in the domain's model repository, and README/CLAUDE.md describing the template catalogue, the product contract with the domain platform, and team ownership. Source-aligned and experience templates are planned. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
commit
62a3714562
30 files changed
+1529
No files matched your search
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "urn:digital-core:example-address:address",
|
||||
"title": "Address",
|
||||
"description": "The canonical record of a physical or postal location. Canonical record published by Example Address. Property names are the ODS column names. Used for both the inbound topic (records producers publish) and the compacted outbound topic (every change, keyed by address_id).",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["address_id", "country"],
|
||||
"properties": {
|
||||
"address_id": {
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"description": "Globally unique surrogate identifier for this physical location record. Immutable once assigned."
|
||||
},
|
||||
"address_type": {
|
||||
"type": ["string", "null"],
|
||||
"enum": ["Street Address", "PO Box", "Registered Office", "Overseas Address", null],
|
||||
"description": "The structural type of the address. Determines which fields are applicable."
|
||||
},
|
||||
"address_line_1": {
|
||||
"type": ["string", "null"],
|
||||
"description": "The primary street address line. For PO Box addresses, the PO Box number."
|
||||
},
|
||||
"address_line_2": {
|
||||
"type": ["string", "null"],
|
||||
"description": "Secondary address line for suite, level, unit, or building name where applicable."
|
||||
},
|
||||
"suburb": {
|
||||
"type": ["string", "null"],
|
||||
"description": "The suburb or locality component of the address."
|
||||
},
|
||||
"city": {
|
||||
"type": ["string", "null"],
|
||||
"description": "The city or town."
|
||||
},
|
||||
"state_or_region": {
|
||||
"type": ["string", "null"],
|
||||
"description": "The state, territory, or region."
|
||||
},
|
||||
"postcode": {
|
||||
"type": ["string", "null"],
|
||||
"description": "The postal code, as a string to preserve leading zeros."
|
||||
},
|
||||
"country": {
|
||||
"type": "string",
|
||||
"description": "ISO 3166-1 alpha-2 country code. Mandatory for all address types."
|
||||
},
|
||||
"created_at": {
|
||||
"type": ["string", "null"],
|
||||
"format": "date-time",
|
||||
"description": "Set by the ODS. Optional on the inbound topic."
|
||||
},
|
||||
"updated_at": {
|
||||
"type": ["string", "null"],
|
||||
"format": "date-time",
|
||||
"description": "Set by the ODS on every change. Optional on the inbound topic."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
-- Example Address: streaming job (Flink SQL, Flink 2.2).
|
||||
-- Submitted by the platform CLI with `bin/sql-client.sh -f job.sql` on the jobmanager.
|
||||
|
||||
SET 'pipeline.name' = 'example-address';
|
||||
SET 'execution.checkpointing.interval' = '10 s';
|
||||
|
||||
CREATE TABLE address_inbound (
|
||||
address_id STRING,
|
||||
address_type STRING,
|
||||
address_line_1 STRING,
|
||||
address_line_2 STRING,
|
||||
suburb STRING,
|
||||
city STRING,
|
||||
state_or_region STRING,
|
||||
postcode STRING,
|
||||
country STRING
|
||||
) WITH (
|
||||
'connector' = 'kafka',
|
||||
'topic' = 'digital-core.example-address.address.inbound',
|
||||
'properties.bootstrap.servers' = 'kafka:29092',
|
||||
'properties.group.id' = 'example-address.address.inbound',
|
||||
'scan.startup.mode' = 'group-offsets',
|
||||
'properties.auto.offset.reset' = 'earliest',
|
||||
'format' = 'json',
|
||||
'json.fail-on-missing-field' = 'false',
|
||||
'json.ignore-parse-errors' = 'false',
|
||||
'json.timestamp-format.standard' = 'ISO-8601'
|
||||
);
|
||||
|
||||
CREATE TABLE address_ods (
|
||||
address_id STRING,
|
||||
address_type STRING,
|
||||
address_line_1 STRING,
|
||||
address_line_2 STRING,
|
||||
suburb STRING,
|
||||
city STRING,
|
||||
state_or_region STRING,
|
||||
postcode STRING,
|
||||
country STRING,
|
||||
PRIMARY KEY (address_id) NOT ENFORCED
|
||||
) WITH (
|
||||
'connector' = 'jdbc',
|
||||
'url' = 'jdbc:postgresql://ods:5432/ods?stringtype=unspecified',
|
||||
'table-name' = 'example_address.address',
|
||||
'username' = 'postgres',
|
||||
'password' = '${ODS_PASSWORD}'
|
||||
);
|
||||
|
||||
CREATE TABLE address_cdc (
|
||||
address_id STRING,
|
||||
address_type STRING,
|
||||
address_line_1 STRING,
|
||||
address_line_2 STRING,
|
||||
suburb STRING,
|
||||
city STRING,
|
||||
state_or_region STRING,
|
||||
postcode STRING,
|
||||
country STRING,
|
||||
updated_at TIMESTAMP_LTZ(6),
|
||||
PRIMARY KEY (address_id) NOT ENFORCED
|
||||
) WITH (
|
||||
'connector' = 'postgres-cdc',
|
||||
'hostname' = 'ods',
|
||||
'port' = '5432',
|
||||
'username' = 'postgres',
|
||||
'password' = '${ODS_PASSWORD}',
|
||||
'database-name' = 'ods',
|
||||
'schema-name' = 'example_address',
|
||||
'table-name' = 'address',
|
||||
'slot.name' = 'example_address_address_flink',
|
||||
'decoding.plugin.name' = 'pgoutput',
|
||||
'scan.incremental.snapshot.enabled' = 'true'
|
||||
);
|
||||
|
||||
CREATE TABLE address_outbound (
|
||||
address_id STRING,
|
||||
address_type STRING,
|
||||
address_line_1 STRING,
|
||||
address_line_2 STRING,
|
||||
suburb STRING,
|
||||
city STRING,
|
||||
state_or_region STRING,
|
||||
postcode STRING,
|
||||
country STRING,
|
||||
updated_at TIMESTAMP_LTZ(6),
|
||||
PRIMARY KEY (address_id) NOT ENFORCED
|
||||
) WITH (
|
||||
'connector' = 'upsert-kafka',
|
||||
'topic' = 'digital-core.example-address.address.outbound',
|
||||
'properties.bootstrap.servers' = 'kafka:29092',
|
||||
'key.format' = 'raw',
|
||||
'value.format' = 'json',
|
||||
'value.json.timestamp-format.standard' = 'ISO-8601'
|
||||
);
|
||||
|
||||
EXECUTE STATEMENT SET
|
||||
BEGIN
|
||||
INSERT INTO address_ods SELECT * FROM address_inbound;
|
||||
INSERT INTO address_outbound SELECT * FROM address_cdc;
|
||||
END;
|
||||
@@ -0,0 +1,31 @@
|
||||
# Example Address: GraphQL surface reflected by pg_graphql from example_address.address.
|
||||
# Documentation only; the live schema is available by introspection at
|
||||
# POST http://localhost:20000/rpc/example_address_graphql (GRAPHQL_PORT of a domain at port base 20000).
|
||||
|
||||
type Address implements Node {
|
||||
nodeId: ID!
|
||||
addressId: UUID!
|
||||
addressType: String # enum:Address Type, enforced by CHECK in the ODS
|
||||
addressLine1: String
|
||||
addressLine2: String
|
||||
suburb: String
|
||||
city: String
|
||||
stateOrRegion: String
|
||||
postcode: String
|
||||
country: String!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
addressCollection(
|
||||
first: Int, last: Int, before: Cursor, after: Cursor,
|
||||
filter: AddressFilter, orderBy: [AddressOrderBy!]
|
||||
): AddressConnection
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
insertIntoAddressCollection(objects: [AddressInsertInput!]!): AddressInsertResponse
|
||||
updateAddressCollection(set: AddressUpdateInput!, filter: AddressFilter, atMost: Int! = 1): AddressUpdateResponse
|
||||
deleteFromAddressCollection(filter: AddressFilter, atMost: Int! = 1): AddressDeleteResponse
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# Run by `data-domain test` against POST /rpc/example_address_graphql.
|
||||
query ExampleAddressSmoke {
|
||||
addressCollection(first: 5) {
|
||||
edges {
|
||||
node {
|
||||
addressId
|
||||
addressType
|
||||
city
|
||||
country
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
-- Example Address: analytical replication into DuckLake (runs on the lakehouse service).
|
||||
|
||||
CREATE SCHEMA IF NOT EXISTS example_address;
|
||||
|
||||
SELECT duckpipe.add_table(
|
||||
'example_address.address',
|
||||
target_table => 'example_address.address',
|
||||
sync_group => 'ods'
|
||||
);
|
||||
|
||||
GRANT USAGE ON SCHEMA example_address TO ducklake_reader, ducklake_writer;
|
||||
GRANT SELECT ON ALL TABLES IN SCHEMA example_address TO ducklake_reader, ducklake_writer;
|
||||
@@ -0,0 +1,95 @@
|
||||
# Example Address: ODPS v4.0 manifest (worked example of canonical_data_product/odps.yaml).
|
||||
schema: https://opendataproducts.org/v4.0/schema/odps.yaml
|
||||
version: 4.0
|
||||
product:
|
||||
details:
|
||||
en:
|
||||
name: "Example Address"
|
||||
productID: "digital-core.example-address"
|
||||
description: "Worked example of the data product template: the canonical Address entity of the Digital Core domain, published through GraphQL, Kafka and Trino."
|
||||
visibility: organisation
|
||||
status: production
|
||||
type: dataset
|
||||
productVersion: "1.0.0"
|
||||
categories:
|
||||
- "Digital Core"
|
||||
tags:
|
||||
- "Address"
|
||||
outputFileFormats:
|
||||
- GraphQL
|
||||
- JSON
|
||||
- SQL
|
||||
SLA:
|
||||
declarative:
|
||||
default:
|
||||
name:
|
||||
en: Default SLA
|
||||
description:
|
||||
en: "Service levels for Example Address"
|
||||
dimensions:
|
||||
- dimension: uptime
|
||||
displaytitle:
|
||||
en: Availability
|
||||
objective: 99.95
|
||||
unit: percent
|
||||
- dimension: updateFrequency
|
||||
displaytitle:
|
||||
en: Data Freshness
|
||||
objective: 1
|
||||
unit: minutes
|
||||
support:
|
||||
email: "data.architecture@bank.com"
|
||||
dataAccess:
|
||||
default:
|
||||
name:
|
||||
en: CRUD API
|
||||
description:
|
||||
en: "GraphQL reflected from the operational store by pg_graphql."
|
||||
outputPorttype: API
|
||||
format: GraphQL
|
||||
authenticationMethod: none
|
||||
accessURL: "http://localhost:20000/rpc/example_address_graphql"
|
||||
publish:
|
||||
name:
|
||||
en: Publish Input
|
||||
description:
|
||||
en: "Kafka topic accepting canonical Address records."
|
||||
outputPorttype: API
|
||||
format: JSON
|
||||
authenticationMethod: none
|
||||
accessURL: "kafka://localhost:20001/digital-core.example-address.address.inbound"
|
||||
specsURL: "http://localhost:8081/apis/registry/v3/groups/digital-core.example-address/artifacts"
|
||||
subscribe:
|
||||
name:
|
||||
en: Subscribe Output
|
||||
description:
|
||||
en: "Compacted Kafka topic carrying every change to Address, keyed by address_id."
|
||||
outputPorttype: API
|
||||
format: JSON
|
||||
authenticationMethod: none
|
||||
accessURL: "kafka://localhost:20001/digital-core.example-address.address.outbound"
|
||||
specsURL: "http://localhost:8081/apis/registry/v3/groups/digital-core.example-address/artifacts"
|
||||
sql:
|
||||
name:
|
||||
en: Analytic SQL
|
||||
description:
|
||||
en: "Trino over DuckLake, continuously replicated from the operational store."
|
||||
outputPorttype: SQL
|
||||
format: SQL
|
||||
authenticationMethod: none
|
||||
accessURL: "jdbc:trino://localhost:20003/lake/example_address"
|
||||
license:
|
||||
en:
|
||||
scope:
|
||||
definition: "TODO: purpose statement for the licence"
|
||||
restrictions: "Internal. Address is reference data with no PII; parties are linked through Contact Address, which is not in this product."
|
||||
permanent: false
|
||||
exclusive: false
|
||||
termination:
|
||||
terminationConditions: "7 years post relationship end"
|
||||
governance:
|
||||
confidentiality: "Internal, per the Address entity governance in the Digital Core domain"
|
||||
dataHolder:
|
||||
en:
|
||||
legalName: "TODO: organisation legal name"
|
||||
email: "data.architecture@bank.com"
|
||||
@@ -0,0 +1,13 @@
|
||||
-- Example Address: operational data store schema (runs on the postgres service).
|
||||
|
||||
CREATE SCHEMA example_address;
|
||||
|
||||
COMMENT ON SCHEMA example_address IS E'@graphql({"inflect_names": true, "introspection": true, "max_rows": 100})';
|
||||
|
||||
CREATE FUNCTION example_address.set_updated_at() RETURNS trigger
|
||||
LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
NEW.updated_at := now();
|
||||
RETURN NEW;
|
||||
END
|
||||
$$;
|
||||
@@ -0,0 +1,33 @@
|
||||
-- Example Address: operational tables (PostgreSQL 17).
|
||||
-- Source: entities/address.md (existence: independent, mutability: reference).
|
||||
|
||||
CREATE TABLE example_address.address (
|
||||
address_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
address_type text CHECK (address_type IN ('Street Address', 'PO Box', 'Registered Office', 'Overseas Address')), -- enum:Address Type
|
||||
address_line_1 text,
|
||||
address_line_2 text,
|
||||
suburb text,
|
||||
city text,
|
||||
state_or_region text,
|
||||
postcode text,
|
||||
country text NOT NULL, -- constraint: Country Required
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
CONSTRAINT street_address_requires_address_line_1 -- constraint of the same name in the model
|
||||
CHECK (address_type <> 'Street Address' OR address_line_1 IS NOT NULL)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE example_address.address IS 'The canonical record of a physical or postal location. Reference data shared across parties: a single Address record is referenced by all Contact Addresses at that location.';
|
||||
COMMENT ON COLUMN example_address.address.address_id IS 'Globally unique surrogate identifier for this physical location record. Immutable once assigned.';
|
||||
COMMENT ON COLUMN example_address.address.address_type IS 'The structural type of the address. Determines which fields are applicable.';
|
||||
COMMENT ON COLUMN example_address.address.address_line_1 IS 'The primary street address line, typically including street number and street name. For PO Box addresses, the PO Box number.';
|
||||
COMMENT ON COLUMN example_address.address.address_line_2 IS 'Secondary address line for suite, level, unit, or building name where applicable.';
|
||||
COMMENT ON COLUMN example_address.address.suburb IS 'The suburb or locality component of the address.';
|
||||
COMMENT ON COLUMN example_address.address.city IS 'The city or town.';
|
||||
COMMENT ON COLUMN example_address.address.state_or_region IS 'The state, territory, or region.';
|
||||
COMMENT ON COLUMN example_address.address.postcode IS 'The postal code, stored as a string to preserve leading zeros and support international formats.';
|
||||
COMMENT ON COLUMN example_address.address.country IS 'The country in which the address is located, as an ISO 3166-1 alpha-2 country code.';
|
||||
|
||||
CREATE TRIGGER address_set_updated_at
|
||||
BEFORE UPDATE ON example_address.address
|
||||
FOR EACH ROW EXECUTE FUNCTION example_address.set_updated_at();
|
||||
@@ -0,0 +1,26 @@
|
||||
-- Example Address: API surface (runs on the postgres service).
|
||||
|
||||
GRANT USAGE ON SCHEMA example_address TO anon;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA example_address TO anon;
|
||||
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA example_address TO anon;
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA example_address GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO anon;
|
||||
|
||||
-- The product's GraphQL endpoint: POST /rpc/example_address_graphql through PostgREST.
|
||||
-- pg_graphql reflects the schemas on the search_path, so the SET clause scopes the
|
||||
-- endpoint to this product's tables.
|
||||
CREATE FUNCTION api.example_address_graphql(
|
||||
query text,
|
||||
variables jsonb DEFAULT '{}'::jsonb,
|
||||
"operationName" text DEFAULT NULL,
|
||||
extensions jsonb DEFAULT NULL
|
||||
) RETURNS jsonb
|
||||
LANGUAGE sql
|
||||
SECURITY INVOKER
|
||||
SET search_path = example_address, graphql
|
||||
AS $$
|
||||
SELECT graphql.resolve(query, variables, "operationName", extensions);
|
||||
$$;
|
||||
|
||||
GRANT EXECUTE ON FUNCTION api.example_address_graphql(text, jsonb, text, jsonb) TO anon;
|
||||
|
||||
NOTIFY pgrst, 'reload schema';
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Example Address: sample rows (runs on the postgres service).
|
||||
|
||||
INSERT INTO example_address.address
|
||||
(address_id, address_type, address_line_1, address_line_2, suburb, city, state_or_region, postcode, country)
|
||||
VALUES
|
||||
('2f4c1a3e-0001-4a7b-9c11-000000000001', 'Street Address', '1 Queen Street', NULL, 'Auckland Central', 'Auckland', 'Auckland', '1010', 'NZ'),
|
||||
('2f4c1a3e-0001-4a7b-9c11-000000000002', 'PO Box', 'PO Box 123', NULL, NULL, 'Wellington', 'Wellington', '6140', 'NZ'),
|
||||
('2f4c1a3e-0001-4a7b-9c11-000000000003', 'Registered Office', 'Level 5, 100 Collins Street', NULL, NULL, 'Melbourne', 'VIC', '3000', 'AU');
|
||||
@@ -0,0 +1,52 @@
|
||||
# Worked example: the template instantiated for a single entity, Address (entities/address.md),
|
||||
# as a product called Example Address. It deploys and tests on the stack as-is and shows what a
|
||||
# finished product directory looks like. A real product lists every entity in its declaration.
|
||||
|
||||
product:
|
||||
name: "Example Address"
|
||||
slug: "example-address"
|
||||
domain: "digital-core"
|
||||
declaration: "entities/address.md"
|
||||
version: "1.0.0"
|
||||
owner: "data.architecture@bank.com"
|
||||
|
||||
ods:
|
||||
schema: "example_address"
|
||||
tables:
|
||||
- name: "address"
|
||||
entity: "Address"
|
||||
key: "address_id"
|
||||
|
||||
graphql:
|
||||
endpoint: "/rpc/example_address_graphql"
|
||||
smoke: graphql/smoke.graphql
|
||||
|
||||
events:
|
||||
registry_group: "digital-core.example-address"
|
||||
compatibility: BACKWARD
|
||||
topics:
|
||||
- name: "digital-core.example-address.address.inbound"
|
||||
role: publish-input
|
||||
table: "address"
|
||||
schema: events/schemas/address.schema.json
|
||||
partitions: 3
|
||||
cleanup_policy: delete
|
||||
retention_ms: 604800000
|
||||
- name: "digital-core.example-address.address.outbound"
|
||||
role: subscribe-output
|
||||
table: "address"
|
||||
schema: events/schemas/address.schema.json
|
||||
partitions: 3
|
||||
cleanup_policy: compact
|
||||
|
||||
flink:
|
||||
job: flink/job.sql
|
||||
name: "example-address"
|
||||
|
||||
lakehouse:
|
||||
sync_group: ods
|
||||
schema: "example_address"
|
||||
|
||||
trino:
|
||||
catalog: lake
|
||||
smoke: trino/smoke.sql
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Example Address: analytic SQL smoke test through Trino's `lake` catalog.
|
||||
|
||||
SELECT 'address' AS table_name, count(*) AS row_count FROM lake.example_address.address;
|
||||
Reference in new issue
Block a user