← All projects

Agentic Analytics with .NET and Angular

Agentic Analytics with .NET and Angular

Talk to your own data.

Business users want answers from their data without writing SQL and without waiting for the next report. In a final project in energy trading, an AI agent moved into a business application for exactly that. It understands the data through a semantic layer and answers questions about key figures and trading data in natural language, without access to personal data.

This demo application shows the same approach on a freely available dataset. It is open source, starts with Docker Compose and was presented live. The demo completely won over everyone present and was enthusiastically integrated into the running application.

github.com/angular-schule/demo-agentic-analytics

Ask questions, get charts

The data comes from Microsoft’s AdventureWorks, the sales of a fictional bicycle manufacturer. You can ask about revenue, costs, margin, units, orders, discounts and freight, each by time, sales channel, product, region, reseller or promotion. The answer appears directly in the chat as a chart, table, product card or reseller profile. This is called Generative UI. The app renders what the agent returns as Angular components.

Sample questions above the chat send a prepared question with one click. Ask the agent what it can do, and it suggests questions its semantic layer can answer.

A semantic layer instead of free-form SQL

The language model never writes SQL. It picks measures, dimensions and filters from a semantic layer. The backend checks every request and passes all values to the database as parameters. The tools the model can call are generated from the same semantic layer, so the model only knows names that actually exist.

This keeps the number of tools small. A new question needs a new measure or dimension in the semantic layer, not a new tool.

A dashboard that loads without a language model

A good answer can be pinned to the dashboard, with a button or through the chat. The dashboard stores the query and fetches the numbers directly from the backend on every load. That needs no language model and no tokens. If no model is configured, the app still starts and the dashboard keeps working.

Personal data stays out

Everything a tool returns goes to the provider of the language model. That is why the semantic layer itself contains no personal data. Company names are included, people are not. So there are no sales representatives and no contact persons. The backends’ database account reads only three views without personal data. The database itself enforces which sales territory they are restricted to.

The app loads no fonts, scripts or telemetry from third parties. Wherever the tools in use send usage data and it can be turned off, it is turned off.

Two backends, one contract

The same Angular app runs with either a TypeScript backend or a .NET backend:

  • TypeScript: NestJS with the agent framework Mastra, Drizzle and PostgreSQL
  • .NET: ASP.NET Core as a Minimal API with the Microsoft Agent Framework, Entity Framework Core and SQL Server

Both backends generate their OpenAPI document from their own code. Contract tests ensure that both documents describe the same contract and that both backends respond the same way. In both cases the agent has the same system prompt and the same three tools. It runs in the backend’s process or as a separate Mastra service in front of it.

Angular, CopilotKit and AG-UI

The frontend is an Angular app without Zone.js, with Signals and httpResource. CopilotKit for Angular handles the chat and the Generative UI. Between app and agent, the AG-UI protocol (Agent-User Interaction) does the talking, streamed as Server-Sent Events.

For learning purposes, a panel below the chat shows every message on both legs. You can see the AG-UI events between browser and agent and the requests between agent and language model. That way you can see exactly what the model receives. The panel can be switched off and does not belong in a production application.

The language model of your choice

Which model answers is set in the configuration. The options are Claude from Anthropic, OpenAI, Google Gemini and Mistral. For OpenAI and Mistral, processing in the EU can be configured. Without an API key, a demo model answers that works without a language model, so the app also runs at no cost.

Tests run against a mock language model with predefined answers. They include unit tests for frontend and agent, contract tests across both backends and all agents, and browser tests with Playwright.

Open source

The demo is on GitHub, with instructions for starting it with Docker Compose: github.com/angular-schule/demo-agentic-analytics

It was inspired by Manfred Steyer’s live coding workshop “Build an Agentic Analytics App with Angular” (his demo). It is built from scratch with its own data, its own backends and a clear focus on data protection. An article series for angular.schule is in preparation.