# Open-source BI engine for building trusted analytics with AI agents

> Build trusted analytics with your coding agent on an open-source semantic layer, query engine, JS SDK and MCP server, on your own warehouse. Apache 2.0.

Open source · Apache 2.0. anfra lets data and product teams build and customize their own data apps with coding agents, on shared metrics defined once in a semantic layer.

[Quickstart](https://anfra.ai/#get-started) · [Watch the teaser (1:27)](https://media.holistics.io/anfra/marketing/anfra-teaser-16x9-captions.mp4) · [Live demos](https://demo.anfra.ai/) · [Docs](https://docs.anfra.ai/)

## Install

**Ask your agent**: paste this into Claude Code, Cursor, Codex or any coding agent.

```text
Install anfra following https://anfra.ai/docs/local-dev/installation, connect my data warehouse and build me a first app.
```

**CLI**: then run `anfra agent setup` and `anfra init my-project`.

```sh
curl -fsSL https://anfra.ai/install.sh | bash
```

Installing anfra means installing both the CLI and the agent skills. `anfra agent setup` installs the skills in Claude Code and Codex only. In any other agent, such as Amp, run `npx skills add holistics/anfra-skills -a <agent-id> -g -y` (`-a amp` for Amp) instead. See [Installation](https://anfra.ai/docs/local-dev/installation.md).

## What teams say

> “anfra is basically dbt for BI apps. The semantic layer is text in git, a coding agent writes the dashboard, the CLI checks it.”
>
> Mark Pham, Analytics Engineer

> “After about 30 minutes of setup, we had key dashboards and apps with built‑in interactions, out of the box, to track our usage.”
>
> Thi Nguyen, Product Manager, dbdiagram.io

> “AI dashboards always felt like artifacts. anfra feels like production: the semantic layer, the SDK and the visuals all working in unison. Really awesome!”
>
> Nick Hernandez, Co-founder & Analytics Consultant, sauzi.ai

## Design your own data apps

Any layout, any interaction, one prompt. Every number still comes from your governed metrics.

- **Cashflow sheet**: A statement you switch between quarters and years, and break down by entity. Prompt: “Build a cash flow statement I can switch between quarters and years, add metrics to, and break down by entity.” [Open the live app](https://demo.anfra.ai/apps/business-apps/cash-flow)
- **Funnel builder**: Add, remove and reorder steps, and see who converted or dropped off. Prompt: “Build a funnel tool where I can add, remove and reorder steps and see who converted or dropped off.” [Open the live app](https://demo.anfra.ai/apps/dashboards/funnel-analysis)
- **Metrics explorer**: Pick any metric, filter from a leaderboard and compare to the last period. Prompt: “Build me a metric explorer where I can pick any measure, filter by a leaderboard row and compare to the previous period.” [Open the live app](https://demo.anfra.ai)
- **Exploratory canvas**: Place charts anywhere, and click a mark to drill into a linked chart. Prompt: “Give me an exploratory canvas where I can place charts anywhere and click a mark to drill into a linked chart.” [Open the live app](https://demo.anfra.ai/apps/build-your-own-bi/flex)

[View all demos](https://demo.anfra.ai/)

## Built by AI. Checkable by anyone

Your agent writes the app, but it doesn’t make up the numbers. Each one comes from a metric your team defined, and anyone using the app can check it.

- What a number means, who owns it and how it’s worked out
- Its lineage, back to the metrics, fields and tables underneath
- The rows and queries behind it, and a trust level for the whole app

## Your metrics, in the AI chat you already use

Claude, ChatGPT or any MCP client answers from your governed metrics.

- Nothing new to learn
- No extra AI bill
- Trace any metric to its definition and lineage

Opening a number's trace straight from a chat answer is coming soon.

## Extend your BI with plugins (Plugins · Coming soon)

Turn on features across every app, or build your own with your agent.

## One prompt, from warehouse to governed dashboard

Ask for a dashboard. Your agent turns your warehouse into models and metrics, then builds on top of them.

01. **Install anfra**: Install the CLI and the agent skills.

```sh
curl -fsSL https://anfra.ai/install.sh | bash
anfra agent setup
```

02. **Connect your warehouse**: Add your credentials to `.anfra/data_sources.yml`.

```sh
anfra init my-project
```

03. **Your agent builds the semantic layer**: It models your tables and defines the metrics, as files you can review.

```text
cd my-project && claude
Use the anfra-build-data-app skill. Build a revenue overview with a region filter.
```

04. **Your agent builds the dashboard**: Every chart uses those metrics.

```text
apps/revenue-overview.html
```

05. **Run it, then publish**: `anfra serve` runs it locally. `anfra publish` shares it with your team on anfra Cloud.

```sh
anfra serve
anfra publish
```

## The backend your agent builds data apps on

Everything a data app needs under it, open source, on your own warehouse.

- **AMQL semantic layer**: Models, datasets and metrics as code, reviewed in git. Metrics build on other metrics, with period comparisons, percent of total and level of detail. (Available now)
- **Query engine**: Compiles each request to SQL, runs it live on your warehouse and keeps the SQL that ran (Available now)
- **JS SDK**: Your app asks for metrics by name, with filters and drill-downs and no SQL in the page (Available now)
- **MCP server**: Coding and data agents read your models and query your metrics (Available now)
- **Search and lineage**: A catalog agents search, and each field traced back to what it’s built from (Available now)
- **Agent skills**: Teach your coding agent to model data, write queries and build data apps (Available now)
- **Plugins**: Extend anfra with your own plugins, without waiting for us (Roadmap)
- **Evals**: Measure how well agents work on your data (Roadmap)

## Built on an open, programmable semantic layer

AMQL, the semantic layer behind Holistics. Define metrics once as code, and every question compiles to SQL on your warehouse.

- **Programmable, not configured**: Metrics build on other metrics, and one AQL expression handles period comparisons, percent of total, running totals and level of detail
- **Open as in yours**: AML and AQL are plain-text files in your git, and every query compiles to SQL you can read
- **One model, every caller**: Apps through the JS SDK and agents over MCP ask for metrics by name and get the same numbers

In AMQL: defined once, works at any grain and filter (`ecommerce.dataset.aml`):

```aml
metric revenue {
  definition: @aql
    sum(order_items.amount) ;;
}

metric revenue_last_year {
  definition: @aql
    revenue | relative_period(
      orders.created_at, interval(-1 year)
    ) ;;
}

metric revenue_growth {
  definition: @aql
    safe_divide(
      revenue - revenue_last_year,
      revenue_last_year
    ) ;;
}
```

In SQL: the same, by month only (`revenue_by_month.sql`):

```sql
WITH monthly AS (
  SELECT date_trunc('month', o.created_at) AS month,
         SUM(oi.amount) AS revenue
  FROM orders o
  JOIN order_items oi ON oi.order_id = o.id
  GROUP BY 1
)
SELECT curr.month,
       curr.revenue,
       prev.revenue AS revenue_last_year,
       (curr.revenue - prev.revenue)
         / NULLIF(prev.revenue, 0) AS revenue_growth
FROM monthly curr
LEFT JOIN monthly prev
  ON prev.month = curr.month - INTERVAL '1 year'
ORDER BY curr.month
```

[Compare AMQL with other semantic layers](https://amql.org/compare) · [Try it in the playground](https://play.amql.org/)

## Wire charts to metrics, not SQL

The JS SDK puts your semantic layer in the page. Query metrics as JS objects, bind them to any chart, and wire up filters and click-to-filter in a few lines.

- **No SQL in the page**: The page asks for revenue by name
- **Filters travel as data**: The page sends a filter beside the query, as data, and anfra builds the SQL from it
- **Sandboxed**: Each app runs in a sandboxed frame and reaches data only through its host
- **Your server decides**: Log, change or refuse any call the page makes

The same page runs in anfra serve or inside your own product. [Read the SDK guide](https://docs.anfra.ai/docs/sdk) · [See the host example](https://github.com/holistics/anfra-host-example)

## BI as code, in your own repo

Every connection, model, metric and app is a plain file in git.

- Reviewed in pull requests
- Full history, easy rollback
- Your agent checks its work before it ships

An anfra project: plain files in git:

```text
analytics/
  .anfra/
    data_sources.yml
  models/
    orders.model.aml
    users.model.aml
  datasets/
    sales.dataset.aml
  apps/
    revenue-overview.html
  AGENTS.md
```

## What you can build with anfra

Your coding agent builds the apps, as many as your team needs, in your own code and on your own warehouse

- **Your own BI tool**: The dashboards and apps your team asks for. The layout and the charts are yours, and the metrics are your data team’s. [See live demos](https://demo.anfra.ai/)
- **A backend for your AI data agent**: The agent searches your datasets and queries metrics by name, so its answers come from your definitions, not SQL it guessed. [Agent skills on GitHub](https://github.com/holistics/anfra-skills)
- **Embedded analytics**: Apps inside your own product through the JS SDK, under your own login and look. [Host example on GitHub](https://github.com/holistics/anfra-host-example)

## Run it your way

Start on your laptop, then run the same project on your own server, or publish it to anfra Cloud

### On your machine

```sh
anfra serve
```

Runs your apps while you and your agent build them, and reloads on every change. It’s for you: there are no logins. [Quickstart](https://anfra.ai/#get-started)

### On your own server

```sh
docker run -p 7878:7878 -v "$PWD:/repo" ghcr.io/holistics/anfra
```

The same engine in a Docker image, on your infrastructure. It has no logins or permissions of its own, so put it where everyone who can reach it may see the data. [Run it with Docker](https://github.com/holistics/anfra/blob/main/docs/usage/docker.md)

### On anfra Cloud (Public beta)

```sh
anfra publish
```

Publish the project as it is. One command, no server. [Try the beta](https://us.anfra.ai)

## anfra Cloud (Public beta)

anfra, hosted, with batteries included. The project you build locally publishes to it unchanged, and your team signs in to use it.

- **Hosted for you**: No server to run yourself
- **Users and roles**: Admins decide who builds and who views. SSO is on the way.
- **Permissions**: On the way: row-level and viewer-level, so access to data follows each user
- **Sharing and audit**: On the way: sharing links and public links, with an audit trail of who did what

[About anfra Cloud](https://anfra.ai/cloud/)

## Build it with us (Community)

Ask questions, share what you’ve built and tell us what anfra should do next.

- **Forum**: Questions, answers and show-and-tell: [forum.anfra.ai](https://forum.anfra.ai/)
- **Slack**: Chat with the team and other builders (coming soon)
- **GitHub**: Report a bug, ask for a feature or star the repo: [holistics/anfra](https://github.com/holistics/anfra)
- **Release notes**: What’s new in anfra and anfra Cloud: [anfra.ai/releases](https://anfra.ai/releases/)

## Get started with anfra

Paste one prompt into your coding agent, or run the commands yourself. The walkthrough shows the whole thing in four minutes.

### What you need

- **macOS or Linux**: x64 or ARM. Anywhere else, use the Docker image
- **A coding agent**: Claude Code, Cursor, Codex or any agent that can run commands
- **A warehouse login**: PostgreSQL, Redshift, BigQuery, Snowflake, Databricks, ClickHouse, MySQL or a DuckDB file

### Ask your agent

```text
Install anfra following https://anfra.ai/docs/local-dev/installation, connect my data warehouse and build me a first app.
```

Then paste it into your coding agent. It installs anfra, asks for your warehouse login and builds the app.

### Run it yourself

1. Install the CLI

```sh
curl -fsSL https://anfra.ai/install.sh | bash
```

2. Teach your coding agent anfra

```sh
anfra agent setup
```

3. Create a project

```sh
anfra init my-project
```

4. Open your apps at localhost:7878

```sh
cd my-project && anfra serve
```

Add your warehouse to `.anfra/data_sources.yml` before you run `anfra serve`.

[anfra: Walkthrough tutorial](https://www.youtube.com/watch?v=zxkj3wqr4e4) (video, 4:13)

### Next

- [Read the quickstart](https://anfra.ai/docs/local-dev/installation): Every step in detail, with the options for each command
- [Start from an example](https://anfra.ai/data-apps/): Open a finished data app and see the prompt that built it
- [Ask a question](https://github.com/holistics/anfra/discussions): Stuck on a step? Ask in GitHub Discussions

## FAQ

### What’s the difference between anfra and anfra Cloud?

anfra is the open-source framework you build BI with: the AMQL semantic layer, the query engine, the JS SDK and the MCP server. You run it yourself, on your machine or your own infrastructure.

anfra Cloud is anfra hosted for you, with what a whole team needs on top: sign-in, invitations and roles today, with SSO, row-level permissions, sharing and an audit trail on the way. It’s in beta in the US region, at us.anfra.ai, and projects you build locally run on it unchanged.

### Why not let Claude write SQL against the warehouse?

Claude can write the SQL, but each time it writes it again, so revenue in one app can differ from revenue in the next. With anfra, metrics are defined once in AMQL, and apps and agents ask for them by name, so anfra writes the same SQL for every caller.

You can also check a number: anfra shows the metric’s definition and the SQL that ran, instead of leaving you to read the code Claude generated. And the data is read live through your model whenever an app is opened, not saved as a snapshot.

### How does my team get to the apps?

anfra serve runs your apps on your machine while you and your agent build and check them, but it has no logins or per-user permissions. To give your team access, publish the project to anfra Cloud (in beta), where they sign in and each person has a role. Or run anfra behind your own SSO proxy, or embed the apps in your own product under your own login.

### What license is anfra under?

The Apache License 2.0. You can use it, change it and build it into your own products, commercial or not.

### How is AMQL different from dbt or Cube?

dbt transforms your data into tables. anfra reads those tables and defines the metrics on top, so the two work together.

Like Cube and dbt’s semantic layer, AMQL defines metrics as code. It is built for the analysis people ask for, such as metrics built from metrics, period comparisons, percent of total and level of detail, so agents query them instead of writing that SQL each time. Support for reading external semantic layers is planned.

### Which warehouses does it support?

PostgreSQL, Amazon Redshift, Google BigQuery, Snowflake, Databricks, ClickHouse and MySQL, plus DuckDB when you run anfra yourself. On anfra Cloud, you’ll use MotherDuck for DuckDB.

### Does anfra include an LLM?

No. anfra doesn’t include an AI model. You bring your own agent, such as Claude Code, Cursor or Codex, and it works with anfra through the agent skills, the CLI and MCP.

### Can I self-host it?

Yes. anfra runs from a single binary or its Docker image, on your machine or your own server. anfra serve has no logins or per-user permissions, so keep it where everyone who can reach it may see the data, or put it behind your own SSO proxy. anfra Cloud (in beta) adds logins and roles, and a paid self-hosted edition with the same features is planned.

---

## For coding agents

This is the Markdown version of https://anfra.ai/. Every page on anfra.ai has one: replace the trailing slash with `.md` (https://anfra.ai/cloud.md for https://anfra.ai/cloud/, and https://anfra.ai/index.md for the home page), or request the page with `Accept: text/markdown`. [llms.txt](https://anfra.ai/llms.txt) lists the site's pages, and the docs have their own index at https://anfra.ai/docs/llms.txt, where every docs page is also available as Markdown by adding `.md` to its URL.

Before you build with anfra:

- Install both the CLI and its agent skills. Installing the CLI alone is not a complete installation. Install the CLI with `curl -fsSL https://anfra.ai/install.sh | bash`. Then install the skills: in Claude Code or Codex, run `anfra agent setup`. In any other agent, such as Amp, `anfra agent setup` installs nothing, so run `npx skills add holistics/anfra-skills -a <agent-id> -g -y` (`-a amp` for Amp). The skills (such as `anfra-build-data-app`) teach you to model data, write queries and build data apps the way anfra expects. See https://anfra.ai/docs/local-dev/installation.md.
- Ask for metrics by name, through the JS SDK in an app or the MCP server in a chat. Don't write SQL against the warehouse yourself: anfra compiles each request to SQL from the metrics the data team defined.
- Check commands, files and API calls against the docs (https://anfra.ai/docs/llms.txt) instead of inferring them from the examples on this page.
- Stuck, or found a mistake? Ask in GitHub Discussions (https://github.com/holistics/anfra/discussions) or open an issue (https://github.com/holistics/anfra/issues).
