# haugstrup/tournamentutils architecture

> Architecture diagram of the GitHub repository haugstrup/tournamentutils, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/haugstrup/tournamentutils
- Repository: https://github.com/haugstrup/tournamentutils

## Overview

Tournament Utilities is a PHP library for match-play tournament preparation. Callers provide seeded players, prior-opponent or arena history, and tournament options; the relevant utility returns pairings, groups, arena assignments, or bracket data. Separate capabilities include Swiss pairing, round-robin play, rating calculation, and arena selection. The graph shows documented utility behavior and source-indexed dependencies; unsampled implementation details are not inferred.

Main entry points: [`src/Base.php`](https://github.com/haugstrup/tournamentutils/blob/master/src/Base.php) (Base helpers), [`src/RandomOptimizer.php`](https://github.com/haugstrup/tournamentutils/blob/master/src/RandomOptimizer.php) (Random optimizer), [`src/HeadToHeadStrictSwissPairing.php`](https://github.com/haugstrup/tournamentutils/blob/master/src/HeadToHeadStrictSwissPairing.php) (Strict Swiss), [`src/AdjacentPairing.php`](https://github.com/haugstrup/tournamentutils/blob/master/src/AdjacentPairing.php) (Adjacent pairing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pairing["Pairing systems"]
  node_adjacent["Adjacent pairing"]
  node_cross["Cross pairing<br/>[CrossPairing.php]"]
  node_slaughter["Slaughter pairing"]
  node_roundrobin["Round robin"]
  node_swiss["Head-to-head Swiss"]
  node_strict_swiss["Strict Swiss"]
  node_tiered_swiss["Tiered Swiss"]
end

subgraph group_optimization["Balanced optimization"]
  node_balanced_pair["Balanced pairing"]
  node_greedy_pair["Greedy pairing"]
  node_arena["Arena assignment<br/>[BalancedArena.php]"]
  node_greedy_arena["Greedy arena"]
  node_player_arena["Player arena pairing"]
  node_player_order["Balanced player order"]
  node_optimizer["Random optimizer"]
end

subgraph group_tournament["Tournament tools"]
  node_arena_selector["Arena selector<br/>[ArenaSelector.php]"]
  node_bracket["Elimination bracket"]
  node_glicko["Glicko calculator"]
  node_golf["Golf hole utility<br/>[GolfHole.php]"]
  node_wcs["WCS groups<br/>[WCSGroups.php]"]
end

subgraph group_foundation["Shared foundation"]
  node_matching["Maximum matching"]
  node_base["Base helpers<br/>[Base.php]"]
end

node_caller(("Library caller"))

node_caller -->|"pairs seeds"| node_adjacent
node_caller -->|"pairs seeds"| node_cross
node_caller -->|"pairs seeds"| node_slaughter
node_caller -->|"generates rounds"| node_roundrobin
node_caller -->|"pairs groups"| node_swiss
node_caller -.->|"requests pairings"| node_strict_swiss
node_caller -->|"generates groups"| node_tiered_swiss
node_caller -->|"balances opponents"| node_balanced_pair
node_caller -.->|"requests pairings"| node_greedy_pair
node_caller -->|"balances arenas"| node_arena
node_caller -.->|"requests assignments"| node_greedy_arena
node_caller -.->|"requests assignments"| node_player_arena
node_caller -.->|"requests ordering"| node_player_order
node_caller -->|"selects arena"| node_arena_selector
node_caller -->|"builds bracket"| node_bracket
node_caller -->|"calculates ratings"| node_glicko
node_caller -.->|"uses utility"| node_golf
node_caller -.->|"uses utility"| node_wcs
node_adjacent -->|"extends"| node_base
node_cross -->|"extends"| node_base
node_slaughter -->|"extends"| node_base
node_roundrobin -->|"extends"| node_base
node_swiss -->|"extends"| node_base
node_strict_swiss -->|"extends"| node_base
node_strict_swiss -->|"computes matching"| node_matching
node_tiered_swiss -->|"extends"| node_base
node_balanced_pair -->|"extends"| node_optimizer
node_greedy_pair -->|"extends"| node_optimizer
node_arena -->|"extends"| node_optimizer
node_greedy_arena -->|"extends"| node_optimizer
node_player_arena -->|"extends"| node_optimizer
node_player_order -->|"extends"| node_optimizer
node_optimizer -->|"extends"| node_base
node_arena_selector -->|"extends"| node_base
node_bracket -->|"extends"| node_base
node_wcs -->|"extends"| node_base

click node_adjacent "https://github.com/haugstrup/tournamentutils/blob/master/src/AdjacentPairing.php"
click node_cross "https://github.com/haugstrup/tournamentutils/blob/master/src/CrossPairing.php"
click node_slaughter "https://github.com/haugstrup/tournamentutils/blob/master/src/SlaughterPairing.php"
click node_roundrobin "https://github.com/haugstrup/tournamentutils/blob/master/src/RoundRobinPairing.php"
click node_swiss "https://github.com/haugstrup/tournamentutils/blob/master/src/HeadToHeadSwissPairing.php"
click node_strict_swiss "https://github.com/haugstrup/tournamentutils/blob/master/src/HeadToHeadStrictSwissPairing.php"
click node_tiered_swiss "https://github.com/haugstrup/tournamentutils/blob/master/src/GroupTieredSwissPairing.php"
click node_balanced_pair "https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedPairing.php"
click node_greedy_pair "https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedGreedyPairing.php"
click node_arena "https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedArena.php"
click node_greedy_arena "https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedGreedyArena.php"
click node_player_arena "https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedPlayerArenaPairing.php"
click node_player_order "https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedPlayerOrder.php"
click node_optimizer "https://github.com/haugstrup/tournamentutils/blob/master/src/RandomOptimizer.php"
click node_arena_selector "https://github.com/haugstrup/tournamentutils/blob/master/src/ArenaSelector.php"
click node_bracket "https://github.com/haugstrup/tournamentutils/blob/master/src/SingleEliminationBracket.php"
click node_glicko "https://github.com/haugstrup/tournamentutils/blob/master/src/GlickoCalculator.php"
click node_golf "https://github.com/haugstrup/tournamentutils/blob/master/src/GolfHole.php"
click node_wcs "https://github.com/haugstrup/tournamentutils/blob/master/src/WCSGroups.php"
click node_matching "https://github.com/haugstrup/tournamentutils/blob/master/src/MaxWeightMatching.php"
click node_base "https://github.com/haugstrup/tournamentutils/blob/master/src/Base.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_adjacent,node_cross,node_slaughter,node_roundrobin,node_swiss,node_strict_swiss,node_tiered_swiss toneBlue
class node_balanced_pair,node_greedy_pair,node_arena,node_greedy_arena,node_player_arena,node_player_order,node_optimizer toneAmber
class node_arena_selector,node_bracket,node_glicko,node_golf,node_wcs toneMint
class node_matching,node_base toneRose
class node_caller toneIndigo
```

## Components

### Pairing systems

- [Adjacent pairing](https://github.com/haugstrup/tournamentutils/blob/master/src/AdjacentPairing.php): `src/AdjacentPairing.php`
- [Cross pairing](https://github.com/haugstrup/tournamentutils/blob/master/src/CrossPairing.php): `src/CrossPairing.php`
- [Slaughter pairing](https://github.com/haugstrup/tournamentutils/blob/master/src/SlaughterPairing.php): `src/SlaughterPairing.php`
- [Round robin](https://github.com/haugstrup/tournamentutils/blob/master/src/RoundRobinPairing.php): `src/RoundRobinPairing.php`
- [Head-to-head Swiss](https://github.com/haugstrup/tournamentutils/blob/master/src/HeadToHeadSwissPairing.php): `src/HeadToHeadSwissPairing.php`
- [Strict Swiss](https://github.com/haugstrup/tournamentutils/blob/master/src/HeadToHeadStrictSwissPairing.php): `src/HeadToHeadStrictSwissPairing.php`
- [Tiered Swiss](https://github.com/haugstrup/tournamentutils/blob/master/src/GroupTieredSwissPairing.php): `src/GroupTieredSwissPairing.php`

### Balanced optimization

- [Balanced pairing](https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedPairing.php): `src/BalancedPairing.php`
- [Greedy pairing](https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedGreedyPairing.php): `src/BalancedGreedyPairing.php`
- [Arena assignment](https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedArena.php): `src/BalancedArena.php`
- [Greedy arena](https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedGreedyArena.php): `src/BalancedGreedyArena.php`
- [Player arena pairing](https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedPlayerArenaPairing.php): `src/BalancedPlayerArenaPairing.php`
- [Balanced player order](https://github.com/haugstrup/tournamentutils/blob/master/src/BalancedPlayerOrder.php): `src/BalancedPlayerOrder.php`
- [Random optimizer](https://github.com/haugstrup/tournamentutils/blob/master/src/RandomOptimizer.php): `src/RandomOptimizer.php`

### Tournament tools

- [Arena selector](https://github.com/haugstrup/tournamentutils/blob/master/src/ArenaSelector.php): `src/ArenaSelector.php`
- [Elimination bracket](https://github.com/haugstrup/tournamentutils/blob/master/src/SingleEliminationBracket.php): `src/SingleEliminationBracket.php`
- [Glicko calculator](https://github.com/haugstrup/tournamentutils/blob/master/src/GlickoCalculator.php): `src/GlickoCalculator.php`
- [Golf hole utility](https://github.com/haugstrup/tournamentutils/blob/master/src/GolfHole.php): `src/GolfHole.php`
- [WCS groups](https://github.com/haugstrup/tournamentutils/blob/master/src/WCSGroups.php): `src/WCSGroups.php`

### Shared foundation

- [Maximum matching](https://github.com/haugstrup/tournamentutils/blob/master/src/MaxWeightMatching.php): `src/MaxWeightMatching.php`
- [Base helpers](https://github.com/haugstrup/tournamentutils/blob/master/src/Base.php): `src/Base.php`

### Other components

- **Library caller**

## Connections

- Library caller → Adjacent pairing: pairs seeds (evidence: `README.md`)
- Library caller → Cross pairing: pairs seeds (evidence: `README.md`)
- Library caller → Slaughter pairing: pairs seeds (evidence: `README.md`)
- Library caller → Round robin: generates rounds (evidence: `README.md`)
- Library caller → Head-to-head Swiss: pairs groups (evidence: `README.md`)
- Library caller → Strict Swiss: requests pairings
- Library caller → Tiered Swiss: generates groups (evidence: `README.md`)
- Library caller → Balanced pairing: balances opponents (evidence: `README.md`)
- Library caller → Greedy pairing: requests pairings
- Library caller → Arena assignment: balances arenas (evidence: `README.md`)
- Library caller → Greedy arena: requests assignments
- Library caller → Player arena pairing: requests assignments
- Library caller → Balanced player order: requests ordering
- Library caller → Arena selector: selects arena (evidence: `README.md`)
- Library caller → Elimination bracket: builds bracket (evidence: `README.md`)
- Library caller → Glicko calculator: calculates ratings (evidence: `README.md`)
- Library caller → Golf hole utility: uses utility
- Library caller → WCS groups: uses utility
- Adjacent pairing → Base helpers: extends (evidence: `src/AdjacentPairing.php`)
- Cross pairing → Base helpers: extends (evidence: `src/CrossPairing.php`)
- Slaughter pairing → Base helpers: extends (evidence: `src/SlaughterPairing.php`)
- Round robin → Base helpers: extends (evidence: `src/RoundRobinPairing.php`)
- Head-to-head Swiss → Base helpers: extends (evidence: `src/HeadToHeadSwissPairing.php`)
- Strict Swiss → Base helpers: extends (evidence: `src/HeadToHeadStrictSwissPairing.php`)
- Strict Swiss → Maximum matching: computes matching (evidence: `src/HeadToHeadStrictSwissPairing.php`)
- Tiered Swiss → Base helpers: extends (evidence: `src/GroupTieredSwissPairing.php`)
- Balanced pairing → Random optimizer: extends (evidence: `src/BalancedPairing.php`)
- Greedy pairing → Random optimizer: extends (evidence: `src/BalancedGreedyPairing.php`)
- Arena assignment → Random optimizer: extends (evidence: `src/BalancedArena.php`)
- Greedy arena → Random optimizer: extends (evidence: `src/BalancedGreedyArena.php`)
- Player arena pairing → Random optimizer: extends (evidence: `src/BalancedPlayerArenaPairing.php`)
- Balanced player order → Random optimizer: extends (evidence: `src/BalancedPlayerOrder.php`)
- Random optimizer → Base helpers: extends (evidence: `src/RandomOptimizer.php`)
- Arena selector → Base helpers: extends (evidence: `src/ArenaSelector.php`)
- Elimination bracket → Base helpers: extends (evidence: `src/SingleEliminationBracket.php`)
- WCS groups → Base helpers: extends (evidence: `src/WCSGroups.php`)
