Skip to content
[Case study · Built by Asrar]

Building an analyst that shows its work.

Playfair is a portfolio product by Asrar: connect a database, a spreadsheet or CSV files, ask in plain language, and get the chart, the number and the exact SQL. This is how we built it, and why it looks the way it does.

The problem.

Founders and operators sit on production databases with no analyst. Text-to-SQL demos look magical until the first wrong number, and after that nobody trusts any of them. The job was not to make SQL disappear. It was to make it readable, checkable and safe, for people who do not write it and people who do.

target from sign-up to a first correct answer
3 min
to answer “Monthly revenue this year” on the sample store
31 ms
independent read-only locks on every query
4
writes a Playfair query can make
0

Four principles, decided first.

  1. 01

    Show the work

    Every number links to its SQL and its rows. The interpretation is visible before anything runs.

  2. 02

    Ask before guessing

    When two columns could mean “revenue”, Playfair asks. Otherwise it guesses and says what it assumed.

  3. 03

    The right chart by default

    Form follows the question and the shape of the result. Zero-based bars, one axis, direct labels.

  4. 04

    Never break silently

    Stale, drifted and failed states are explicit and repairable, from a single tile to a whole source.

From a question to an answer.

Eight steps, two of them non-negotiable: validation and a read-only execution. The model can be clever; the pipeline around it is not allowed to be.

  1. 01 · context

    Relevant tables, metrics, joins, rules and the thread so far.

  2. 02

    Interpret

    Measure, grain, filters, assumptions.

    Revenue · month · 2026

  3. 03

    Generate SQL

    Dialect-aware, uses governed metrics.

    SELECT date_trunc(…)

  4. 04

    Validate

    One SELECT, known tables, allowed columns.

    1 statement · ok

  5. 05

    Execute

    Read-only transaction, timeout, row cap.

    31 ms · 9 rows

  6. 06

    Chart

    Form from question and result shape.

    line · by month

  7. 07

    Narrate

    Headline, caveats, confidence.

    €3.66M · high

  8. 08 · learn

    Accepted corrections become semantic rules for the next question.

The trace follows “Monthly revenue this year” on the sample store.

Decisions that shaped it.

Trust is a design problem

Confidence badges with their reasons, caveats such as “September is still in progress”, and an interpretation preview that runs after a pause unless you step in. The product earns belief by being specific about doubt.

A planner first, a model second

A deterministic semantic planner turns most questions into SQL from the schema, the metrics and their synonyms. A language model helps only where a question is ambiguous or weakly matched — and its output passes the same validator. Playfair works without any AI key.

Charts with opinions

The chart engine chooses from the question and the result shape, then enforces the rules on every spec: thousand separators, workspace currency, pie only for four parts or fewer, one categorical palette validated in both themes.

Paper and ink

Warm white paper, near-black ink, colour kept for meaning and for data. One saturated moment — the pixel sky — and a pixel identity that nods to Playfair’s engraved plates.

The stack.

One Next.js app is both the backend and the frontend: route handlers for data, server components for pages, and the same typed contracts on both sides.

[App]
Next.js 16 App RouterReact 19TypeScriptTailwind CSS v4shadcn/ui
[Data]
PostgreSQLPrisma 7node-sql-parserpg · mysql2
[Client]
TanStack QueryTanStack TableRecharts + d3-scaleZustandnuqs
[Platform]
Better AuthResendMinIOServer-sent eventsZod
[Quality]
VitestPlaywrightBoth themesWCAG 2.2 AA
ASRAR

Need a data product your team will actually trust?

Asrar designs and builds products like Playfair, from the query engine to the last empty state. Tell us what your people keep asking for.