Skip to content

LBS Foundry Documentation

Documentation for LBS Foundry — a sports content and data management platform built on event sourcing and CQRS. Start with Introduction for a platform overview.

This index is generated from each document's YAML frontmatter (type / title / description) by tools/docs/docs-index.mjs. Do not edit by hand — run pnpm docs:index after adding or moving a doc. See the documentation conventions.

Start here

Getting started

Architecture

  • LBS Foundry Architecture Overview index — This guide provides a comprehensive overview of the LBS Foundry architecture, design patterns, and core principles.
  • Domain-Driven Design: Aggregates, Events, and Commands concept — This guide explains how to implement domain-driven design (DDD) concepts using our event sourcing framework.
  • Batch Command Execution Design design — This document outlines design options for executing multiple commands in a single API request, with support for transactional execution grouped by aggregate...
  • Data Harvesters Overview concept — The Data Harvesters are responsible for ingesting real-time data from external sources into the system. These sources can include sports data feeds, social...
  • Foundry Database Schema Diagram reference — The following contracts are registered in their own Marten modules for the main event store database, not the Foundry read model store:
  • Event Sourcing Architecture concept — This document describes the event sourcing implementation in LBS Foundry, including patterns, practices, and technical details.
  • Foundry — Architecture, Rationale & Glossary reference — Architecture, rationale, and glossary for the Foundry platform: what it is, what it delivers (a canonical record of the sport plus the full distribution of simulated game outcomes), and the canonical terminology.
  • Foundry — Architecture Use Case Walk concept — A use-case walk of the Foundry architecture. Each walk traces a realistic
  • Generic Query Pattern design — The generic query pattern provides abstract base classes for implementing common query operations (GetAll, GetById) while allowing derived classes to:
  • Identity Linking — Problem & Solution Summary design — LBS.Foundry ingests sports data from multiple providers (FoxSports, SuperCoach, StatsPerform, NRL Web, and — in the NFL 2026-2027 initiative — NflVerse, ESPN)....
  • Mermaid Diagram Update Prompt reference — Use this prompt at the end of any session where you've added or modified contracts, events, or contract builders. Paste it into Claude Code (or any AI...
  • Multi-Host Concurrency Design design — The current TimerService implementation only controls concurrency within a single host process:
  • Query-Command System Alignment Design design — This document outlines a design for aligning the query system architecture with the command system patterns to achieve consistency and reduce complexity.
  • Real-Time Notification System - Technical Design design — Related ADR: real-time-notification-system.md
  • LBS.EntityResolution — Provider-to-canonical-ID resolution reference — Resolves a provider's rows to Foundry canonical_ids — one canonical identity per real-world entity across every provider, so downstream Foundry Core joins...

Developer guide

  • Developer Guide index — Day-to-day development reference for LBS Foundry. For platform overview see intro; for architecture see architecture/README.
  • Adding Event History to Detail Pages guide — This guide shows how to add event history viewing capabilities to any aggregate detail page in Foundry.
  • CI/CD Pipeline guide — This document describes the LBS Foundry continuous integration and deployment pipeline, implemented in .github/workflows/Build-Container-Apps.yml.
  • Coding Standards guide — This guide outlines the coding standards and conventions for the LBS Foundry project. Following these standards ensures consistency, maintainability, and...
  • Common Development Tasks guide — This guide covers the most common tasks you'll perform while developing LBS Foundry. Each task includes step-by-step instructions and examples.
  • Debugging and Troubleshooting Guide guide — This guide covers common issues you might encounter while developing LBS Foundry and how to resolve them.
  • Deployment Pipeline Setup Guide guide — This guide provides step-by-step instructions for setting up the deployment pipeline for LBS Foundry applications, including GitHub secrets configuration and...
  • LBS Foundry Development Workflow guide — This guide outlines the internal development workflow and best practices for the LBS Foundry team.
  • Event History Viewer (Backend) guide — This document describes the event history viewing feature in Foundry, which allows viewing the complete event stream for any aggregate.
  • Event Versioning and Maintaining Backwards Compatibility guide — This guide explains how to version, rename, or retire an event in an event-sourced system without breaking replay, projections, local environments, or...
  • Frequently Asked Questions (FAQ) guide — Common questions and answers for LBS Foundry developers.
  • Generic Queries guide — Reusable base query records (GetAllQuery / GetByIdQuery) and their handlers for read models implementing IContract.
  • Module System guide — The LBS module system provides a declarative way to enable/disable features and timers based on enabled modules. It integrates seamlessly with the Timer...
  • Real-Time Notification System - Developer Guide guide — The LBS Foundry notification system provides real-time WebSocket-based notifications for database entity changes. It eliminates the need for polling and...
  • GetByIdQuery Ownership Validation - Design Options design — This document outlines potential approaches for implementing ownership validation in GetByIdQuery. This is Phase 2 functionality that was deferred...
  • Real-World Event Replay Testing guide — This guide explains how to create tests that replay production/staging events through builders to verify correct behavior and debug issues.
  • Timer Infrastructure guide — LBS Foundry provides a declarative timer infrastructure for scheduling recurring tasks. Instead of writing manual SystemBackgroundService implementations with...

