Skip to content

Foundry Database Schema Diagram

Complete ERD of all read model contracts registered in the Foundry database (FoundryReadModelConfiguration). The Foundry database is a read-only secondary PostgreSQL store (schema: readmodels) queried via IFoundryStore. Event streams (aggregates) and their async projections (ContractBuilders) produce these contracts in the main event store; they are replicated to Foundry for cross-service reads.

Full Schema Overview

erDiagram
    %% ============================================
    %% CORE SPORT
    %% ============================================

    CompetitionContract {
        Guid Id PK
        string Slug
        string_nullable Code
        string_nullable Name
        string_nullable ShortName
        DataProvider DataSource
        Sport Sport
        long Version
        bool AutoImportEnabled
    }

    SeasonContract {
        Guid Id PK
        string_nullable SeasonName
        int SeasonYear
        string_nullable SourceId
        bool CurrentSeason
        DataProvider DataSource
        string_nullable SourceName
        CompetitionId CompetitionId FK
        string Slug
        Sport Sport
        string_nullable CurrentGroupName
        List_SeasonGroup Groups
        List_PoolNode PoolNodes
        List_PoolDefinition PoolDefinitions
        long Version
    }

    SeasonGroup {
        string Name
        bool IsProjectionsVisible
    }

    PoolNode {
        PoolId PoolId
        string Code
        string Name
        string Definition
        string_nullable ParentCode
        PoolId_nullable ParentPoolId
        int DisplayOrder
    }

    PoolDefinition {
        string Name
        bool CanBeTopLevel
        List_string AllowedParents
        bool CanHaveChildren
    }

    TeamContract {
        Guid Id PK
        string Name
        string ShortName
        string FullName
        string Code
        string DisplayName
        DataProvider DataSource
        Sport Sport
        long Version
        string Slug
    }

    ParticipantContract {
        Guid Id PK
        string FirstName
        string DisplayName
        string FullName
        string Surname
        string_nullable MiddleName
        DateTimeOffset_nullable DateOfBirth
        string Nationality
        int_nullable Height
        int_nullable Weight
        Sport Sport
        string Status
        DataProvider DataSource
        long Version
        string Slug
        ParticipantType Type
    }

    LineupContract {
        Guid Id PK
        Guid SportingEventId FK
        Guid SeasonId FK
        Sport Sport
        string Status
        List_LineupTeamContract Teams
        long Version
    }

    LineupTeamContract {
        TeamId TeamId FK
        List_LineupMemberContract Members
    }

    LineupMemberContract {
        ParticipantId ParticipantId FK
        string Role
        string SelectionRole
        string_nullable MatchPosition
        int_nullable JerseyNumber
        bool Captain
        string_nullable CoachingRole
        string_nullable WithdrawalReason
    }

    InjuryContract {
        Guid Id PK
        Guid ParticipantId FK
        Guid SeasonId FK
        Sport Sport
        DateTimeOffset ReportedAt
        InjuryStatus CurrentStatus
        string InjuryType
        string InjuryLocation
        string_nullable InjurySide
        DateOnly_nullable ReturnDate
        string_nullable ShortComment
        string_nullable LongComment
        bool IsResolved
        DateTimeOffset_nullable ResolvedAt
        long Version
    }

    SquadContract {
        Guid Id PK
        Guid TeamId FK
        string TeamName
        Guid SeasonId FK
        string SeasonName
        Sport Sport
        List_SquadMemberContract Members
        int MemberCount
        List_SquadTierCount MembersByTier
        long Version
    }

    SquadMemberContract {
        ParticipantId ParticipantId FK
        string Name
        MemberCategory MemberCategory
        NflSquadTier_nullable NflSquadTier
        Position_nullable PrimaryPosition
        int_nullable JerseyNumber
    }

    SquadTierCount {
        string Tier
        int Count
    }

    SportingEventContract {
        Guid Id PK
        long Version
        DataProvider DataSource
        CompetitionId CompetitionId FK
        SeasonId SeasonId FK
        Sport Sport
        string Group
        SportingEventTeamsEventContract Teams
        DateTimeOffset StartTimeUtc
        VenueSummaryContract Venue
        string Slug
        bool IsArchived
    }

    SportingEventTeamsEventContract {
        SportEventTeamContract HomeTeam
        SportEventTeamContract AwayTeam
    }

    SportEventTeamContract {
        string Id
        string Name
        string ShortName
        TeamId TeamId FK
        string Code
    }

    VenueSummaryContract {
        VenueId Id FK
        string Name
    }

    WeatherContract {
        Guid Id PK
        Guid SportingEventId FK
        Guid VenueId FK
        string VenueName
        WeatherCondition Condition
        bool IsForecast
        decimal_nullable TemperatureCelsius
        int_nullable HumidityPercent
        decimal_nullable WindSpeedKph
        int_nullable WindDirectionDegrees
        decimal_nullable PrecipitationMm
        decimal_nullable PressureHpa
        decimal_nullable TemperatureFahrenheit
        decimal_nullable WindSpeedMph
        decimal_nullable PrecipitationInches
        DateTimeOffset ValidAt
        DataProvider DataSource
        long Version
    }

    %% ============================================
    %% SCOREBOARDS
    %% ============================================

    ScoreBoardContract {
        Guid Id PK
        Guid SportingEventId FK
        Sport Sport
        string HomeTeamId
        string HomeTeamName
        string AwayTeamId
        string AwayTeamName
        string Period
        MatchStatus Status
        bool IsPartial
        long Version
    }

    RugbyLeagueScoreBoardContract {
        Guid Id PK
        List_RugbyLeaguePeriodContract HomePeriods
        List_RugbyLeaguePeriodContract AwayPeriods
        MatchTimeContract_nullable MatchTime
    }

    RugbyLeaguePeriodContract {
        Period Period
        int Points
        int Tries
        int Conversions
        int PenaltyGoals
        int FieldGoals
    }

    MatchTimeContract {
        SourceTier SourceTier
        DataProvider DataSource
        MatchClockState MatchState
        MatchClockEventContract MatchClock
        Period CurrentPeriod
        List_MatchClockPeriodEventContract Periods
    }

    MatchClockEventContract {
        int Value
        ClockDirection Direction
        ClockState State
        DateTimeOffset LastUpdatedUtc
    }

    MatchClockPeriodEventContract {
        Period Code
        int ExpectedDurationSeconds
        int ActualDurationSeconds
        MatchClockEventContract Clock
    }

    CricketScoreBoardContract {
        Guid Id PK
        List_CricketInningsContract HomeInnings
        List_CricketInningsContract AwayInnings
        CricketTossContract_nullable Toss
        string MatchSummary
    }

    CricketInningsContract {
        Period Period
        int Runs
        int Wickets
        decimal Overs
    }

    CricketTossContract {
        TeamId_nullable TeamWonId FK
        TeamId_nullable TeamBattingFirstId FK
        string_nullable TossSummary
    }

    %% ============================================
    %% SCORECARDS
    %% ============================================

    ScoreCardContract {
        Guid Id PK
        Guid SportingEventId FK
        Sport Sport
        long Version
    }

    CricketScoreCardContract {
        Guid Id PK
        CricketScoreCardTeamsContract Teams
        CricketTossContract_nullable Toss
        List_CricketInningsScoreCardContract Innings
        MatchStatus_nullable MatchStatus
        Dict_ParticipantId_CricketLineupParticipantContract Lineup
    }

    CricketScoreCardTeamsContract {
        CricketScoreCardTeamContract_nullable TeamOne
        CricketScoreCardTeamContract_nullable TeamTwo
    }

    CricketScoreCardTeamContract {
        TeamId TeamId FK
        string_nullable TeamName
        string_nullable TeamCode
    }

    CricketInningsScoreCardContract {
        int InningsNumber
        TeamId_nullable BattingTeamId FK
        TeamId_nullable BowlingTeamId FK
        int TotalRuns
        int TotalWickets
        int TotalOvers
        int TotalBalls
        CricketExtrasContract Extras
        List_CricketBatterScoreCardContract Batting
        List_CricketBowlerScoreCardContract Bowling
        List_CricketFallOfWicketContract FallOfWickets
        Dict_int_CricketBallEventContract BallsBySequenceNumber
    }

    CricketExtrasContract {
        int Wides
        int NoBalls
        int Byes
        int LegByes
        int Penalties
    }

    CricketBatterScoreCardContract {
        ParticipantId BatterId FK
        TeamId_nullable TeamId FK
        string_nullable DisplayName
        int BattingOrder
        int Runs
        int BallsFaced
        int Fours
        int Sixes
        int DotBalls
        int ScoringShots
        bool IsNotOut
        bool HasBatted
        CricketDismissalContract_nullable Dismissal
        bool IsCaptain
        bool IsWicketkeeper
    }

    CricketDismissalContract {
        CricketDismissalType DismissalType
        ParticipantId_nullable BowlerId FK
        string_nullable BowlerName
        ParticipantId_nullable FielderId FK
        string_nullable FielderName
        string_nullable Description
    }

    CricketBowlerScoreCardContract {
        ParticipantId BowlerId FK
        TeamId_nullable TeamId FK
        string_nullable DisplayName
        int BowlingPosition
        int Overs
        int Balls
        int Maidens
        int DotBalls
        int RunsConceded
        int Wickets
        int Wides
        int NoBalls
        int FoursConceded
        int SixesConceded
        bool IsCaptain
        bool IsBowling
    }

    CricketFallOfWicketContract {
        int WicketNumber
        int TeamScore
        int OverNumber
        int BallNumber
        string OverDisplay
        ParticipantId BatterId FK
        string_nullable BatterName
        string_nullable Description
    }

    CricketBallEventContract {
        int InningsNumber
        int OverNumber
        int RunningOverNumber
        int BallNumber
        int DeliveryNumber
        int SequenceNumber
        int RunsTotal
        int RunsBatter
        int RunsLegByes
        int RunsByes
        int WideRuns
        bool NoBall
        bool IsBoundary
        string_nullable Commentary
        int_nullable ShotX
        int_nullable ShotY
        CricketBallPlayersEventContract Players
        CricketBallWicketEventContract_nullable Wicket
    }

    CricketBallPlayersEventContract {
        ParticipantId BatterIdStriker FK
        ParticipantId_nullable BatterIdNonStriker FK
        ParticipantId BowlerId FK
    }

    CricketBallWicketEventContract {
        CricketDismissalType Type
        ParticipantId BatterId FK
        ParticipantId_nullable FielderId FK
    }

    CricketLineupParticipantContract {
        ParticipantId Id FK
        string_nullable DisplayName
        TeamId TeamId FK
        Position Position
        int PositionOrder
        bool IsCaptain
        bool IsWicketkeeper
        int JumperNumber
        bool IsPlayingXI
    }

    RugbyLeagueScoreCardContract {
        Guid Id PK
        List_RugbyLeagueParticipantStatsEventContract HomeTeamParticipantStats
        List_RugbyLeagueParticipantStatsEventContract AwayTeamParticipantStats
        RugbyLeagueScoreCardTeamsContract Teams
        MatchStatus_nullable MatchStatus
        Dict_ParticipantId_RugbyLeagueLineupParticipantContract Lineup
        Dict_ParticipantId_int SuperCoachPoints
    }

    RugbyLeagueScoreCardTeamsContract {
        RugbyLeagueScoreCardTeamContract_nullable TeamOne
        RugbyLeagueScoreCardTeamContract_nullable TeamTwo
    }

    RugbyLeagueScoreCardTeamContract {
        TeamId TeamId FK
        string_nullable TeamName
        string_nullable TeamCode
    }

    RugbyLeagueParticipantStatsEventContract {
        ParticipantId ParticipantId FK
        string Name
        string Position
        int Number
        TeamId TeamId FK
        int Tries
        string Trend
        int TryAssist
        int TryContribution
        int Goal
        int FieldGoal
        int LineBreak
        int LineBreakAssist
        int EffectiveOffload
        int Offload
        int TackleBust
        int Intercept
        int OffloadToGround
        int OffloadToHand
        int OffloadTurnovers
        int AllRuns
        int AllRunsUnder8mNoLineEng
        int AllRunsUnder8m
        int AllRuns8mAndOverNoLineEng
        int AllRuns8mAndOver
        int LineEngagedRuns
        int Tackle
        int Kicks4020
        int Kicks2040
        int ForcedDropOut
        int MissedTackle
        int MissedGoal
        int MissedFieldGoal
        int PenaltyConceded
        int Error
        int KickDead
        int SinBin
        int SendOff
        int TwoPointFieldGoal
        int TrySaves
        bool OnField
        int MinutesPlayed
    }

    RugbyLeagueLineupParticipantContract {
        ParticipantId Id FK
        string_nullable DisplayName
        TeamId TeamId FK
        Position Position
        int PositionOrder
        bool IsCaptain
        int JumperNumber
    }

    %% ============================================
    %% PROJECTIONS
    %% ============================================

    SportingEventProjectionContract {
        Guid Id PK
        SportingEventId SportingEventId FK
        Sport Sport
        long Version
        ParticipantId_nullable TopParticipantId FK
        string_nullable TopParticipantName
        string_nullable Summary
    }

    RugbyLeagueSportingEventProjectionContract {
        Guid Id PK
        TeamId_nullable ProjectedLineupHomeTeamId FK
        TeamId_nullable ProjectedLineupAwayTeamId FK
        List_RLProjectedLineup ProjectedHomeTeamLineup
        List_RLProjectedLineup ProjectedAwayTeamLineup
        List_RLParticipantProjection ParticipantProjections
    }

    RugbyLeagueProjectedLineupEventContract {
        ParticipantId ParticipantId FK
        string ParticipantName
        int JerseyNumber
        string Position
        bool IsCaptain
    }

    RugbyLeagueParticipantProjectionEventContract {
        ParticipantId ParticipantId FK
        string ParticipantName
        TeamId TeamId FK
        string TeamName
        double ProjectedPoints
        int ProjectedMinutes
        int ProjectedPrice
        int ProjectedPriceDelta
        int ProjectedBreakEven
        double ProjectedOver60Points
        double ProjectedOver100Points
        double Rating
        int PositionOrder
    }

    CricketSportingEventProjectionContract {
        Guid Id PK
        TeamId_nullable ProjectedLineupHomeTeamId FK
        TeamId_nullable ProjectedLineupAwayTeamId FK
        List_CricketProjectedLineup ProjectedHomeTeamLineup
        List_CricketProjectedLineup ProjectedAwayTeamLineup
        List_CricketParticipantProjection ParticipantProjections
        List_CricketWinProbabilityPoint WinProbabilities
    }

    CricketProjectedLineupEventContract {
        ParticipantId ParticipantId FK
        string ParticipantName
        int BattingOrder
        bool IsWicketKeeper
        bool IsCaptain
    }

    CricketParticipantProjectionEventContract {
        ParticipantId ParticipantId FK
        string ParticipantName
        TeamId TeamId FK
        string TeamName
        int BattingOrder
        bool IsWicketKeeper
        double RunsScored
        double BallsFaced
        double StrikeRate
        double StrikeRateQualified
        double FoursScored
        double SixesScored
        double MostRunsTeams
        double MostRunsMatch
        double MostSixesTeams
        double MostSixesMatch
        double HighestStrikeRateTeam
        double HighestStrikeRateMatch
        double OversBowled
        double Wickets
        double RunsConceded
        double Maidens
        double DotBalls
        double Extras
        double Economy
        double EconomyQualified
        double MostWicketsTeam
        double MostWicketsMatch
        double BestEconomyTeam
        double BestEconomyMatch
        double Catches
        double RunOuts
        double Stumpings
        double StrikeRate120Plus
        double StrikeRate130Plus
        double StrikeRate140Plus
        double StrikeRate150Plus
        double StrikeRate160Plus
        double Runs20Plus
        double Runs50Plus
        double Runs100Plus
        double Wickets1Plus
        double Wickets2Plus
        double Wickets3Plus
        double Overs3Plus
        double Economy4OrLess
        double Economy5OrLess
        double Economy6OrLess
        double Economy7OrLess
        double Economy8OrLess
        double SuperCoachPointsTotal
        double SuperCoachPointsBatting
        double SuperCoachPointsBattingBonus
        double SuperCoachPointsBattingTotal
        double SuperCoachPointsBowling
        double SuperCoachPointsBowlingBonus
        double SuperCoachPointsBowlingTotal
        double SuperCoachPointsFielding
        double SuperCoachPointsFieldingBonus
        double SuperCoachPointsFieldingTotal
        double SuperCoachPointsBonusTotal
    }

    CricketWinProbabilityPointContract {
        int Innings
        int Over
        int Ball
        int DeliveryNumber
        double HomeTeamProbability
        double AwayTeamProbability
    }

    %% ============================================
    %% FANTASY STATS - Season
    %% ============================================

    NrlSuperCoachPlayerStatsContract {
        Guid Id PK
        ParticipantId ParticipantId FK
        Guid TeamId FK
        SeasonId_nullable SeasonId FK
        long Version
        string SeasonYear
        string FirstName
        string LastName
        string DisplayName
        string SlugName
        string TeamName
        int Round
        Sport Sport
        string CompetitionType
        List_string Position
        int TotalGamesPlayed
        int CurrentPrice
        int SeasonPriceChange
        int Points
        int Games
        int TotalPoints
        double AveragePoints
        int_nullable RoundScore
        int_nullable LiveScore
        int_nullable BreakEven
        double_nullable ThreeRoundAveragePoints
        double_nullable FiveRoundAveragePoints
        double AverageMinutesPlayed
        double_nullable ThreeRoundAverageMinutesPlayed
        double_nullable FiveRoundAverageMinutesPlayed
        double PointsPerMinute
        double_nullable ThreeRoundPointsPerMinute
        double_nullable FiveRoundPointsPerMinute
        double BaseAverage
        double_nullable ThreeRoundBaseAverage
        double_nullable FiveRoundBaseAverage
        double BasePowerAverage
        double_nullable ThreeRoundBasePowerAverage
        double_nullable FiveRoundBasePowerAverage
        double_nullable Rating
        int_nullable ProjectedPrice
        int_nullable ProjectedBreakEven
        double_nullable ProjectedPoints
        int_nullable ProjectedPriceDelta
        int_nullable ProjectedMinutes
        double_nullable ProjectedOver60Points
        double_nullable ProjectedOver100Points
        double OwnershipPercentage
        double TopOneOwnershipPercentage
        double TopFiveOwnershipPercentage
        double TopTenOwnershipPercentage
        double RoundOwnershipChange
        double TopOneRoundOwnershipChange
        double TopFiveRoundOwnershipChange
        double TopTenRoundOwnershipChange
        double CaptainPercentage
        double TopOneCaptainPercentage
        double TopFiveCaptainPercentage
        double TopTenCaptainPercentage
        double ViceCaptainPercentage
        double TopOneViceCaptainPercentage
        double TopFiveViceCaptainPercentage
        double TopTenViceCaptainPercentage
        int Tries
        int TotalTries
        int TryAssists
        int TotalTryAssists
        int TryContributions
        int TotalTryContributions
        int Goals
        int TotalGoals
        int MissedGoals
        int TotalMissedGoals
        int FieldGoals
        int TotalFieldGoals
        int MissedFieldGoals
        int TotalMissedFieldGoals
        int Tackles
        int TotalTackles
        int MissedTackles
        int TotalMissedTackles
        int TackleBusts
        int TotalTackleBusts
        int ForcedDropOuts
        int TotalForcedDropOuts
        int EffectiveOffloads
        int TotalEffectiveOffloads
        int IneffectiveOffloads
        int TotalIneffectiveOffloads
        int LineBreaks
        int TotalLineBreaks
        int LineBreakAssists
        int TotalLineBreakAssists
        int FortyTwenty
        int TotalFortyTwenty
        int KickRegatherBreak
        int TotalKickRegatherBreak
        int HitupsOver8M
        int TotalHitupsOver8M
        int HitupsUnder8M
        int TotalHitupsUnder8M
        int HoldupsInGoal
        int TotalHoldupsInGoal
        int InterceptsTaken
        int TotalInterceptsTaken
        int DeadKicks
        int TotalDeadKicks
        int Penalties
        int TotalPenalties
        int Errors
        int TotalErrors
        int Sendoffs
        int TotalSendoffs
        Dict_SportingEventProjections SportingEventProjections
    }

    BblSuperCoachPlayerStatsContract {
        Guid Id PK
        ParticipantId ParticipantId FK
        Guid TeamId FK
        long Version
        string SeasonYear
        string FirstName
        string LastName
        string DisplayName
        string SlugName
        string TeamName
        int Round
        Sport Sport
        string CompetitionType
        DataProvider DataSource
        List_string Position
        int TotalGamesPlayed
        int CurrentPrice
        int SeasonPriceChange
        int Points
        int Games
        int TotalPoints
        double AveragePoints
        int_nullable RoundScore
        int_nullable BreakEven
        double_nullable ThreeRoundAveragePoints
        double_nullable FiveRoundAveragePoints
        double OwnershipPercentage
        double TopOneOwnershipPercentage
        double TopFiveOwnershipPercentage
        double TopTenOwnershipPercentage
        double RoundOwnershipChange
        double TopOneRoundOwnershipChange
        double TopFiveRoundOwnershipChange
        double TopTenRoundOwnershipChange
        double CaptainPercentage
        double TopOneCaptainPercentage
        double TopFiveCaptainPercentage
        double TopTenCaptainPercentage
        double ViceCaptainPercentage
        double TopOneViceCaptainPercentage
        double TopFiveViceCaptainPercentage
        double TopTenViceCaptainPercentage
        decimal_nullable ProjectedPoints
        decimal_nullable ProjectedBatting
        decimal_nullable ProjectedBattingBonus
        decimal_nullable ProjectedBowling
        decimal_nullable ProjectedBowlingBonus
        decimal_nullable ProjectedFielding
        decimal_nullable ProjectedFieldingBonus
        decimal_nullable ProjectedBonus
        int Runs
        int TotalRuns
        int RunsBonus
        int TotalRunsBonus
        int Fours
        int TotalFours
        int Wickets
        int TotalWickets
        int WicketsBonus
        int TotalWicketsBonus
        int MaidenOvers
        int TotalMaidenOvers
        int Dotballs
        int TotalDotballs
        int ExtrasConceded
        int TotalExtrasConceded
        int EconomyRate
        int TotalEconomyRate
        int Catches
        int TotalCatches
        int Runouts
        int TotalRunouts
        int Stumpings
        int TotalStumpings
        Dict_SportingEventProjections SportingEventProjections
    }

    %% ============================================
    %% FANTASY STATS - Match
    %% ============================================

    SuperCoachParticipantMatchStatsContract {
        Guid Id PK
        SportingEventId SportingEventId FK
        ParticipantId ParticipantId FK
        Sport Sport
        string FullName
        TeamId TeamId FK
        string TeamName
        string TeamCode
        DateTimeOffset LastUpdated
        long Version
    }

    NrlSuperCoachParticipantMatchStatsContract {
        Guid Id PK
        int MinutesPlayed
        int Tries
        int TryAssists
        int TryContributions
        int Goals
        int MissedGoals
        int FieldGoals
        int MissedFieldGoals
        int Tackles
        int MissedTackles
        int TackleBusts
        int ForcedDropOuts
        int EffectiveOffloads
        int Offloads
        int LineBreaks
        int LineBreakAssists
        int FortyTwenty
        int TwentyForty
        int KickRegatherBreak
        int HitupsOver8M
        int HitupsUnder8M
        int HoldupsInGoal
        int InterceptsTaken
        int DeadKicks
        int Penalties
        int Errors
        int Sendoffs
        int SinBins
        int TwoPointFieldGoals
        int TrySaves
        double SuperCoachPoints
        int AllRuns
        int AllRunsUnder8m
        int AllRunsUnder8mNoLineEng
        int AllRuns8mAndOver
        int AllRuns8mAndOverNoLineEng
        int LineEngagedRuns
        int OffloadToGround
        int OffloadToHand
        int OffloadTurnovers
    }

    CricketSuperCoachParticipantMatchStatsContract {
        Guid Id PK
        int Runs
        int BallsFaced
        int Fours
        int Sixes
        int OversBowled
        int BallsBowled
        int RunsConceded
        int Wickets
        int MaidenOvers
        int DotBalls
        int NoBalls
        int Wides
        int Catches
        int RunOuts
        int Stumpings
    }

    %% ============================================
    %% PLAYER PROFILES
    %% ============================================

    SuperCoachParticipantProfileDetailContract {
        Guid Id PK
        string DisplayName
        string TeamName
        TeamId TeamId FK
        string Position
        string Summary
        Sport Sport
        string Slug
        string Price
        Dict_Statistic_string KeyStats
        List_SuperCoachCompletedStatsContract CompletedEvents
        List_SuperCoachPlayerUpcomingEventContract UpcomingEvents
        string CompetitionType
    }

    SuperCoachCompletedStatsContract {
        Guid Id PK
        string Round
        string SeasonYear
        int Points
        string Opponent
        VenueClassification VenueClassification
        EventOutcome Outcome
        string Venue
        Dict_Statistic_string MatchStats
    }

    SuperCoachPlayerUpcomingEventContract {
        Guid Id PK
        string Round
        string SeasonYear
        double ProjectedPoints
        string Opponent
        VenueClassification VenueClassification
        DateTimeOffset_nullable SportingEventStartTime
        string Venue
    }

    %% ============================================
    %% RELATIONSHIPS
    %% ============================================

    %% Core Sport Hierarchy
    CompetitionContract ||--o{ SeasonContract : "has seasons"
    SeasonContract ||--o{ SportingEventContract : "has events"
    CompetitionContract ||--o{ SportingEventContract : "owns events"

    %% Season nested types
    SeasonContract ||--o{ SeasonGroup : "has groups"
    SeasonContract ||--o{ PoolNode : "has pool nodes"
    SeasonContract ||--o{ PoolDefinition : "has pool rules"
    PoolNode ||--o| PoolNode : "parent pool"

    %% Injuries (Tier-4 People)
    ParticipantContract ||--o{ InjuryContract : "has injuries"
    SeasonContract ||--o{ InjuryContract : "season injuries"

    %% Squads
    TeamContract ||--o{ SquadContract : "has squads"
    SeasonContract ||--o{ SquadContract : "season squads"
    SquadContract ||--o{ SquadMemberContract : "has members"
    SquadContract ||--o{ SquadTierCount : "tier breakdown"
    SquadMemberContract }o--|| ParticipantContract : "participant"

    %% SportingEvent nested types
    SportingEventContract ||--|| SportingEventTeamsEventContract : "has teams"
    SportingEventTeamsEventContract ||--|| SportEventTeamContract : "home/away"

    %% Lineup (per-game selected squad)
    LineupContract ||--o{ LineupTeamContract : "has teams"
    LineupTeamContract ||--o{ LineupMemberContract : "has members"
    SportingEventContract ||--|| VenueSummaryContract : "has venue"

    %% SportingEvent references
    SportEventTeamContract }o--|| TeamContract : "references team"

    %% SportingEvent children (1:1)
    SportingEventContract ||--o| WeatherContract : "has weather"
    SportingEventContract ||--o| ScoreBoardContract : "has scoreboard"
    SportingEventContract ||--o| ScoreCardContract : "has scorecard"
    SportingEventContract ||--o| SportingEventProjectionContract : "has projection"

    %% Scoreboard inheritance
    ScoreBoardContract ||--o| RugbyLeagueScoreBoardContract : "extends"
    ScoreBoardContract ||--o| CricketScoreBoardContract : "extends"

    %% Rugby League Scoreboard nested types
    RugbyLeagueScoreBoardContract ||--o{ RugbyLeaguePeriodContract : "has periods"
    RugbyLeagueScoreBoardContract ||--o| MatchTimeContract : "has match time"
    MatchTimeContract ||--|| MatchClockEventContract : "has clock"
    MatchTimeContract ||--o{ MatchClockPeriodEventContract : "has period clocks"
    MatchClockPeriodEventContract ||--o| MatchClockEventContract : "has clock"

    %% Cricket Scoreboard nested types
    CricketScoreBoardContract ||--o{ CricketInningsContract : "has innings"
    CricketScoreBoardContract ||--o| CricketTossContract : "has toss"
    CricketTossContract }o--o| TeamContract : "toss winner"

    %% ScoreCard inheritance
    ScoreCardContract ||--o| CricketScoreCardContract : "extends"
    ScoreCardContract ||--o| RugbyLeagueScoreCardContract : "extends"

    %% Cricket ScoreCard nested types
    CricketScoreCardContract ||--|| CricketScoreCardTeamsContract : "has teams"
    CricketScoreCardTeamsContract ||--o| CricketScoreCardTeamContract : "team one/two"
    CricketScoreCardTeamContract }o--|| TeamContract : "references team"
    CricketScoreCardContract ||--o{ CricketInningsScoreCardContract : "has innings"
    CricketScoreCardContract ||--o{ CricketLineupParticipantContract : "has lineup"
    CricketInningsScoreCardContract ||--o| CricketExtrasContract : "has extras"
    CricketInningsScoreCardContract ||--o{ CricketBatterScoreCardContract : "has batters"
    CricketInningsScoreCardContract ||--o{ CricketBowlerScoreCardContract : "has bowlers"
    CricketInningsScoreCardContract ||--o{ CricketFallOfWicketContract : "has fall of wickets"
    CricketInningsScoreCardContract ||--o{ CricketBallEventContract : "has ball events"
    CricketBatterScoreCardContract ||--o| CricketDismissalContract : "has dismissal"
    CricketBatterScoreCardContract }o--|| ParticipantContract : "batter"
    CricketBowlerScoreCardContract }o--|| ParticipantContract : "bowler"
    CricketBallEventContract ||--|| CricketBallPlayersEventContract : "has players"
    CricketBallEventContract ||--o| CricketBallWicketEventContract : "has wicket"
    CricketLineupParticipantContract }o--|| ParticipantContract : "participant"

    %% Rugby League ScoreCard nested types
    RugbyLeagueScoreCardContract ||--|| RugbyLeagueScoreCardTeamsContract : "has teams"
    RugbyLeagueScoreCardTeamsContract ||--o| RugbyLeagueScoreCardTeamContract : "team one/two"
    RugbyLeagueScoreCardTeamContract }o--|| TeamContract : "references team"
    RugbyLeagueScoreCardContract ||--o{ RugbyLeagueParticipantStatsEventContract : "has player stats"
    RugbyLeagueScoreCardContract ||--o{ RugbyLeagueLineupParticipantContract : "has lineup"
    RugbyLeagueParticipantStatsEventContract }o--|| ParticipantContract : "participant"
    RugbyLeagueLineupParticipantContract }o--|| ParticipantContract : "participant"

    %% Projection inheritance
    SportingEventProjectionContract ||--o| RugbyLeagueSportingEventProjectionContract : "extends"
    SportingEventProjectionContract ||--o| CricketSportingEventProjectionContract : "extends"

    %% Projection references
    SportingEventProjectionContract }o--o| ParticipantContract : "top participant"

    %% Rugby League Projection nested types
    RugbyLeagueSportingEventProjectionContract ||--o{ RugbyLeagueProjectedLineupEventContract : "has lineup"
    RugbyLeagueSportingEventProjectionContract ||--o{ RugbyLeagueParticipantProjectionEventContract : "has projections"
    RugbyLeagueProjectedLineupEventContract }o--|| ParticipantContract : "participant"
    RugbyLeagueParticipantProjectionEventContract }o--|| ParticipantContract : "participant"
    RugbyLeagueParticipantProjectionEventContract }o--|| TeamContract : "team"

    %% Cricket Projection nested types
    CricketSportingEventProjectionContract ||--o{ CricketProjectedLineupEventContract : "has lineup"
    CricketSportingEventProjectionContract ||--o{ CricketParticipantProjectionEventContract : "has projections"
    CricketSportingEventProjectionContract ||--o{ CricketWinProbabilityPointContract : "has win probabilities"
    CricketProjectedLineupEventContract }o--|| ParticipantContract : "participant"
    CricketParticipantProjectionEventContract }o--|| ParticipantContract : "participant"
    CricketParticipantProjectionEventContract }o--|| TeamContract : "team"

    %% Match Stats inheritance
    SuperCoachParticipantMatchStatsContract ||--o| NrlSuperCoachParticipantMatchStatsContract : "extends"
    SuperCoachParticipantMatchStatsContract ||--o| CricketSuperCoachParticipantMatchStatsContract : "extends"

    %% Match Stats references
    SportingEventContract ||--o{ SuperCoachParticipantMatchStatsContract : "match stats"
    ParticipantContract ||--o{ SuperCoachParticipantMatchStatsContract : "player stats"
    TeamContract ||--o{ SuperCoachParticipantMatchStatsContract : "team"

    %% Season Player Stats
    ParticipantContract ||--o{ NrlSuperCoachPlayerStatsContract : "NRL season stats"
    ParticipantContract ||--o{ BblSuperCoachPlayerStatsContract : "BBL season stats"
    TeamContract ||--o{ NrlSuperCoachPlayerStatsContract : "current team"
    TeamContract ||--o{ BblSuperCoachPlayerStatsContract : "current team"
    SeasonContract ||--o{ NrlSuperCoachPlayerStatsContract : "season"

    %% Player Profile references
    SuperCoachParticipantProfileDetailContract }o--|| TeamContract : "current team"
    SuperCoachParticipantProfileDetailContract ||--o{ SuperCoachCompletedStatsContract : "completed events"
    SuperCoachParticipantProfileDetailContract ||--o{ SuperCoachPlayerUpcomingEventContract : "upcoming events"

Context Boundaries

block-beta
    columns 3

    block:core_sport["Core Sport"]:2
        CompetitionContract
        SeasonContract
        TeamContract
        ParticipantContract
        SportingEventContract
        SquadContract
    end

    block:scoreboard["Scoreboards"]:1
        ScoreBoardContract
        RugbyLeagueScoreBoardContract2["RugbyLeague ScoreBoard"]
        CricketScoreBoardContract2["Cricket ScoreBoard"]
    end

    block:scorecard["ScoreCards"]:2
        ScoreCardContract
        CricketScoreCardContract2["Cricket ScoreCard"]
        RugbyLeagueScoreCardContract2["RugbyLeague ScoreCard"]
    end

    block:projections["Projections"]:1
        SportingEventProjectionContract
        RugbyLeagueProjection["RugbyLeague Projection"]
        CricketProjection["Cricket Projection"]
    end

    block:season_stats["Fantasy Season Stats"]:2
        NrlSuperCoachPlayerStatsContract
        BblSuperCoachPlayerStatsContract
    end

    block:match_stats["Fantasy Match Stats"]:1
        SuperCoachParticipantMatchStats["Match Stats Base"]
        NrlMatchStats["NRL Match Stats"]
        CricketMatchStats["Cricket Match Stats"]
    end

    block:profiles["Player Profiles"]:3
        SuperCoachParticipantProfileDetailContract
    end

Aggregate-to-Projection Mapping (Foundry Contracts)

Aggregate Projection Builder Output Contract Foundry Registered
CompetitionAggregate CompetitionContractBuilder CompetitionContract Yes
SeasonAggregate SeasonContractBuilder SeasonContract Yes
TeamAggregate TeamContractBuilder TeamContract Yes
ParticipantAggregate ParticipantContractBuilder ParticipantContract Yes
SportingEventAggregate SportingEventContractBuilder SportingEventContract Yes
SquadAggregate SquadContractBuilder SquadContract No
ScoreBoardAggregate ScoreBoardContractBuilder ScoreBoardContract (polymorphic: RL + Cricket) Yes
ScoreBoardAggregate RugbyLeagueScoreCardContractBuilder RugbyLeagueScoreCardContract Yes
ScoreBoardAggregate CricketScoreCardContractBuilder CricketScoreCardContract Yes
SportingEventProjectionsAggregate SportingEventProjectionsContractBuilder SportingEventProjectionContract (polymorphic: RL + Cricket) Yes
SuperCoachParticipantStatsAggregate NrlSuperCoachParticipantStatsContractBuilder NrlSuperCoachPlayerStatsContract Yes
SuperCoachParticipantStatsAggregate BblSuperCoachParticipantStatsContractBuilder BblSuperCoachPlayerStatsContract Yes
SuperCoachParticipantStatsAggregate NrlSuperCoachParticipantMatchStatsContractBuilder NrlSuperCoachParticipantMatchStatsContract Yes (via base)
SuperCoachParticipantStatsAggregate CricketSuperCoachParticipantMatchStatsContractBuilder CricketSuperCoachParticipantMatchStatsContract Yes
SuperCoachParticipantStatsAggregate SuperCoachParticipantProfileDetailContractBuilder SuperCoachParticipantProfileDetailContract Yes

Notes

Contracts NOT in Foundry (Main/Ballr Database Only)

The following contracts are registered in their own Marten modules for the main event store database, not the Foundry read model store:

Contract Marten Module Database
UserContract UserMartenModule Main
VenueContract SportDomainCoreMartenConfigurationModule Main
InjuryContract SportDomainCoreMartenConfigurationModule Main
WeatherContract SportDomainCoreMartenConfigurationModule Main
SquadContract SportDomainCoreMartenConfigurationModule Main
ImportJobContract ImportMartenModule Main
ChatSessionContract ChatMartenModule Main
SupercoachTeamContract BallrContestsMartenModule Main (Ballr)

Indexes (Foundry Database)

Configured in FoundryReadModelConfiguration:

Contract Indexed Fields
SportingEventContract StartTimeUtc, SeasonId, CompetitionId, Sport, Slug, IsArchived
NrlSuperCoachPlayerStatsContract ParticipantId
BblSuperCoachPlayerStatsContract ParticipantId

Subclass Hierarchies (Marten Polymorphism)

Base Contract Registered Subclasses
ScoreBoardContract CricketScoreBoardContract, RugbyLeagueScoreBoardContract
ScoreCardContract CricketScoreCardContract, RugbyLeagueScoreCardContract
SportingEventProjectionContract CricketSportingEventProjectionContract, RugbyLeagueSportingEventProjectionContract
SuperCoachParticipantMatchStatsContract CricketSuperCoachParticipantMatchStatsContract