anfra docsAlpha

Concepts

How anfra fits together, and the terms used across these docs

An anfra project is a folder of code in Git. It holds two things: a semantic layer that defines what your data means, and data apps that show it. A context layer, the Semantic Catalog, gathers the knowledge around those definitions so agents can find and trust them. anfra Server connects them: when a reader uses an app, the server turns each request into a query on the semantic layer and runs it on your warehouse.

How anfra fits together
  • Runtime · every reader interaction
  • Development time · reviewed in Git
  • Reader — Opens an app in the browser
  • Data app
  • Your page — Your HTML, CSS and charting library: draws the results and handles clicks
  • anfra SDK — Declares queries, controls and cross-filters, and sends them to anfra Server
  • anfra Server — anfra serve: resolves each SDK request through the semantic layer and runs it
  • Warehouse — Your database. Every query runs here
  • Semantic layer — Data models, datasets, metrics and dimensions, as AML in your project
  • Coding agent — Claude Code, Codex or Cursor, with the anfra skills
  • Semantic Catalog — The context layer: definitions, docs, ownership and lineage from your AML, dbt and LookML, searchable by agents
  • Git repo — Your project: AML, apps and config as plain files, reviewed and versioned in Git
  • reader → page (interacts)
  • page → sdk (uses)
  • sdk → server (semantic queries)
  • server → warehouse (SQL)
  • semantic → server (definitions)
  • agent → page (builds)
  • agent → semantic (models)
  • agent → catalog (searches)
  • semantic → git (stores)
  • git → catalog (ingested)

Architecture

Your project

Everything you write lives in one Git repository, as plain files:

  • models/ and datasets/ hold the semantic layer, in AML.
  • apps/ holds the data apps, one HTML file each.
  • .anfra/ holds the project's config, such as warehouse connections and the context sources for the catalog.

Because it is all code, a change to a metric or an app is reviewed, versioned and rolled back like any other change. See Project structure.

The semantic layer

The semantic layer defines your business data once: which tables matter, how they join, and what "revenue" or "active user" means. anfra uses AMQL: AML to define the semantic layer, and AQL to query it.

Apps and agents query the semantic layer by name, such as "revenue by month", never with hand-written SQL. anfra generates the SQL, including the joins, so every app gets the same answer to the same question. See Semantic layer for the building blocks, and Model your data to build one.

The context layer (Semantic Catalog)

The semantic layer says how a metric is calculated. To answer "Why did revenue drop?", an agent also needs to know which revenue metric to use, what it includes and where its data comes from. The context layer holds that knowledge, and in anfra it is the Semantic Catalog.

anfra ingest builds the catalog from your project's AML and from the dbt and LookML projects you list as context sources in .anfra/context_sources.yml. Agents and people then use it to:

  • Search for metrics, datasets and models in business language, with anfra search.
  • Trace lineage from a metric back to the fields, models and source tables it is built from, with anfra lineage or Anfra.lineage() in a data app.

The catalog is a snapshot, not a live view of your files, so run anfra ingest again after you change a model or a context source. anfra keeps it on your machine, outside the project, under ~/.anfra/repos/. See Semantic Catalog.

Data apps and the anfra SDK

A data app is an HTML page: a dashboard, a report or a custom analysis, built with any HTML, CSS and charting library. The page uses the anfra SDK to declare the data each view needs and how its filters, drill-downs and clicks connect.

The page draws the results. It doesn't build queries, apply filters or compute metrics, so its numbers can't drift from the semantic layer. See Semantic UI.

anfra Server

anfra Server, started with anfra serve, sits between your apps and your warehouse. For each interaction, it applies the reader's choices to the app's queries, resolves them through the semantic layer, generates SQL and runs it on the warehouse.

It also serves the apps themselves, with an Inspect panel showing the query and SQL behind every view, and an API and MCP server that let agents read your models.

Your warehouse

Your data stays in your warehouse, and every query runs there. anfra connects to it through connections, defined with their credentials in .anfra/data_sources.yml. See Connect your data.

Coding agents and skills

anfra includes no AI model. You bring your own coding agent, such as Claude Code, Codex or Cursor, and the anfra skills teach it to model data, write queries and build apps. The agent writes code into your project, and you review it like a teammate's. See Set up your coding agent.

anfra Core and anfra BI Cloud

anfra Core is the open-source engine: the anfra binary, which runs on your machine or a server. anfra BI Cloud is the hosted anfra BI, built on the same engine, at us.anfra.ai. It adds organizations, members with roles, and a sign-in for each person's AI client through the MCP server it hosts. A project built with Core runs unchanged on anfra BI Cloud, and moves there with anfra publish. To compare the two, see Choose how to run anfra.

How a number reaches the page

  1. A reader opens an app, or changes a filter, drill or selection in it.
  2. The SDK sends the app's queries, with the reader's current choices, to anfra Server.
  3. The server applies those choices to each affected query and resolves it through the semantic layer into SQL.
  4. The warehouse runs the SQL and returns the rows.
  5. The page draws the results. The Inspect panel shows the AQL and SQL that produced each one.

Key terms

Semantic layer

TermMeaning
ConnectionHow anfra reaches your warehouse: a name, a type and credentials. Models refer to it by name. The CLI, data_sources.yml, publish prompts and the anfra BI Cloud UI call it a data source.
Semantic layerYour business data defined once, in AML: data models, datasets, metrics and dimensions.
Data modelMaps one table or SQL query to dimensions and measures.
DatasetJoins data models through relationships. It is what apps and agents query.
MetricA named calculation on a dataset, such as revenue. It can span models and build on other metrics.
MeasureAn aggregation on a single data model.
DimensionA field to group or filter by, such as a date, status or country.
RelationshipHow two models in a dataset join, and which side is "many".
AMLThe language the semantic layer is written in, in .aml files.
AQLThe language for querying a dataset, as in explore { dimensions { … } measures { … } }.

Context layer

TermMeaning
Semantic Cataloganfra's context layer: definitions, documentation, ownership and lineage in one place agents can search.
Context sourceA dbt or LookML project listed in .anfra/context_sources.yml, ingested alongside your AML.
IngestBuilds the catalog from your AML and context sources, with anfra ingest.
SearchFinds catalog entities by text, property and lineage, with anfra search.
LineageTraces a field back to the metrics, models and source tables it is built from.

Apps

TermMeaning
Data appOne HTML file in apps/, served by anfra serve.
QueryThe data one view needs: a dataset and an AQL query.
ControlAn input the reader changes: a filter or a date drill.
Control mappingWhich queries a control applies to, and on which field.
Cross-filterFilters one query by the rows a reader selects in another.
Semantic UIThe SDK's model of an app: queries, controls and the mappings between them.
InspectShows the AQL and SQL that actually ran for each query.

Next steps

On this page