SDK

  • SDK Generation & Publishing Process guide — This document explains how and when the TypeScript and Python SDKs are generated and published.
  • SDK Generation Strategy & Versioning guide (archived) — RFC weighing whether to commit auto-generated SDK files, with a recommendation and versioning strategy.
  • SDK Generation guide — The LBS Foundry platform provides auto-generated client SDKs in multiple languages, ensuring type safety and API consistency across all client applications.
  • GitHub Token Setup for pnpm on Windows guide — This guide explains how to configure a GitHub Personal Access Token (PAT) for pnpm on Windows to access private packages from GitHub Packages.
  • SDK Local Development Guide guide — This guide explains how to use the Foundry SDK locally during development, including linking the SDK to your applications and testing authentication.

Architecture decisions (ADRs)

API

Ballr

Importers

  • ClearRugbyLeaguePlayerProjectionsImporter guide — Clears player projections for NRL SuperCoach participant stats. Supports clearing all participants for a given season and round, or a specific subset of...
  • Event Integrators Guide guide — Event integrators allow you to react to domain events in the event store, enabling integration with external systems, cross-aggregate workflows, and...
  • Admin Feed Imports guide — How the admin Feed Imports UI browses harvested provider data and triggers imports through the generic per-entity importers and the import infrastructure.
  • Import Infrastructure Usage Guide guide — This document explains how to use the LBS Foundry import infrastructure for creating and executing transactional imports.
  • SquadImporter guide — Imports squad rosters (team-by-season player, coach, and staff lists) from the foundry.squads ClickHouse table into the SquadAggregate, reconciling each squad declaratively against the feed.
  • Stats Perform NRL Match State Reference guide — Single source of truth for the Stats Perform Rugby League game state model and its mapping to the Foundry domain.
  • StatsPerformNrlScoreboardImporter guide — Manually triggers a full reprocess of an NRL match scoreboard from StatsPerform. Fetches live match data from the StatsPerform API, resolves player and team ID...

Integrations

  • Clerk Authentication Integration guide — This document describes the pure event-sourced User authentication system integrated with Clerk for the LBS Foundry platform.
  • Clerk Webhook Implementation Plan plan — Implement a secure webhook handler to synchronize user data between Clerk and our system, creating user aggregates and preferences when users are created...
  • Cloudflare PFX Certificate Generation Guide guide — Complete guide for generating PFX certificates from Cloudflare Origin Certificates for use with Azure Container Apps custom domains.
  • Discord Integration Configuration guide — The LBS Foundry platform integrates with Discord to provide community engagement and user verification features. This document outlines the configuration...
  • Discord Verification Frontend Flow guide — How the Discord verification frontend flow works: a backend-served verification page that hands off to the SvelteKit login page and back again to complete account linking.
  • LBS Ballr MCP Server Setup Guide guide — The LBS Ballr MCP Server provides secure, controlled access to sports data via the Model Context Protocol (MCP). It integrates with Clerk OAuth for...
  • NuGet Package Publishing Guide guide — This guide provides step-by-step instructions for publishing NuGet packages to GitHub Packages for this repository.

