-
Notifications
You must be signed in to change notification settings - Fork 2
Architecture
Back to Home. Related: Source-Map, Decisions-and-Roadmap.
main.js (bootstrap + concrete adapters)
├─ ui/ (renderers and controller)
├─ editor/ (injected SQL + Spec CodeMirror adapters)
├─ net/ (OAuth and ClickHouse HTTP)
├─ state.js (signals-backed model and operations)
└─ core/ (pure parsing, transforms, layout, formatting)
ui/ → net/state/core net/ → core core/ → nothing
src/main.js is the composition root. createApp(env) receives browser and
service dependencies. Render modules receive the returned app controller and
must not import app.js, which prevents cycles.
- Network functions receive
fetchor a ClickHouse context. - PKCE, storage, time, location, and browser globals are parameters.
- CodeMirror is behind explicit injected
app.sqlEditorandapp.specEditorseams; only the composition root chooses the adapters. SQL actions always address the SQL adapter rather than the currently visible document. - Chart.js and Dagre are concrete adapters injected as
app.Chart/app.Dagre. - Signals coordinate state. Imperative/high-frequency surfaces remain adapters.
This pattern keeps tests genuine: plain stubs replace dependencies without broad module mocking.
- The editor/controller prepares SQL and typed parameters.
-
src/net/ch-client.jssends the HTTP request with injected auth/fetch context. -
JSONStringsEachRowWithProgressis folded line by line by pure stream logic. - Results resolve through the panel registry to table, chart, logs, KPI, filter, text, or graph-oriented renderers.
- One auth refresh is attempted for expired/denied tokens.
build/build.mjs bundles src/main.js with esbuild, minifies it, and inlines JS
and src/styles.css into build/template.html. Output is dist/sql.html, with
no third-party runtime requests.
Canonical source: docs/ARCHITECTURE.md and
CLAUDE.md.
Rules source of truth: CLAUDE.md. Deep-detail archive: Claude native memory (indexed in Operations-Memory). Re-verify anything with a date, version, or cluster ID before acting. Distilled 2026-07-12.
Orientation
Working here
Operations
Meta