Microsoft Fabric Rayfin App Replays Barcelona’s 5-0 Clásico With Live Match Analytics
By Nikola 602 views
A Fabric match center combines Eventhouse analytics, a DirectQuery model and Rayfin app writes to replay Barcelona’s 2010 win.

Microsoft Fabric can host more than a report that refreshes after a match. A Rayfin app can pair live analytics with user data that the app writes to its own database. A football match center built around Barcelona’s 5-0 win over Real Madrid on 29 November 2010 shows how those pieces fit together: event data streams into Fabric, a semantic model serves the figures, and signed-in users can submit predictions.
The replay follows the original match at an adjustable pace. It marks Xavi’s goal at 9 minutes and Pedro’s at 17, then tracks David Villa’s two goals after half-time. As the events arrive, Barcelona’s expected goals (xG) rise to 2.77, while Real Madrid’s finish at 0.13. The figures come from StatsBomb open data for the match, identified as 69299.
One workspace, two kinds of data
The design brings together two workloads. Match events are read-heavy: thousands of passes, shots and other actions feed calculations such as xG, momentum and player networks. Predictions and scouting notes are small writes that need somewhere to persist. Fabric’s analytics services handle the first workload; Rayfin supplies an app backend for the second.
Rayfin is an open-source SDK and command-line tool for deploying an application backend to Fabric. Developers define data entities in TypeScript, then use rayfin up to provision a Fabric SQL database, GraphQL API, Entra sign-in and static front-end hosting as a Fabric App item.
- Ingestion: A Python producer replays StatsBomb events into an Eventstream custom endpoint at a chosen speed.
- Eventhouse: JSON arrives in
raw_events. An update policy converts it into typed records inmatch_events. Seven KQL functions calculateScoreline,XgRace,Momentum,ShotMap,PassNetwork,PlayerStatsandKeyMoments. - Semantic model: A DirectQuery model exposes one table for each KQL function and uses a single
Match_Idparameter. The app sends DAX queries to this model, keeping its match figures in one governed layer. - Rayfin app: A React front end reads match data through the semantic model and stores predictions in its own SQL database through the generated GraphQL API. Users sign in with Entra and install nothing.

Everything apart from the event producer runs in one workspace. The analytics path serves match data, while the SQL database provisioned by Rayfin holds user-created records.
Turning archived events into a replay
Commercial live sports feeds can involve contracts, making them an awkward starting point for a demonstration. The project instead uses StatsBomb open data, which is free for non-commercial use and includes La Liga events from the Messi era. The 2010 Clásico file contains 3,975 events, with timestamps, teams, players and pitch coordinates; shot events also include StatsBomb’s xG values.
The producer, ingest/replay_match.py, filters that file down to 1,565 events useful to a match center. It keeps passes, shots, dribbles, duels, cards and substitutions, while dropping ball receipts, carries and pressures. It emits each retained event according to when it occurred in the match, with the delay scaled by the --speed setting. Half-time is skipped; at --speed 10, the replay takes about nine minutes.
Each message carries a match_id, an emitted_at timestamp and the event itself inside content. That small envelope lets the receiving Eventstream accept the data as it arrives, while the event payload remains available for KQL processing.
Deploying the Fabric components
The project stores its components as code: the KQL schema is a script, the Eventstream is a JSON definition, the semantic model is TMDL, and the app is TypeScript. A Python deployment script uses Fabric and Power BI REST APIs to create or update the workspace items, then deploys the app with the Rayfin CLI. Sign-in is the only browser step described in the setup.
The prerequisites are a Fabric workspace on capacity, with F2 or a trial listed as sufficient; an Admin or Member role in that workspace; and the Fabric apps tenant setting enabled by a Fabric admin. The local machine needs Python 3.10 or later, Node.js 20 or later, and Azure CLI. The tenant ID and workspace ID appear in the workspace URL as ctid and the group ID.
From PowerShell in the project folder, sign in and install the producer dependency:
az login --tenant <tenant-id> python -m pip install -r ingest\requirements.txt
Preview the deployment before creating anything:
python fabric\deploy\deploy.py --tenant-id <tenant-id> --workspace-id <workspace-id> --dry-run
Then deploy to the workspace. The first run takes about 15 minutes, mostly while Fabric provisions the items:
python fabric\deploy\deploy.py --tenant-id <tenant-id> --workspace-id <workspace-id>
Replay the match with the bundled event data:
python ingest\replay_match.py --events ingest\data\events_69299.json --speed 10
The producer gets the Eventstream connection string through the Fabric API using the Azure CLI sign-in token, so the operator does not need to copy that string manually. Check the deployment chain with:
python fabric\deploy\08_verify.py
Once the replay and verification are complete, open the rayfin-football Fabric App item in the workspace.
What the deployment creates
The script creates or reuses EH_Football and its KQL database, then applies the KQL schema: tables, mapping, update policy, 10-second batching and the seven functions. It creates ES_MatchEvents from its definition, connecting the custom endpoint to raw_events, and uploads the Football_Model TMDL definition pointed at the workspace’s Eventhouse.
It also sets the model’s data source to end-user sign-in, so each user queries the Eventhouse as themselves. The deployment writes the model ID into the app’s environment files and rayfin.yml, then runs rayfin up. That command creates the Fabric App item, its SQL database, GraphQL API and built front end. The database includes Prediction, ScoutingNote and WatchedMatch tables.
The deployment steps can be run again, and existing items with the default names are reused. After a full replay, the verification script should show Barcelona with 5 goals from 14 shots, xG of 2.77 and 723 passes at 88.1% accuracy. Real Madrid should show 0 goals from 5 shots and xG of 0.13.
To replay from a clean state, clear both Eventhouse tables in a KQL queryset:
.clear table raw_events data .clear table match_events data
If only one component changes, the deployment script can target that step. For example, after editing KQL, run deploy.py --only 2.
A match center built for the screen
The interface takes its cues from television match graphics rather than a conventional dashboard. It uses a dark pitch, the two teams’ colors, condensed number styling and a prominent score. The screen includes a clock that advances every second and a pulsing LIVE marker. When a goal arrives, the scoring team’s color sweeps across the scoreboard strip alongside the scorer’s name.

