{"id":30351487,"url":"https://github.com/cliftonc/drizzle-cube","last_synced_at":"2026-04-01T20:53:19.788Z","repository":{"id":310291599,"uuid":"1039375754","full_name":"cliftonc/drizzle-cube","owner":"cliftonc","description":"An embeddable multi-dimensional semantic layer and self-service analytics module (built on Drizzle) - broadly compliant with cube-js concepts and semantic definitions.","archived":false,"fork":false,"pushed_at":"2026-02-28T08:43:32.000Z","size":9131,"stargazers_count":33,"open_issues_count":18,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-28T14:12:42.718Z","etag":null,"topics":["business-intelligence","drizzle-orm","embedded","mit-license","react","reporting","tailwindcss"],"latest_commit_sha":null,"homepage":"https://try.drizzle-cube.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cliftonc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":["cliftonc"]}},"created_at":"2025-08-17T04:49:03.000Z","updated_at":"2026-02-28T08:41:52.000Z","dependencies_parsed_at":"2026-01-07T13:07:44.581Z","dependency_job_id":null,"html_url":"https://github.com/cliftonc/drizzle-cube","commit_stats":null,"previous_names":["cliftonc/drizzle-cube"],"tags_count":137,"template":false,"template_full_name":null,"purl":"pkg:github/cliftonc/drizzle-cube","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cliftonc%2Fdrizzle-cube","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cliftonc%2Fdrizzle-cube/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cliftonc%2Fdrizzle-cube/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cliftonc%2Fdrizzle-cube/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cliftonc","download_url":"https://codeload.github.com/cliftonc/drizzle-cube/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cliftonc%2Fdrizzle-cube/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30076935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T08:01:56.766Z","status":"ssl_error","status_checked_at":"2026-03-04T08:00:42.919Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["business-intelligence","drizzle-orm","embedded","mit-license","react","reporting","tailwindcss"],"created_at":"2025-08-18T23:02:25.449Z","updated_at":"2026-04-01T20:53:19.777Z","avatar_url":"https://github.com/cliftonc.png","language":"TypeScript","funding_links":["https://github.com/sponsors/cliftonc"],"categories":[],"sub_categories":[],"readme":"# Drizzle Cube\n\n**A Drizzle ORM-first semantic layer for type-safe analytics**\n\n![Drizzle Cube Dashboard](https://try.drizzle-cube.dev/dashboard_light.png)\n\nBuild a semantic layer on top of your Drizzle schema. Define cubes with measures, dimensions, and joins—then query them from dashboards, AI agents, or your own code. All with full TypeScript inference and SQL injection protection.\n\n- **[Documentation](https://www.drizzle-cube.dev/)**\n- **[Try the Sandbox](https://try.drizzle-cube.dev/)**\n- **[Ask for help in Discord](https://discord.gg/kFvT97hZsv)**\n- **[Contribute to the Roadmap](https://github.com/users/cliftonc/projects/2)**\n\n[![NPM Version](https://img.shields.io/npm/v/drizzle-cube)](https://www.npmjs.com/package/drizzle-cube)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue)](https://www.typescriptlang.org/)\n[![Drizzle ORM](https://img.shields.io/badge/Drizzle%20ORM-0.44.4+-green)](https://orm.drizzle.team/)\n[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)\n\n## What is a Semantic Layer?\n\nA semantic layer sits between your database and your applications. It provides:\n\n- **Business-friendly abstractions** - Define \"Revenue\" once, use it everywhere\n- **Consistent metrics** - Everyone uses the same calculation for \"Active Users\"\n- **Security isolation** - Multi-tenant filtering built into every query\n- **Self-service analytics** - Users explore data without writing SQL\n- **Decoupling** - Reports and AI agents continue to work when you change your underlying data model\n\nDrizzle Cube brings this to the Drizzle ORM ecosystem with full type safety.\n\n## Why Drizzle Cube?\n\n| Feature | Drizzle Cube | Raw SQL | Other BI Tools |\n|---------|-------------|---------|----------------|\n| Type Safety | Full TypeScript inference | Manual types | None |\n| SQL Injection | Impossible (parameterized) | Risk | Varies |\n| Multi-tenant | Built-in security context | Manual | Complex |\n| AI Integration | MCP server included | Build yourself | Limited |\n| Setup | Minutes | Hours | Days |\n\n## Quick Start\n\n### 1. Install\n\n```bash\nnpm install drizzle-cube drizzle-orm\n```\n\n### 2. Define Cubes on Your Schema\n\n```typescript\nimport { defineCube } from 'drizzle-cube/server'\nimport { eq } from 'drizzle-orm'\nimport { employees, departments } from './schema'\n\nexport const employeesCube = defineCube('Employees', {\n  // Security: filter by organisation automatically\n  sql: (ctx) =\u003e ({\n    from: employees,\n    where: eq(employees.organisationId, ctx.securityContext.organisationId)\n  }),\n\n  // Define relationships for cross-cube queries\n  joins: {\n    Departments: {\n      targetCube: () =\u003e departmentsCube,\n      relationship: 'belongsTo',\n      on: [{ source: employees.departmentId, target: departments.id }]\n    }\n  },\n\n  measures: {\n    count: { type: 'count', sql: employees.id },\n    avgSalary: { type: 'avg', sql: employees.salary },\n    totalSalary: { type: 'sum', sql: employees.salary }\n  },\n\n  dimensions: {\n    name: { type: 'string', sql: employees.name },\n    email: { type: 'string', sql: employees.email },\n    hiredAt: { type: 'time', sql: employees.hiredAt }\n  }\n})\n```\n\n### 3. Create API Server\n\n```typescript\nimport { Hono } from 'hono'\nimport { createCubeApp } from 'drizzle-cube/adapters/hono'\nimport { employeesCube, departmentsCube } from './cubes'\n\nconst app = createCubeApp({\n  cubes: [employeesCube, departmentsCube],\n  drizzle: db,\n  schema,\n  extractSecurityContext: async (req) =\u003e ({\n    organisationId: req.user.orgId  // Multi-tenant isolation\n  })\n})\n\nexport default app\n```\n\n### 4. Query from Anywhere\n\n```typescript\n// From React components\nimport { AnalysisBuilder, AnalyticsDashboard } from 'drizzle-cube/client'\n\n// From AI agents via MCP\n// Connect Claude, ChatGPT, or n8n to /mcp\n\n// From your own code\nconst result = await fetch('/cubejs-api/v1/load', {\n  method: 'POST',\n  body: JSON.stringify({\n    query: {\n      measures: ['Employees.count', 'Employees.avgSalary'],\n      dimensions: ['Departments.name']\n    }\n  })\n})\n```\n\n## Analysis Modes\n\nDrizzle Cube supports multiple analysis modes out of the box:\n\n### Query Builder (Analysis Builder)\nBuild ad-hoc queries with measures, dimensions, filters, and time ranges. Search-first field picker, drag-and-drop chart configuration, and multiple visualization options.\n\n![Analysis Builder](https://try.drizzle-cube.dev/dashboard_light.png)\n\n**[Try the Analysis Builder →](https://try.drizzle-cube.dev/analysis-builder)**\n\n### Funnel Analysis\nTrack conversion through multi-step processes. Define funnel steps, measure drop-off rates, and analyze time-to-convert metrics (average, median, p90).\n\n```typescript\n// Funnel query example\n{\n  analysisType: 'funnel',\n  steps: [\n    { name: 'Signed Up', filter: { member: 'Users.status', operator: 'equals', values: ['registered'] } },\n    { name: 'Activated', filter: { member: 'Users.activated', operator: 'equals', values: [true] } },\n    { name: 'Subscribed', filter: { member: 'Users.plan', operator: 'notEquals', values: ['free'] } }\n  ],\n  timeDimension: 'Users.createdAt',\n  dateRange: ['2024-01-01', '2024-12-31']\n}\n```\n\n### Flow Analysis\nVisualize user journeys and navigation paths through your application. Understand how users move between states or pages.\n\n### Retention Analysis\nMeasure user retention over time with cohort analysis. Track how many users return after their first interaction across days, weeks, or months.\n\n### Dashboards\nCompose multiple charts into persistent dashboards with grid layouts, filters, and real-time updates. Save and share dashboard configurations.\n\n**[Try the Dashboard Builder →](https://try.drizzle-cube.dev/)**\n\n## AI \u0026 MCP Integration\n\nDrizzle Cube includes a built-in **MCP server** that lets AI agents query your semantic layer:\n\n![Claude using Drizzle Cube MCP](https://try.drizzle-cube.dev/claude_mcp.png)\n\n### Available MCP Tools\n\n| Tool | Purpose |\n|------|---------|\n| `drizzle_cube_discover` | Find relevant cubes by topic |\n| `drizzle_cube_validate` | Validate queries with auto-corrections |\n| `drizzle_cube_load` | Execute queries and return data |\n| `drizzle_cube_chart` | Execute queries with interactive chart visualization |\n\n### Connect AI Tools\n\n**Claude Desktop** - Add to `claude_desktop_config.json`:\n```json\n{\n  \"mcpServers\": {\n    \"analytics\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@anthropic/mcp-remote\", \"https://your-app.com/mcp\"]\n    }\n  }\n}\n```\n\n**Claude.ai** - Settings → Connectors → Add your MCP URL\n\n**ChatGPT** - Settings → Connectors → Developer Mode → Add MCP URL\n\n**n8n** - Use the MCP Client node in your workflows\n\n**[Learn more about AI integration →](https://www.drizzle-cube.dev/ai/mcp-endpoints/)**\n\n## Claude Code Plugin\n\nQuery your semantic layer with natural language directly from Claude Code:\n\n```bash\nclaude /install-plugin github:cliftonc/drizzle-cube-plugin\n```\n\nThen configure your API endpoint in `.drizzle-cube.json` and ask Claude things like:\n- \"Show me revenue by region for the last quarter\"\n- \"Which departments have the highest average salary?\"\n- \"Create a dashboard showing key HR metrics\"\n\n**[Plugin documentation →](https://www.drizzle-cube.dev/ai/claude-code-plugin/)**\n\n## Features\n\n### Semantic Layer\n- **Cubes** - Define measures, dimensions, and calculated fields\n- **Joins** - belongsTo, hasOne, hasMany, belongsToMany relationships\n- **Security** - Multi-tenant isolation via security context\n- **Cross-cube queries** - Automatic join resolution\n\n### Modeling Note: Multi-Fact Queries\n- For `FactA -\u003e Dimension \u003c- FactB` (star/snowflake patterns), define reverse `hasMany` joins on the center dimension back to each fact.\n- Example: if `Sales` and `Inventory` both `belongsTo Products`, `Products` should define `hasMany Sales` and `hasMany Inventory`.\n- Why: join-path traversal is directional. Without reverse joins, the planner may not be able to pick the center dimension as the primary cube, which can lead to fan-out-prone execution plans.\n- If you cannot add reverse joins immediately, include the center join key dimension (for example `Products.id`) in the query grain to reduce aggregation ambiguity.\n\n### Client Components\n- **AnalysisBuilder** - Interactive query builder with chart visualization\n- **AnalyticsDashboard** - Configurable dashboards with grid layouts\n- **Chart components** - Bar, line, area, pie, funnel, heatmap, and more\n\n### Framework Support\n- Express, Fastify, Hono, Next.js adapters\n- PostgreSQL, MySQL, SQLite, DuckDB databases\n- React components with TanStack Query\n\n### Theming\nThree built-in themes (light, dark, neon) with semantic CSS variables. Add custom themes without changing components.\n\n## Documentation\n\n- **[Getting Started](https://www.drizzle-cube.dev/getting-started/)** - Installation and setup\n- **[Semantic Layer](https://www.drizzle-cube.dev/semantic-layer/)** - Cubes, measures, dimensions, joins\n- **[Client Components](https://www.drizzle-cube.dev/client/)** - React components and hooks\n- **[AI Integration](https://www.drizzle-cube.dev/ai/)** - MCP server and Claude plugin\n- **[API Reference](https://www.drizzle-cube.dev/api-reference/)** - Complete API documentation\n\n## Examples\n\n- **[Hono Example](https://github.com/cliftonc/drizzle-cube/tree/main/examples/hono)** - Cloudflare Workers compatible\n- **[Express Example](https://github.com/cliftonc/drizzle-cube/tree/main/examples/express)** - Traditional Node.js server\n- **[Fastify Example](https://github.com/cliftonc/drizzle-cube/tree/main/examples/fastify)** - High-performance server\n- **[Next.js Example](https://github.com/cliftonc/drizzle-cube/tree/main/examples/nextjs)** - Full-stack React\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md).\n\n## Roadmap\n\nView and contribute to the roadmap on [GitHub Projects](https://github.com/users/cliftonc/projects/2).\n\n## License\n\nMIT © [Clifton Cunningham](https://github.com/cliftonc)\n\n---\n\n**Built with ❤️ for the Drizzle ORM community**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcliftonc%2Fdrizzle-cube","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcliftonc%2Fdrizzle-cube","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcliftonc%2Fdrizzle-cube/lists"}