Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/clickhouse-reference-architecture

@0d57af8
Run it yourself

Production reference architecture for ClickHouse-backed applications — project layout, data flow, multi-tenant patterns, and operational topology. Use when designing a new ClickHouse system, reviewing an existing analytics architecture, or establishing standards for ClickHouse integrations. Trigger with "clickhouse architecture", "clickhouse project structure", "clickhouse design", "clickhouse multi-tenant", "clickhouse reference".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/clickhouse-reference-architecture

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesmulti-tenant-patterns.md

≈408 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Multi-Tenant Patterns

Three isolation strategies, from lowest to highest operational overhead. Approach A is the recommended default and scales to 10K+ tenants; reach for B or C only when a compliance boundary demands stricter isolation.

Approach A: Shared table with tenant_id in ORDER BY (recommended)

-- Tenant_id first in ORDER BY = queries filter on tenant efficiently
ORDER BY (tenant_id, event_type, created_at)

-- Query: only scans data for this tenant
SELECT count() FROM events_raw WHERE tenant_id = 42;

Putting tenant_id first in the sort key lets ClickHouse skip every granule that doesn't belong to the tenant, so per-tenant queries stay fast even as the shared table grows. One schema, one set of DDL changes, one place to operate.

Approach B: Database per tenant (for strict isolation)

CREATE DATABASE tenant_42;
CREATE TABLE tenant_42.events (...) ENGINE = MergeTree() ...;

-- Pros: Full isolation, easy to drop tenant
-- Cons: Schema changes need per-tenant DDL, more operational overhead

Use when a tenant must be fully separable — e.g. one-command offboarding via DROP DATABASE, or a contractual data-isolation requirement. The cost is fan-out on every migration.

Approach C: Row-level security (ClickHouse RBAC)

CREATE ROW POLICY tenant_isolation ON analytics.events_raw
    FOR SELECT USING tenant_id = getSetting('custom_tenant_id')
    TO app_user;

Enforces the tenant filter in the database itself, so an application bug that forgets a WHERE tenant_id = … clause cannot leak cross-tenant rows. Pairs well with Approach A as defense-in-depth.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides a reference architecture and best practices for building ClickHouse-backed applications. It includes standard project structures, schema designs, and client-side code templates that adhere to security best practices such as parameterized queries and environment-based secret management.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 4 months ago
What it can do
Reads files
version
1.7.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
[
  "saas",
  "database",
  "analytics",
  "clickhouse",
  "olap"
]
All 2 allowed tools
ReadGrep
Other metadata
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/clickhouse-reference-architecture