Insightics sits between your users and your Postgres. A question goes in as plain language. What comes back is a chart, built from SQL that was checked before it ever reached your database.
Ten steps, in order. The first three are pure functions you can test without a database. The model is the only part that guesses, and the guard right after it is the trust boundary.
- 01PureRetrievalPicks up to 12 relevant tables out of hundreds, deterministically, so the model only sees what the question needs.
- 02PureGlossaryMaps the words your team uses, like “MRR” or “active”, onto the columns that hold them, like mrr_cents.
- 03PurePromptRenders just those tables to the model as Postgres DDL. Nothing else about your database is sent.
- 04UntrustedModelAnthropic or OpenAI writes a query and picks a chart. Its output is treated as untrusted input, every time.
- 05Trust boundaryGuardPostgres’s own parser reads the query, an allowlist checks it, and the SQL that runs is re-emitted from the checked tree.
- 06BoundedRepairIf the guard denies a query for an honest mistake, the model gets exactly one retry. Never a loop.
- 07DatabaseScopeIn multi-tenant mode a verified token becomes SET LOCAL app.tenant_id, and row-level security takes it from there.
- 08DatabaseExecuteThe query runs inside BEGIN READ ONLY as a SELECT-only role, and the transaction is always rolled back.
- 09NarrowedWireWhat reaches the browser is narrowed: rows and a chart spec, never deny codes, prompts or token counts.
- 10SVGChartBar, line or single-number charts in hand-rolled SVG. Turn on live and it stays current over server-sent events.
One install with an import path per part, and deliberately no root import, so browser code cannot pull in server code by accident.
Add The SDK
npm install insightics-sdk pg @anthropic-ai/sdkCreate The Read-Only Role
The CLI writes the ik_reader role, then proves the guarantees from the live catalog. It exits non-zero when the proof fails, so it belongs in CI.
npx ik init
npx ik doctorDrop In One Component
"use client";
import { Insight } from "insightics-sdk/react";
<Insight
endpoint="/api/insightics"
question="how many users signed up this week, by signup method"
live
/>Mount One Handler
A reader source, a guard, a model provider, a schema and an explicit tenancy choice. That is the whole server.
import { asReaderSource, introspectSchema } from "insightics-sdk/core";
import { fromPgPool } from "insightics-sdk/core/pg";
import { anthropicProvider } from "insightics-sdk/llm/anthropic";
import { createInsightics, SINGLE_TENANT_ACKNOWLEDGEMENT, singleTenant, toNextRoute } from "insightics-sdk/server";
import { createGuard } from "insightics-sdk/sql-guard";
import { Pool } from "pg";
const source = asReaderSource(fromPgPool(new Pool({ connectionString: process.env.DATABASE_URL })));
const ik = createInsightics({
source,
guard: await createGuard({ maxRows: 1000 }),
provider: anthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY!, model: "claude-opus-5" }),
schema: () => introspectSchema(source, { excludeSchemas: ["insightics"] }),
tenancy: singleTenant(SINGLE_TENANT_ACKNOWLEDGEMENT),
live: {},
});
export const { GET, POST } = toNextRoute(ik.handler);Tenancy, said out loud
There is no default. Single-tenant mode asks for the exact sentence “every user of this app may read every row” instead of a boolean, because that is what it means. Multi-tenant mode verifies a JWT and hands the tenant to Postgres row-level security.
Live, at both ends
Live charts need live switched on in the server config and on the component. Leave either off and the answer renders once, quietly. In multi-tenant mode the stream also needs tokenFrom, since a browser EventSource cannot send headers.
Your model, your keys
Bring an Anthropic or OpenAI key. The model provider is a small structural interface, so the engine itself never depends on a model SDK.
Your framework
One handler, mounted wherever you like. Adapters ship for Next.js route handlers, plain Node and Express, Fastify and Hono.
Inside the repository each part is its own package, and the boundaries between them are enforced in CI. The build packs them into one install.
- insightics-sdk/serverHTTP and SSE handler for Next, Express, Fastify and Hono
- insightics-sdk/react<Insight />, hooks and hand-rolled SVG charts
- insightics-sdk/coreReader path, introspection, planner, glossary, store
- insightics-sdk/core/pgThe node-postgres adapter
- insightics-sdk/sql-guardThe security kernel. Pure, zero I/O
- insightics-sdk/protocolThe browser to server contract
- insightics-sdk/llm/anthropicAnthropic model provider
- insightics-sdk/llm/openaiOpenAI model provider
Come Build It
With Us
Ask questions, show what you are building, and help decide what Insightics does next. The Discord is where the roadmap gets argued out.