Platform design: self-hosted Cube Cloud on Cube Core
Status: accepted · Date: 2026-12-02 · Background: Cloud vs Core research
CubeBI rebuilds Cube Cloud's product layer as services around an unmodified Cube Core. It runs entirely on the customer's host. The only outbound connection is the optional Claude API used by the AI features.
Decisions
| # | Decision | Choice | Consequence |
|---|---|---|---|
| D1 | Deployment target | Docker Compose on one host | One docker-compose.yml, images pinned by digest, releases shipped as an offline bundle. No Kubernetes work for now. |
| D2 | Tenancy | One organisation per install | No tenant IDs in content tables and one Cube app ID. Data security comes only from groups and user attributes. |
| D3 | Identity | Keycloak | Local users, groups, attributes and MFA, with optional LDAP/AD federation later. The platform turns Keycloak identities into per-user Cube JWTs. |
| D4 | AI | Claude API (Messages API), agent loop hosted by us | Only model calls leave the host. Tools, queries, chat history and data access all stay local. The product works fully with AI turned off. |
| D5 | Engine | Cube Core, unmodified | Customisation only through cube.js hooks and the model. Cube upgrades are image bumps. |
What "offline" means here
- No outbound traffic except
api.anthropic.com, and only when AI is enabled. No telemetry, CDNs, external fonts, map tiles or SaaS connectors. - AI off = fully functional BI. Explore, dashboards, deliveries and alerts never depend on the model.
- Supply chain: images come from a mirror registry and are pinned by digest. npm and Python dependencies are baked into images at build time, and Cube image signatures are verified.
Architecture
┌──────────── cubebi-web (React UI) ─────────────┐
users ──► cubebi-proxy ─┤ Explore · Workbooks · Dashboards · Chat · Admin │
(TLS) └──────────────────────┬─────────────────────────┘
▼
cubebi-keycloak ◄──── OIDC ────────── cubebi-platform (control plane, BFF)
sessions, users/groups/attributes,
reports, dashboards, folders, ACLs,
audit log, mints per-user Cube JWTs
┌──────────────────┬──────────────────┼────────────────────┬──────────────────┐
▼ ▼ ▼ ▼ ▼
cubebi-cube cubebi-agent cubebi-worker cubebi-renderer cubebi-gitea
cubebi-cube-refresh Claude API job queue: deliveries, headless Chromium model repo +
cubebi-cubestore (only egress) + alerts, agent tasks, PNG / PDF branches
Cube tools pre-agg jobs → SMTP
│
cubebi-db (Postgres: warehouse sample, platform, keycloak, query log)| Service | Replaces this Cloud feature | Notes |
|---|---|---|
cubebi-cube + cubebi-cube-refresh + cubebi-cubestore | Managed semantic layer | API and refresh worker are separate containers. Hooks: checkAuth, checkSqlAuth, contextToGroups, queryRewrite, logger. |
cubebi-platform | Users, roles, content, sharing, audit, settings | Backend-for-frontend. The browser never holds a Cube token. Reports are the central object (dashboard tiles, deliveries and alerts reference them). Folder permissions are view/edit/full; the closest folder wins, capped by role. |
cubebi-keycloak | SSO, SCIM | Realm cubebi; groups and attributes come through token mappers. |
cubebi-web | Cloud UI | Dashboards use Cloud's published file format (grid of widgets, controls, cross-filters). |
cubebi-agent | Analytics Chat, Dashboard Agent, rules, certified queries, skills, evals, MCP | See AI design. |
cubebi-worker | Deliveries, alerts, scheduled tasks, warm-up | Postgres-backed queue. Uses Cube's Orchestration API. Alert rules follow Cloud's documented semantics. |
cubebi-renderer | PNG/PDF downloads and exports | Headless Chromium on the web app's print routes. |
cubebi-gitea | Data model IDE, dev branches | repositoryFactory + schemaVersion, one compiled model per branch. |
Identity and data security
- Users sign in through Keycloak (OIDC authorization code + PKCE).
cubebi-platformkeeps the session in an HTTP-only cookie. - For every Cube call, the platform mints a short-lived JWT:
{ sub, cubeCloud: { groups: [...], userAttributes: {...} } }. - Cube's
contextToGroupsreads the groups, and access policies in the model enforce row- and member-level security for every user, including the AI agent, deliveries and alerts, which run as the owner. - Content permissions (who can open a dashboard) are separate from data permissions (what rows they see). Sharing content never widens data access.
AI design
- Agent loop: hosted in
cubebi-agentwith the Anthropic TypeScript SDK, using the Messages API tool runner.- Why not Managed Agents: it would host the loop, a sandbox and the session history at Anthropic. Keeping the loop local means only model requests cross the boundary.
- Model:
claude-opus-5-5.- Adaptive thinking, streaming, and explicit
effortper route:mediumfor chat, higher for analysis. - Server-side refusal fallbacks are enabled.
- Whether to use a cheaper model for small tasks (titles, suggested questions, date parsing) is a cost decision for later, made with measurements.
- Adaptive thinking, streaming, and explicit
- Tools (strict schemas). Every tool runs with the end user's Cube JWT:
list_views: from/v1/meta, including descriptions andmeta.ai_context.query: Semantic SQL via/v1/cubesql, or a Cube JSON query. Results are capped (row limit, aggregated by default).to_chart:/v1/convert-query, turning agent SQL into an editable chart.save_report, and later folder, schedule and dashboard-state tools.
- Grounding:
agents/folder in the repo, same layout as Cube Cloud:config.yml,rules/,certified_queries/,skills/.- Rule conditions use the same groups and attributes as access policies. Conditions only select which prompts are sent; they are not security.
- Cost and latency:
- The tool list, system prompt and model catalog form a stable, cached prefix (prompt caching).
- Long chats use compaction.
- Protocol: streaming NDJSON in the shape of Cube's Chat API, so a client written for one can be pointed at the other.
- Quality: an eval set (exact-match grader plus a Claude judge, following Cube's documented method) runs in CI before any prompt or model change ships.
- Data leaving the host: the user's question, the model catalog (names and descriptions) and the query results the agent reads. Never credentials, never more rows than the cap. Every LLM call is written to the audit log with user, tokens and cost. A single switch (
AI_ENABLED=false) turns all of it off.
Phases
| Phase | Scope | Done when |
|---|---|---|
| 0 Foundations | Separate refresh worker; telemetry off everywhere; SQL API (18454) with checkSqlAuth; contextToGroups; proxy the unused Core endpoints (cubesql, convert-query, sql-filters, running-query); query log from Cube events | Stack runs with no outbound traffic; SQL API works with a per-user check; every query lands in query_log |
| 1 Platform + Keycloak | Login, users/groups/attributes, per-user JWTs, reports, folders, permissions, audit | A user in group X sees only X's rows in every surface |
| 2 Dashboards v2 | Cloud dashboard format, grid builder, controls + URL state, cross-filtering, drill-through, versions | A dashboard round-trips as a file in Git |
| 3 Agent | Chat with the tools above, agents/ config, evals; then the Dashboard Agent | Eval pass rate meets the agreed bar; works with AI off |
| 4 Worker + renderer | Deliveries, alerts, PNG/PDF export, scheduled agent tasks | An alert fires exactly once when its condition starts to hold |
| 5 Ops + modeling | Query history UI, pre-aggregation console, Gitea branches, data-lake integrations | — |
| 6 Packaging | Offline release bundle, upgrade runbook, backup/restore | Fresh install from the bundle on a host with no internet |