Models

  • American Football Benchmarks guide — BenchmarkDotNet harness for the NFL simulation and outcome-context pipeline. Tracks the cost of simulating a season and folding it into outcome contexts, so...
  • Engine — NFL Game Simulator model — NFL game simulator — a code-driven finite state machine that mirrors the flowchart in docs/models/americanfootball/nfl-flow/rendered/nfl_sim_flowchart.md. This...
  • Play Decision — Real Model Integration Contract reference — The Play Decision predictor is the first real model behind the Predictors seam: the quants' Play Decision network, replacing the LBS-1654 pseudo predictor...

American Football

NFL flow

  • NFL Simulation Flowchart index — Mermaid visualization of the NFL game simulator state machine, organized into 3 phases (Initialization / Play Execution / Play Aftermath). Vendored from the...
  • NFL Game Simulation Flowchart — Glossary model — Terms used across the flowchart and its supporting docs. Domain vocabulary (NFL game / simulator state machine) and doc-framework vocabulary (how this project...
  • UPDATING.md model — Operating manual for docs/models/americanfootball/nfl-flow/. Read this before editing the flowchart.
Rendered

Outcome Context

Evaluations

Storage experiment

Query layer

Sub-designs

Sport / domain

  • GetLadderQuery — Reference reference — Source-of-truth reference for GetLadderQuery: the read-model query that returns competition ladder
  • GetSportingEventsQuery — Filter Mode Reference reference — Reference for the three mutually exclusive filter modes of GetSportingEventsQuery and the fixed priority ladder the handler uses to resolve exactly one mode per request.
  • GetMappedPlayers Query reference — Retrieves the full list of mapped players from ClickHouse, providing a cross-reference between FOX Sports, NRL, and SuperCoach player identifiers.
  • ScoreBoard Unit Tests Documentation reference — How the ScoreBoard aggregate unit-test suite is structured (Cricket and Rugby League partials, integrator, projection builder) and how to run it.
  • Process Flow of SetGroupCommand reference — This document describes the end-to-end flow for handling a SetGroupCommand against a sporting event aggregate, including validation, change detection, event...

SuperCoach participant stats

  • Cricket SuperCoach Participant Stats Rules reference — This document outlines the scoring rules and statistics tracked for Cricket SuperCoach participants. Each player receives one document per match that is...

Data engineering

Testing

  • Notification System Testing Guide guide — This guide covers testing strategies for the LBS Real-Time Notification System across unit tests, integration tests, and end-to-end scenarios.
  • Testing CQRS Command System guide — This document provides examples for testing the command endpoint (POST /api/command) using existing commands in the system. Requests are intended to be run...
  • Importer System Testing guide — This document provides examples for testing the import endpoint (POST /api/import). Requests are intended to be run with Bruno; each example shows the request...
  • Read-Model Query Testing guide — This document provides examples for testing the read-model endpoint (POST /api/readmodel) and its authentication behaviour. Requests are intended to be run...

Runbooks

  • Runbook: Archive Non-LuckBox Aggregates runbook — Scope: Marten event streams in events.mt_events whose Create event carried a non-LuckBox DataSource. These are duplicate aggregates left behind by the...

Configuration

  • Configuration Samples index — This directory contains sample configuration files for various integrations and features in LBS Foundry.

Samples

Experiment runs

  • Experiment Run Results index — Captured output from real runs of the storage experiment against a local ClickHouse container.

Use cases

User guides

End-user guides

  • Projection Visibility Management guide — Projection Visibility Management allows content managers to control which rounds of player projections are visible to Ballr users. All projection data for...

Meta (docs about docs)