- Stat bars cover shots, shots on target, xG, passes, pass accuracy and cards, with each bar extending toward its team’s side.
- Shot map shows both teams on one pitch. Barcelona attack the right goal and Madrid the left. Since StatsBomb records teams as attacking left to right, the away side’s coordinates are mirrored. Shot marker size reflects xG, and goals receive a gold ring.
- Pass network shows player average positions and passing links, with a team toggle. For this match, Xavi’s central role stands out.
- xG race and momentum chart each side’s cumulative xG and display momentum as a mirrored graphic. The momentum calculation uses shots, final-third passes and box entries over a five-minute window.
- Key moments list goals, shots, cards and substitutions, using familiar player names such as Xavi rather than Xavier Hernández Creus.
- Predictions let signed-in users submit a score and optionally name the first scorer before the match begins. The form locks once the replay goes live, and a prediction that remains possible is marked green.
Predictions are app data, with ownership checks
The prediction feature demonstrates the difference between reading analytics and writing application data. Each signed-in user can submit one prediction per match and change it until kickoff. The record lives in the app’s own SQL database, rather than in the Eventhouse match data.
Rayfin defines the entity and access rules in a TypeScript class. Signed-in users can read predictions, which makes a shared leaderboard possible. Create, update and delete operations are limited to the record’s owner: the server compares the sub claim in the user’s Entra token with user_id. A modified client request therefore cannot grant a user permission to edit someone else’s entry. The front end calls methods such as client.data.Prediction.create(...) and update(...), with types derived from the same class.
During the replay, the app checks predictions against the score and marks those still possible in green. The entity includes a points field for scoring predictions after full time, though that scoring feature has not been built.
Power BI also supports writes through Translytical task flows. A report button can call a Fabric User Data Function to insert, update or delete rows, which suits an action such as approving an order or correcting a record from a visual. In this app, predictions sit within the application’s own data model, with permissions declared beside the entity and an interface designed around the workflow.
Development experience and trade-offs
Claude produced most of the implementation: the replay producer, KQL schema and functions, Rayfin entities, TMDL model, React interface and deployment scripts. The builder supplied the brief, made design and implementation decisions, iterated on the result and ran each component in a personal tenant.
That tenant testing mattered because Claude could not inspect the Fabric environment directly. Some initial guesses failed in practice, including a nonexistent rayfin config command and KQL variables that used reserved words. The fixes came after errors were returned to Claude and the code was run again. Mock testing against a Fabric API also caught three defects before tenant testing: the KQL script was split into 16 broken fragments, the model ID went into a file the app did not read, and the pass-network query needed a separate call for each team.
For teams weighing this against a conventional Power BI report, the main difference is the application behavior. The app’s clock and score update as events arrive, and its pitch visualization is an SVG in React rather than a custom visual SDK. Its analytics still come from one semantic model, and the app, data and Entra sign-in sit in the Fabric workspace.
There are operational costs to account for. Rayfin is in preview, and during this build the service began requiring a newer CLI than the project had pinned; upgrading to version 1.36 changed the client API in two places. The front end also requires someone to build and maintain a React application. Finally, the always-on Eventhouse is the largest capacity consumer in this setup, so capacity sizing needs to account for it.

Getting started
Rayfin can scaffold a starter app with sign-in and a data model using npm create @microsoft/rayfin@latest; npx rayfin up deploys it to a workspace. The awesome-rayfin gallery offers templates. The Helsinki Public Transport template is the closest match to this project, and its deployment scripts provided a starting point.
To run the football match center, use the project repository and follow the deployment sequence above. Keep the data terms in mind: StatsBomb open data is for non-commercial use with attribution, so it fits demonstrations and talks rather than a paid product. The deployment scripts and query transport code are adapted from the MIT-licensed Helsinki template. Further references include the Rayfin repository and Microsoft’s Fabric Apps programming model documentation.