Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributor guide — altinity-sql-browser

A modular ES-module SPA that builds to one self-contained HTML file served from
ClickHouse. No framework; runtime deps are rare and deliberate (currently five,
ClickHouse. No framework; runtime deps are rare and deliberate (currently seven,
all bundled — see hard rule 4). Quality is held by tests.

## Hard rules
Expand Down Expand Up @@ -38,10 +38,11 @@ all bundled — see hard rule 4). Quality is held by tests.
fail clearly. `package-lock.json` is committed; use `npm ci` for a
reproducible dependency graph in local, CI, and release builds, and update
the lock only with an intentional dependency change.
There are **six** bundled runtime dependencies — **CodeMirror 6** (the SQL
There are **seven** bundled runtime dependencies — **CodeMirror 6** (the SQL
editor, saved-query Spec JSON editor, and read-only source viewer, behind
injected seams — #21/#212/#213),
**Chart.js** (the Chart result view) with **chartjs-adapter-date-fns**
**Chart.js** (the Chart result view) with **chartjs-adapter-date-fns** and
**date-fns**
(registers the date-math backend Chart.js's `time` scale needs for
line/area charts over a time-role X column — #309; the pure axis/role
decision of *whether* to use it stays in `core/chart-data.ts`, the adapter
Expand All @@ -55,7 +56,7 @@ all bundled — see hard rule 4). Quality is held by tests.
token tree is projected into DOM by `ui/doc-markdown-view.ts` under the
fail-closed policy: images/raw HTML/rejected links render as literal
text; measured +44 KB raw / ~3% artifact delta) — all inlined into the
artifact, so the page still makes zero third-party requests.
artifact, so the page loads no runtime libraries from third-party CDNs.
Adding *another* runtime dependency is a deliberate decision (it grows the
single served file) — don't do it casually. When a feature needs a library,
keep the testable logic pure in `src/core/` (chart axis/role/pivot math in
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ tabbed SQL editor with syntax highlighting, find/replace, bracket matching, and
schema-aware autocomplete, streaming results with table / JSON / chart views,
saved queries, history, and shareable links. It ships as a
**single self-contained HTML file served from ClickHouse itself** (no Node
server, no CDN, no external fonts) — the page makes **zero third-party
requests** and renders in the OS's native UI font. Its five bundled runtime
server, no CDN, no external fonts) — every runtime dependency is bundled, and
the page renders in the OS's native UI font. Its seven bundled runtime
dependencies — **CodeMirror 6** (the SQL editor, saved-query Spec JSON editor,
and read-only source viewer),
**Chart.js** + **chartjs-adapter-date-fns** (the chart result view, including
a real time scale for time-series line/area charts), **@dagrejs/dagre** (the
**Chart.js** + **chartjs-adapter-date-fns** + **date-fns** (the chart result
view, including a real time scale for time-series line/area charts),
**@dagrejs/dagre** (the
EXPLAIN pipeline-graph layout), and
**@preact/signals-core** (state reactivity) — are inlined into that one file.
**@preact/signals-core** (state reactivity), and **marked** (Markdown
tokenization for reference documentation) — are inlined into that one file.

Refactored from a single-file SPA into a fully modular, test-first codebase
held at **100% test coverage**.
Expand Down Expand Up @@ -59,7 +61,7 @@ only moving parts are ClickHouse's HTTP handlers and your OAuth provider.

The workbench uses **CodeMirror 6** behind separately injected SQL and Spec
editor seams (#143/#21/#212) — bundled and inlined like the other runtime deps,
so the page still makes zero third-party requests. A saved-query tab exposes a
so no editor library is loaded from a third-party CDN. A saved-query tab exposes a
visible **SQL | Spec** switch: SQL edits the executable text, while Spec edits
only the complete `query.spec` JSON. Linked Save validates and atomically
commits both drafts; an unsaved tab remains SQL-only until its first Save.
Expand Down
96 changes: 96 additions & 0 deletions THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,46 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

---

## chartjs-adapter-date-fns — v3.0.0

The MIT License (MIT)

Copyright (c) 2019 Chart.js Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---

## date-fns — v4.4.0

MIT License

Copyright (c) 2021 Sasha Koss and Lesha Koss https://kossnocorp.mit-license.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---

## @dagrejs/dagre — v3.0.0

The MIT License (MIT)
Expand Down Expand Up @@ -51,6 +91,62 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

---

## marked — v18.0.7

### Marked

Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/)
Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

### Markdown

Copyright © 2004, John Gruber
http://daringfireball.net/
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name “Markdown” nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.

This software is provided by the copyright holders and contributors “as is”
and any express or implied warranties, including, but not limited to, the
implied warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall the copyright owner or contributors be liable
for any direct, indirect, incidental, special, exemplary, or consequential
damages (including, but not limited to, procurement of substitute goods or
services; loss of use, data, or profits; or business interruption) however
caused and on any theory of liability, whether in contract, strict liability,
or tort (including negligence or otherwise) arising in any way out of the use
of this software, even if advised of the possibility of such damage.

---

## Ajv — v8.20.0 (build-time schema compiler; generated helpers only)

MIT License
Expand Down
14 changes: 7 additions & 7 deletions docs/ADR-0001-reactivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ a dependent → stale UI. This is an *absence-of-reactivity* problem, distinct f
a *component-model* problem.

Three hard constraints frame any solution: a single self-contained HTML artifact
with zero third-party requests (CLAUDE.md rule 4 — deliberate deps only), the
with no third-party asset loads (CLAUDE.md rule 4 — deliberate deps only), the
per-file 100/100/100/100 coverage gate (rule 1), and the injected-seam layering
(rule 2).

Expand All @@ -40,8 +40,8 @@ memoized `computed()` — none of which the naive synchronous prototype provides
It costs one small, zero-transitive-dependency package and **+1.4 KB gzip** to
the artifact (vs +0.45 KB hand-rolled), in exchange for not owning ~70 lines +
~180 test lines of correctness-critical reactive code. Per CLAUDE.md rule 4 this
is a deliberate dependency; it is still inlined, so the artifact makes zero
third-party requests.
is a deliberate dependency; it is still inlined, so the artifact makes no
third-party asset request for it.

## Options considered (all measured)

Expand Down Expand Up @@ -122,8 +122,8 @@ re-opening this ADR's "no framework" line for *complex panels only*.

**What it cost (measured / observed):**
- **Bundle: +6.8 KB gzip** (148,044 → 154,873 B; raw 457,892 → 474,440) — close
to this ADR's +5.9 KB estimate. ~+4.6% of the artifact, still zero third-party
requests (inlined).
to this ADR's +5.9 KB estimate. ~+4.6% of the artifact, still with no
third-party asset loads (inlined).
- **A second paradigm.** signals-core `effect()`s drive the rest of `createApp`
(tabs/results/title); the schema tree is Preact. Two render models coexist —
the main ongoing cost.
Expand Down Expand Up @@ -321,8 +321,8 @@ Three further observations:
rewrite of ~9 k LOC of `src/ui/` and its 100%-covered tests.
- Grafana/Superset use React for reasons this project does not have — a
third-party plugin ecosystem and a very large contributor surface. This
project's differentiator is the opposite: one self-contained file, zero
third-party requests.
project's differentiator is the opposite: one self-contained file with no
third-party asset loads.
- ADR-0002 (incremental strict TypeScript) further reduces the framework pull:
a typed `h()` hyperscript and a typed `app` controller surface recover much
of the edit-time DX people reach for a framework to get.
Expand Down
7 changes: 4 additions & 3 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ failure signs out; after, it is a query error).
## Build

`build/build.mjs` runs esbuild (bundle + minify, IIFE), inlines the script and
`styles.css` into `build/template.html` → a single `dist/sql.html`. Five
bundled runtime dependencies (CodeMirror 6, Chart.js + chartjs-adapter-date-fns,
dagre, `@preact/signals-core`); the served page makes zero third-party requests.
`styles.css` into `build/template.html` → a single `dist/sql.html`. Seven
bundled runtime dependencies (CodeMirror 6, Chart.js +
chartjs-adapter-date-fns + date-fns, dagre, `@preact/signals-core`, marked);
none is loaded from a third-party CDN.
2 changes: 1 addition & 1 deletion docs/assets/site.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Altinity SQL Browser — public site styles.
Hand-built, zero third-party requests. Tokens lifted from src/styles.css. */
Hand-built, with no third-party asset loads. Tokens lifted from src/styles.css. */

:root {
--accent: #0079AD;
Expand Down
2 changes: 1 addition & 1 deletion docs/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h1>Engineering notes</h1>
<a class="card post-card" href="no-backend-sql-console.html">
<div class="kicker">Architecture</div>
<h3>The SQL console with no backend</h3>
<p>One HTML file ClickHouse® serves itself, OAuth in the browser, per-user grants, zero third-party requests, and a CSP that enforces it.</p>
<p>One HTML file ClickHouse® serves itself, OAuth in the browser, per-user grants, bundled dependencies, and a strict CSP.</p>
<div class="post-meta"><span>June 2026</span><span class="dot">·</span><span>4 min read</span></div>
</a>
<a class="card post-card" href="materialized-view-web.html">
Expand Down
8 changes: 4 additions & 4 deletions docs/blog/no-backend-sql-console.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The SQL console with no backend — Altinity® SQL Browser</title>
<meta name="description" content="Most database UIs are a service you deploy and babysit. This one is a single HTML file ClickHouse serves itself — OAuth in the browser, per-user grants, zero third-party requests, a strict CSP.">
<meta name="description" content="Most database UIs are a service you deploy and babysit. This one is a single HTML file ClickHouse serves itself — OAuth in the browser, per-user grants, bundled dependencies, and a strict CSP.">
<link rel="icon" href="../assets/favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="../assets/site.css">
</head>
Expand Down Expand Up @@ -63,11 +63,11 @@ <h2>How that works</h2>
<figcaption>Sign in with your IdP (or a saved connection). The “Target” line shows exactly where queries will go.</figcaption>
</figure>

<h2>Zero third-party requests</h2>
<h2>No third-party asset loads</h2>
<p>Open the network tab while you use it. You'll see calls to ClickHouse and to your IdP — and
nothing else. No CDN, no analytics, no web fonts; it renders in your OS font. Everything the app
needs is inlined into that one file at build time, including the two libraries it leans on (Chart.js
for the chart view, dagre for the graph layout). I'd rather ship one ~440&nbsp;KB file I can diff than a
needs is inlined into that one file at build time, including CodeMirror, Chart.js and its date
adapter, dagre, signals-core, and marked. I'd rather ship one file I can diff than a
tree of packages I can't.</p>

<p>That's a security property too, and it's enforced rather than hoped for. The handler ships a strict
Expand Down
14 changes: 7 additions & 7 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Altinity® SQL Browser — an OAuth-gated SQL console for ClickHouse®</title>
<meta name="description" content="A self-contained, OAuth-gated SQL browser for any ClickHouse cluster. Charts, EXPLAIN graphs, data-flow graphs, autocomplete — one HTML file, zero third-party requests. Run it locally with one curl command.">
<meta name="description" content="A self-contained, OAuth-gated SQL browser for any ClickHouse cluster. Charts, EXPLAIN graphs, data-flow graphs, autocomplete — one HTML file with runtime dependencies bundled. Run it locally with one curl command.">
<link rel="icon" href="assets/favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="assets/site.css">
<meta property="og:title" content="Altinity SQL Browser">
<meta property="og:description" content="A self-contained, OAuth-gated SQL console for any ClickHouse cluster — charts, EXPLAIN graphs, data-flow graphs. One HTML file, zero third-party requests. Install locally with one curl command.">
<meta property="og:description" content="A self-contained, OAuth-gated SQL console for any ClickHouse cluster — charts, EXPLAIN graphs, data-flow graphs. One HTML file with runtime dependencies bundled. Install locally with one curl command.">
<meta property="og:type" content="website">
</head>
<body>
Expand All @@ -31,7 +31,7 @@

<section class="hero center">
<div class="wrap">
<span class="pill">One HTML file · Zero third-party requests</span>
<span class="pill">One HTML file · Dependencies bundled</span>
<h1>A SQL console for ClickHouse®<br>that you can host anywhere</h1>
<p class="lede">An OAuth-gated query browser with charts, EXPLAIN pipeline graphs, data-flow graphs and
smart autocomplete — built as a single self-contained HTML file. Serve it from ClickHouse itself,
Expand Down Expand Up @@ -65,8 +65,8 @@ <h1>A SQL console for ClickHouse®<br>that you can host anywhere</h1>
<div class="section-head">
<div class="eyebrow">Why it's different</div>
<h2>A full query workbench with no backend to run</h2>
<p>The browser talks straight to ClickHouse over HTTP. There is no app server, no database of its own,
and no third-party requests — just one HTML file and your OAuth provider.</p>
<p>The browser talks straight to ClickHouse over HTTP. There is no app server or database of its own;
runtime libraries are bundled into the one HTML file.</p>
</div>
<div class="grid cols-3">
<div class="card">
Expand All @@ -79,7 +79,7 @@ <h3>OAuth-gated, no static secret</h3>
<div class="ic" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/></svg></div>
<h3>One self-contained file</h3>
<p>esbuild bundles everything — including Chart.js and the graph layout engine — into a single
<code class="k">sql.html</code>. No CDN, no fonts, no external calls. Serve it from ClickHouse's
<code class="k">sql.html</code>. No CDN or external font/library loads. Serve it from ClickHouse's
<code class="k">user_files</code> and you're done.</p>
</div>
<div class="card">
Expand Down Expand Up @@ -175,7 +175,7 @@ <h2>Engineering notes</h2>
<a class="card post-card" href="blog/no-backend-sql-console.html">
<div class="kicker">Architecture</div>
<h3>The SQL console with no backend</h3>
<p>One HTML file ClickHouse serves itself — OAuth in the browser, per-user grants, zero third-party requests.</p>
<p>One HTML file ClickHouse serves itself — OAuth in the browser, per-user grants, dependencies bundled.</p>
</a>
<a class="card post-card" href="blog/materialized-view-web.html">
<div class="kicker">Schema</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "altinity-sql-browser",
"private": true,
"version": "0.6.2",
"description": "A self-contained, OAuth-gated SQL browser for any ClickHouse cluster. Vanilla ES modules, served from ClickHouse itself as one HTML file with zero third-party requests.",
"description": "A self-contained, OAuth-gated SQL browser for any ClickHouse cluster. Vanilla ES modules, served from ClickHouse itself as one HTML file with all runtime dependencies bundled.",
"type": "module",
"license": "Apache-2.0",
"engines": {
Expand Down
Loading