Dynamic PricingClickHouse Workshops

00 Set up your retail environment

Separate credentials, owned services, and readiness make data failures diagnosable.

Votre ordinateur
Terminal macOS : Exécutez les commandes de l’atelier dans le Terminal avec zsh ou bash.

Outcome

Create your dedicated ClickHouse Cloud service, managed Postgres instance, and operational CDC pipeline. Confirm access to ClickHouse Agents. Your laptop runs the sales generator and pricing workbench.

Analytics workshop with a prepared model

A production team can use ClickHouse transaction history and features such as price, promotions, availability, calendars, and weather to train a demand or revenue model. This workshop supplies a prepared model and synthetic sales; production model training is outside its scope. You will learn the data pipeline, SQL calculations, and how approved prices lead to generated transactions and observed analytics.

Starting point

Use your own ClickHouse Cloud account and a terminal for your platform.

Why

Separate credentials, owned services, and readiness make data failures diagnosable.

Cloud architecture

Historical Parquet files load from S3. The sales generator sends batched transaction lines directly to ClickHouse. Managed Postgres stores inventory, prices, policies, run metadata, batch acknowledgements, and approval receipts. ClickPipes replicates those operational records into ClickHouse.

SQL queries combine sales and operational state to discover pricing opportunities. ClickHouse Agents uses the same analytical views to recommend a strategy. You approve a price in the workbench; subsequent synthetic sales use it. ClickStack traces that application.

S3 history and live sales enter ClickHouse; operational Postgres records arrive through ClickPipes. SQL and agent recommendations support learner-approved prices, with ClickStack for logs and traces.

Actions

Choose your platform in the page header. Complete installation and account access before the session; the 25-minute module connects and verifies the stack.

Use macOS Terminal. Install Docker Desktop, Git, Python 3.12, and Node 22. Install the pinned ClickHouse CLI in your user directory:

npm install --global --prefix "$HOME/.local" clickhousectl@0.4.2
export PATH="$HOME/.local/bin:$PATH"

Add the export PATH line to ~/.zshrc so new terminals find the tool. Verify:

docker version
docker compose version
git --version
python3.12 --version
node --version
clickhousectl --version
  1. Clone the workshop repository and install the lab dependencies:

    git clone https://github.com/ClickHouse/ClickHouse_Demos.git
    cd ClickHouse_Demos
    cd "$(git rev-parse --show-toplevel)/workshops/dynamic_pricing"
    python3.12 -m venv .venv
    .venv/bin/python -m pip install -r versions.lock -e app/backend
    cp app/.env.workshop.example app/.env.workshop
    chmod 600 app/.env.workshop
  2. Create an API key for your own organization to authenticate Cloud mutations. In the ClickHouse Cloud console, open the organization menu and select API keys.

    ClickHouse Cloud organization menu with API keys highlighted

    Select New API key. Name the key dynamic_pricing, select the Admin role required to create the workshop resources, then select Generate API key. Save the generated key and secret privately.

    Create API key dialog with the dynamic_pricing name, Admin role, and Generate API key button

    OAuth is read-only. Run this login command separately, substituting your private credentials; keep them out of shared terminals and shell history:

    clickhousectl cloud auth login --api-key '<YOUR_API_KEY>' --api-secret '<YOUR_API_SECRET>'

    The CLI stores credentials in .clickhouse/credentials.json, which is ignored by Git.

  3. Edit the private file if you need to change the region or Postgres size. The template already selects Singapore and the prepared workshop model. Leave the ClickHouse hostname and both Postgres connection strings empty. Setup creates the managed services and fills in their Cloud endpoints. It also generates a stable installation ID and session secret. Setup detects your Cloud organization and public IPv4 address; if your API key can access several organizations, select one when prompted. Verify your CLI account:

    clickhousectl cloud auth status
    clickhousectl cloud org list

    Create your owned services:

    bash scripts/setup-cloud.sh

    This single command creates your ClickHouse Cloud service with one replica, pricing and telemetry databases, managed Postgres source schema, application and replication roles, publication, and six-table operational CDC ClickPipe. Progress messages show resource creation and readiness while setup waits for the destination schema and creates canonical views. Repeated setup preserves existing scenario state and reuses saved resource IDs.

    Setup creates Managed Postgres with source tables, roles, and a publication; a six-table CDC ClickPipe; and one ClickHouse Cloud service with pricing and otel databases. Connection settings, resource IDs, and the CA certificate are saved locally.

    The three Cloud resources appear in infra/resources.json. The files in the diagram's lower row stay on your laptop. You load historical data and build aggregates in Modules 01 and 02.

    To start over, stop the local workbench if it is running, then preview the workshop resources to delete:

    bash scripts/setup-cloud.sh --destroy

    Review the listed IDs. The following command permanently deletes your workshop ClickPipe, Managed Postgres instance, and ClickHouse service, including their data:

    bash scripts/setup-cloud.sh --destroy --execute

    After deletion completes, create a fresh stack with one replica:

    bash scripts/setup-cloud.sh

    Setup archives the deleted resource inventory and replaces the old connection settings. Your CLI login and workshop preferences remain available. Repeat Module 01 to reload historical data and Module 02 to rebuild aggregates and start sales.

  4. Inspect infra/resources.json: organization, region, service ID, Postgres ID, and ClickPipe ID. The inventory stores IDs; preflight checks readiness. Keep PRICING_POSTGRES_ADMIN_DSN for schema initialization and grants. Setup saves PRICING_POSTGRES_DSN with the limited pricing_app role and privately stores the generated replication password. No manual role creation, URI editing, or pipe-ID editing is required. Module 02 checks operational CDC beside the direct sales stream.

  5. Verify the private Cloud hostname is bare, the SQL port is 8443 with TLS, and managed Postgres uses sslmode=verify-full plus its instance CA. No local Postgres or ClickHouse substitutes for this path.

Do not start the app until Module 01 has loaded history. The app's liveness endpoint and data readiness answer different questions.

6. Check managed agent access

In ClickHouse Cloud, select ClickHouse Agents, then Launch. Confirm you can open the managed chat and agent builder. You will create Retail Pricing Strategist in Module 05. Choose its model in the managed UI; no separate model API key is required in the local environment.

Verify

The setup command reports ready. Your inventory contains the ClickHouse service, Postgres instance, and ClickPipe IDs.

Reset

Keep your saved inventory for the remaining modules. Delete your services in Module 06.

Stretch

Explain liveness versus module readiness before starting the app.

Instructor notes.

Sur cette page

Suivre votre progression ?

Facultatif. Nous envoyons un lien par e-mail pour confirmer votre adresse ; la progression est enregistrée après son ouverture.

Utilisez votre adresse e-mail professionnelle, et non une adresse personnelle.

En continuant, vous acceptez les Conditions d’utilisation.

FR