hypequery - The TypeScript analytics layer for ClickHouse
See the code
The type-safe analytics backend for ClickHouse.
hypequery is an open-source TypeScript semantic layer and type-safe query builder for ClickHouse. Define analytics once, then use the same trusted contract in backend code, multi-tenant APIs, React hooks, and MCP tools for AI agents.
It fits the stack you already have. Generate types from your live ClickHouse schema, model metrics in normal TypeScript, and catch broken tables, columns, filters, and result shapes before production—without another BI server or YAML project.
Quick start · Capabilities · Examples · MCP
import { dataset, dimension, measure } from '@hypequery/datasets';
export const Orders = dataset('orders', {
source: 'orders',
tenantKey: 'tenant_id',
timeKey: 'created_at',
dimensions: {
region: dimension.string(),
status: dimension.string(),
createdAt: dimension.timestamp({ column: 'created_at' }),
},
measures: {
revenue: measure.sum('amount'),
orderCount: measure.count('id'),
p95OrderValue: measure.percentile('amount', 0.95),
},
});
export const revenue = Orders.metric('revenue', {
measure: 'revenue',
});
That dataset can run in a worker, become a validated HTTP endpoint, power a typed React dashboard, or appear as a bounded MCP tool. Tenant scope and metric meaning stay in one place.
npm install -D @hypequery/cli
npx hypequery init
npx hypequery dev
Or add only the ClickHouse query builder:
npm install @hypequery/clickhouse
const revenueByRegion = await db
.table('orders')
.select(['region'])
.where('status', 'eq', 'completed')
.sum('amount', 'revenue')
.groupBy('region')
.orderBy('revenue', 'DESC')
.execute();
No hand-written result interface. No any[]. The result is inferred from your real schema and the query itself.
FINAL, LIMIT BY, percentiles, argMax, arrays, CTEs, streaming, and window expressions.| Package | Job |
|---|---|
@hypequery/clickhouse | Type-safe ClickHouse query builder |
@hypequery/datasets | TypeScript semantic layer |
@hypequery/serve | Validated analytics APIs and OpenAPI |
@hypequery/react | Typed React hooks |
@hypequery/mcp | Governed ClickHouse MCP server |
@hypequery/cli | Setup, generation, local docs, and deployment |
If hypequery saves you from another copied SQL string or drifting metric, a GitHub star helps the next TypeScript team find it.
Apache-2.0. See LICENSE.
603 commits
91 commits
4 commits
2 commits
TypeScript
86.3%
MDX
7.8%
Python
3.1%
JavaScript
2.3%
hypequery - The TypeScript analytics layer for ClickHouse
See the code
The type-safe analytics backend for ClickHouse.
hypequery is an open-source TypeScript semantic layer and type-safe query builder for ClickHouse. Define analytics once, then use the same trusted contract in backend code, multi-tenant APIs, React hooks, and MCP tools for AI agents.
It fits the stack you already have. Generate types from your live ClickHouse schema, model metrics in normal TypeScript, and catch broken tables, columns, filters, and result shapes before production—without another BI server or YAML project.
Quick start · Capabilities · Examples · MCP
import { dataset, dimension, measure } from '@hypequery/datasets';
export const Orders = dataset('orders', {
source: 'orders',
tenantKey: 'tenant_id',
timeKey: 'created_at',
dimensions: {
region: dimension.string(),
status: dimension.string(),
createdAt: dimension.timestamp({ column: 'created_at' }),
},
measures: {
revenue: measure.sum('amount'),
orderCount: measure.count('id'),
p95OrderValue: measure.percentile('amount', 0.95),
},
});
export const revenue = Orders.metric('revenue', {
measure: 'revenue',
});
That dataset can run in a worker, become a validated HTTP endpoint, power a typed React dashboard, or appear as a bounded MCP tool. Tenant scope and metric meaning stay in one place.
npm install -D @hypequery/cli
npx hypequery init
npx hypequery dev
Or add only the ClickHouse query builder:
npm install @hypequery/clickhouse
const revenueByRegion = await db
.table('orders')
.select(['region'])
.where('status', 'eq', 'completed')
.sum('amount', 'revenue')
.groupBy('region')
.orderBy('revenue', 'DESC')
.execute();
No hand-written result interface. No any[]. The result is inferred from your real schema and the query itself.
FINAL, LIMIT BY, percentiles, argMax, arrays, CTEs, streaming, and window expressions.| Package | Job |
|---|---|
@hypequery/clickhouse | Type-safe ClickHouse query builder |
@hypequery/datasets | TypeScript semantic layer |
@hypequery/serve | Validated analytics APIs and OpenAPI |
@hypequery/react | Typed React hooks |
@hypequery/mcp | Governed ClickHouse MCP server |
@hypequery/cli | Setup, generation, local docs, and deployment |
If hypequery saves you from another copied SQL string or drifting metric, a GitHub star helps the next TypeScript team find it.
Apache-2.0. See LICENSE.
603 commits
91 commits
4 commits
2 commits
TypeScript
86.3%
MDX
7.8%
Python
3.1%
JavaScript
2.3%