Scaffold domain digital-core

This commit is contained in:
paul committed 2026-09-17 23:22:37 +12:00
commit 64e0ce27ba
13 files changed
+212

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
# digital-core — secrets and ports for this domain's stack. Never commit .env.
# platform/setup-domain.sh creates .env from this file and generates every CHANGE_ME.
# Keep values shell-safe (letters, digits, - _): scripts source .env.
DOMAIN=digital-core
# Host ports, all bound to 127.0.0.1 (port base 20000; give each domain its own base)
GRAPHQL_PORT=20000
KAFKA_PORT=20001
FLINK_PORT=20002
TRINO_PORT=20003
MINIO_CONSOLE_PORT=20004
KAFKA_CLUSTER_ID=CHANGE_ME
ODS_PASSWORD=CHANGE_ME
AUTHENTICATOR_PASSWORD=CHANGE_ME
LAKEHOUSE_PASSWORD=CHANGE_ME
MINIO_ROOT_USER=lake-admin
MINIO_ROOT_PASSWORD=CHANGE_ME
DBT_PASSWORD=CHANGE_ME
TRINO_LAKE_PASSWORD=CHANGE_ME
# Written by platform/domain-integration.sh register|unregister mgmt.
# COMPOSE_PROFILES=scheduled starts the dbt-worker once Airflow can accept it.
AIRFLOW_JWT_SECRET=
COMPOSE_PROFILES=
+6
View File
@@ -0,0 +1,6 @@
.env
.venv/
__pycache__/
dbt/target/
dbt/logs/
dbt/dbt_packages/
+3
View File
@@ -0,0 +1,3 @@
[submodule "platform"]
path = platform
url = https://git.semprini.me/paul/semprini-data-domain.git
+48
View File
@@ -0,0 +1,48 @@
# Data domain: digital-core
The running instance of the digital-core data domain: its stack, its generated data products and
its dbt project. Owned and operated by the domain's data product engineering team.
It brings together work from three teams, each in its own repository:
| Input | Owner | Repository | Used as |
|---|---|---|---|
| Domain platform | Data platform team | [semprini-data-domain](https://git.semprini.me/paul/semprini-data-domain) | the `platform/` submodule |
| Domain data model | Modelling team | the domain's `semprini-domain-*-datamodel` repository | product declarations and entities to generate from |
| Data product templates | Engineering teams | [semprini-data-product-templates](https://git.semprini.me/paul/semprini-data-product-templates) | what a product directory looks like, and the agent that generates it |
| Path | What |
|---|---|
| `compose.yml` | The domain stack: includes `platform/compose.domain.yml` |
| `.env` | Domain name, ports and secrets (generated, never committed) |
| `products/<slug>/` | Data products generated from a template for one model declaration |
| `dbt/` | dbt project for experience data products, built into the lakehouse |
| `dbt/schedules.yml` | When the management zone's Airflow runs them |
Record which model and template versions a product was generated from in its commit
message, e.g. `Generate canonical-party from digital-datamodel v1.0.0, templates v0.1.0`.
## Run
The data management zone must be up first (semprini-data: `./stack-data.sh up mgmt`).
```bash
git submodule update --init # after cloning
platform/setup-domain.sh # .env with generated secrets (idempotent)
docker compose up -d --build # the domain stack
uv run data-domain deploy <templates>/canonical_data_product/example # platform smoke test
uv run data-domain test <templates>/canonical_data_product/example
```
Run `data-domain` from this directory; it acts on the domain repository it is run in.
Register with Keycloak (classification groups), OpenMetadata and Airflow, then start the
dbt-worker that the registration enables:
```bash
platform/domain-integration.sh register all
docker compose up -d
```
Ports (127.0.0.1): GraphQL 20000, Kafka 20001, Flink 20002, Trino 20003,
MinIO console 20004. See `platform/README.md` for the platform.
+14
View File
@@ -0,0 +1,14 @@
# compose.yml — data domain digital-core
#
# The platform (ODS, GraphQL, Kafka, Flink, lakehouse, Trino, dbt-worker) is defined in
# platform/compose.domain.yml, from the semprini-data-domain submodule. Add services
# that belong only to this domain below the include.
#
# Requires the data management zone: cd ../semprini-data && ./stack-data.sh up mgmt
name: digital-core
include:
- path: platform/compose.domain.yml
project_directory: .
env_file: .env
+26
View File
@@ -0,0 +1,26 @@
# dbt project for the digital-core domain's experience data products.
#
# Runs against the lakehouse as role `dbt`, whose default table access method is
# ducklake, so every model table is DuckLake (Parquet in MinIO), readable through
# Trino as lake.<schema>.<table>. Give each experience product its own schema:
# models/<product_schema>/*.sql with +schema: <product_schema>
#
# By hand: uv run data-domain dbt build
# Scheduled: schedules.yml, registered with platform/domain-integration.sh register mgmt
name: digital_core
version: "1.0.0"
profile: domain
model-paths: ["models"]
macro-paths: ["macros"]
models:
digital_core:
+materialized: table
# Trino reads the lake as `trino`, a member of ducklake_reader.
+grants:
select: ["ducklake_reader"]
on-run-end:
- "{% for schema in schemas %}grant usage on schema {{ schema }} to ducklake_reader;{% endfor %}"
+52
View File
@@ -0,0 +1,52 @@
{#-
Macros that make dbt-postgres work against pg_ducklake. Verified 2026-09-17 with
dbt-core 1.12.5 / dbt-postgres 1.11.0 for table, view and incremental models.
-#}
{#-
dbt-postgres stages incremental rows in `create temporary table ... as`. The dbt role
runs with default_table_access_method = ducklake, and DuckLake tables cannot be
temporary ("temporary tables are not supported with ducklake access method"), so
temporary tables are pinned to heap. Everything else is dbt-postgres's macro verbatim.
-#}
{% macro postgres__create_table_as(temporary, relation, sql) -%}
{%- set unlogged = config.get('unlogged', default=false) -%}
{%- set sql_header = config.get('sql_header', none) -%}
{{ sql_header if sql_header is not none }}
create {% if temporary -%}
temporary
{%- elif unlogged -%}
unlogged
{%- endif %} table {{ relation }}
{% if temporary -%} using heap {%- endif %}
{% set contract_config = config.get('contract') %}
{% if contract_config.enforced %}
{{ get_assert_columns_equivalent(sql) }}
{% endif -%}
{% if contract_config.enforced and (not temporary) -%}
{{ get_table_columns_and_constraints() }} ;
insert into {{ relation }} (
{{ adapter.dispatch('get_column_names', 'dbt')() }}
)
{%- set sql = get_select_subquery(sql) %}
{% else %}
as
{% endif %}
(
{{ sql }}
);
{%- endmacro %}
{#-
A model's +schema is its experience product's schema, used as given rather than
prefixed with the target schema, so the product reads as lake.<schema>.<table>.
-#}
{% macro generate_schema_name(custom_schema_name, node) -%}
{%- if custom_schema_name is none -%}
{{ target.schema }}
{%- else -%}
{{ custom_schema_name | trim }}
{%- endif -%}
{%- endmacro %}
View File
Whitespace-only changes.
+16
View File
@@ -0,0 +1,16 @@
# dbt connection profile, read inside the dbt-worker container.
# DBT_PASSWORD comes from the domain's .env; nothing else leaves the domain.
domain:
target: lakehouse
outputs:
lakehouse:
type: postgres
host: lakehouse
port: 5432
user: dbt
password: "{{ env_var('DBT_PASSWORD') }}"
dbname: lake
schema: experience
# DuckLake does not retry conflicting transactions. On a first run dbt creates
# schemas from several threads at once, and two creating the same schema abort.
threads: 1
+9
View File
@@ -0,0 +1,9 @@
# dbt schedules for domain digital-core: one Airflow DAG per entry, run by this domain's
# dbt-worker (platform/airflow/dbt_dags.py). The management zone's Airflow reads a copy,
# so re-run `platform/domain-integration.sh register mgmt` after editing this file.
domain: digital-core
schedules: []
# - name: experience-hourly # DAG id: dbt_digital_core_experience_hourly
# select: tag:hourly # dbt node selection
# schedule: "@hourly" # cron or preset; null for manual runs only
# description: Rebuild the experience products tagged hourly
Submodule
+1
Submodule platform added at fbbbef3a1d.
View File
Whitespace-only changes.
+11
View File
@@ -0,0 +1,11 @@
[project]
name = "semprini-domain-digital-core"
version = "0.1.0"
description = "Data domain digital-core"
requires-python = ">=3.12"
dependencies = [
"semprini-data-domain",
]
[tool.uv.sources]
semprini-data-domain = { path = "platform", editable = true }