Skip to content

About

Open e-commerce data models for ClickHouse in the Apache Ossie format: canonical entities and source packages

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

dactopus-data-models

CI License Release

Open data models for e-commerce on ClickHouse, written in the Apache Ossie semantic model format, with IoT devices as a reference domain. Two kinds of content:

  • Canonical entities: sessions, events and purchases from web analytics; orders, their lines, discount codes, refunds, sales events and customers, and the catalog's products with their categories and brands, from the store; devices and their readings, the reference domain iot. They have the same shape whatever the data came from.
  • Source packages: each maps one source onto those entities. GA4, Shopify, WooCommerce and Sensor.Community are available.

A store on Shopify and a WooCommerce store on its own MySQL look the same once mapped, and one query works on both; unions add up several stores, properties or networks (deployment). BI tools read the tables, AI agents the model through dactopus-ossie-clickhouse. Plans: ROADMAP.md.

How the packages work: the GA4 export, Shopify's orders, a WooCommerce store's order tables and Sensor.Community's readings are loaded into input tables in your ClickHouse; the dbt packages build the canonical tables, and unions add up those of several stores; BI tools read them directly and AI agents through dactopus-ossie-clickhouse and the Ossie models.

The interactive version explains each part and follows one purchase from GA4 to an agent's answer.

Sources

Source Entities Guide
GA4 (BigQuery export) events, sessions, purchases sources/ga4
Shopify (GraphQL Admin API) orders, order_lines, refunds, sales_events, customers, products, line_categories, line_brands, order_discount_codes, product_categories, product_brands sources/shopify
WooCommerce (the store's MySQL tables through CDC) the same as Shopify sources/woocommerce
Sensor.Community (the archive's files and the API's snapshots) devices, readings; the reference domain sources/sensor_community

Where the two order sources differ, such as which orders the store's reports count, the entities' descriptions say how. iot is a reference domain drawn from one public dataset, the Sensor.Community air quality network; a field goes in when any network of devices would have it (Authoring rules).

Quick start

Build the Shopify package over the rows the repository tests it with and ask the commerce model about them. You need ClickHouse (26.8, the LTS release, or later), dbt v2 (pip install dbt-oss) or dbt v1 (dbt-core 1.11 with dbt-clickhouse), and dactopus-ossie-clickhouse 0.15.0 or later with its MCP server (pip install "dactopus-ossie-clickhouse[mcp]").

Add this profile to ~/.dbt/profiles.yml (packages ship none). Over TLS, as ClickHouse Cloud requires, add secure: true, set the HTTPS port, and give dactopus-ossie-clickhouse https:// URLs.

dactopus:
  target: default
  outputs:
    default:
      type: clickhouse
      # The database the canonical tables are written to.
      schema: "{{ env_var('CLICKHOUSE_DATABASE', 'dactopus') }}"
      host: "{{ env_var('CLICKHOUSE_HOST', 'localhost') }}"
      port: "{{ env_var('CLICKHOUSE_PORT', '8123') | int }}"
      user: "{{ env_var('CLICKHOUSE_USER', 'default') }}"
      password: "{{ env_var('CLICKHOUSE_PASSWORD', '') }}"
      custom_settings:
        # The dbt v2 ClickHouse adapter (beta) decompresses LZ4 only, while
        # ClickHouse 26.x compresses HTTP responses with ZSTD by default.
        network_compression_method: LZ4

The rows, tests/shopify/fixture.sql, are twelve orders of a shop in New York and its thirteen products, each a case the package must get right (refunds, cancellations, discounts, tax included in prices, a gift card, a tip, import duties, repeated deliveries, a product's type and vendor changed, a deleted product).

  1. Load the input tables sources/shopify/input.sql and the rows into a database the variable shopify_input_database names.

    clickhouse client --param_db=shopify_sample_raw --multiquery < sources/shopify/input.sql
    clickhouse client --param_db=shopify_sample_raw --multiquery < tests/shopify/fixture.sql
  2. Build in the shop's time zone, as Shopify's reports date orders (the default is UTC).

    CLICKHOUSE_DATABASE=shopify_sample dbt build --project-dir sources/shopify \
        --vars '{shopify_input_database: shopify_sample_raw, shopify_timezone: America/New_York}'
  3. Validate and check. check_numbers.py asks 49 questions and compares the answers with numbers worked out by hand from the rows.

    dactopus-ossie-clickhouse validate entities/commerce.yaml --url http://user:password@host:8123/shopify_sample --time-zone America/New_York
    OSSIE_CLICKHOUSE_URL=http://user:password@host:8123/shopify_sample OSSIE_CLICKHOUSE_TIME_ZONE=America/New_York uv run tests/shopify/check_numbers.py
  4. Ask. Serve the model over MCP in the shop's zone (connecting an agent). Try net revenue, refunds by month, average order value and repeat orders by country, revenue by product type, products not sold since a date.

    dactopus-ossie-clickhouse serve entities/commerce.yaml \
        --url http://user:password@host:8123/shopify_sample --time-zone America/New_York

The same walk for each source, and for a store, your own: GA4 (Google's public sample export), Shopify (then your store through the GraphQL Admin API), WooCommerce (eighteen hand-written orders, then your store mirrored by PeerDB), Sensor.Community (one country's sensors).

Documentation

Versioning

One version for the whole repository, SemVer, tags vX.Y.Z; the Ossie schema version (0.3.0.dev0) is separate, and the GitHub release names it for every release.

A breaking change stops a deployment working or changes its numbers: renaming or removing a field, metric or column, changing a column's type or what a metric means, a new required input column. Before 1.0 these come in a minor release, after it in a major one. New fields and metrics are minor, fixes are patches.

A deployment pins one tag for its packages (sources/<source>), unions (unions/<domain>) and Ossie models. Upgrading is changing the tag and running dbt build --full-refresh, which rebuilds every table from the input; UPGRADING.md lists the releases that need it and any change to an input table.

License

Apache License 2.0. Packages adapted from Fivetran's dbt packages (Apache 2.0) say so in the package and keep the original notices.

About

Open e-commerce data models for ClickHouse in the Apache Ossie format: canonical entities and source packages

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages