Skip to main content

Tournaments & Competitions

End-to-end competition management for golf clubs: create competitions, manage entries, score rounds, calculate handicaps, and publish results.

Module overview

  • Package: @digiwedge/tee-time-servicesTournamentsModule
  • Persistence: @prisma/teetime (shared with core tee-time data)
  • Env: TEETIME_DATABASE_URL (if unset, tournaments features are disabled gracefully)

Feature summary


Key services

ServicePurpose
CompetitionsServiceCreate/update competitions, manage rounds, divisions, local rules
EntriesServicePlayer entries, team members, withdrawals
ScorecardsServiceHole-by-hole scoring, attestation, locking
ResultsServiceLeaderboards, position assignment, finalization
DrawsServiceGenerate pairings (random, handicap order, seeded)
HandicapSnapshotServiceCapture handicap index at entry time
HandicapPostingServicePost scores to GolfRSA/DotGolf
SeriesServiceOrder of Merit standings across events
SideCompetitionsServiceNearest pin, longest drive
MatchplayServiceBracket generation, seeding, match scoring
PrizeServicePrize allocation and descriptions
AppealsServiceOpen/update/resolve result appeals
ResultsExportServiceCSV leaderboard exports
CompetitionTeeSheetSyncServiceSync tee-sheet bookings to entries

Competition lifecycle

┌─────────────┐    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│ CREATE │───▶│ ENTRIES │───▶│ DRAW │───▶│ SCORING │
│ Competition │ │ Open │ │ Generated │ │ In Progress│
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘

┌─────────────┐ ┌─────────────┐ │
│ COMPLETED │◀───│ FINALIZE │◀──────────┘
│ Results │ │ Results │
└─────────────┘ └─────────────┘
  1. Create - Set up competition with format, rounds, divisions
  2. Entries - Players enter, handicap snapshots captured
  3. Draw - Generate pairings and tee times
  4. Scoring - Hole-by-hole score entry, attestation
  5. Finalize - Lock results, assign positions, post handicaps
  6. Complete - Results published, events emitted

Data model

EntityPurpose
CompetitionMain competition record
CompetitionRoundIndividual rounds with course/date
CompetitionDivisionHandicap/age/gender divisions
CompetitionEntryPlayer entries
CompetitionTeamMemberTeam member assignments
ScorecardRound scorecards
HoleScoreIndividual hole scores
HandicapSnapshotCaptured handicap at entry
CompetitionResultFinal positions
SideCompetitionResultNTP/LD results
MatchplayBracketMatchplay brackets
MatchplayMatchIndividual matches
DailyCourseConditionsPCC storage
SeasonSeason grouping

Quick start

Import the module

import { TournamentsModule } from '@digiwedge/tee-time-services';

@Module({
imports: [TournamentsModule],
})
export class AppModule {}

Create a competition

const competition = await competitionsService.create({
clubId: 'club-123',
name: 'Monthly Medal',
format: 'STABLEFORD',
isHandicapQualifying: true,
handicapAllowance: 100,
rounds: [{
roundNumber: 1,
date: new Date('2025-12-15'),
courseId: 'course-123',
startType: 'TEE_TIMES',
}],
divisions: [
{ name: 'A Division', maxHandicap: 12 },
{ name: 'B Division', minHandicap: 13, maxHandicap: 24 },
],
});

Environment

VariableRequiredDescription
TEETIME_DATABASE_URLYesPrisma datasource for tournaments data
GolfRSA credentialsOptionalFor handicap posting to GolfRSA
DotGolf credentialsOptionalFor handicap posting to DotGolf

Testing

# Unit tests
pnpm nx test tee-time-services --testPathPattern=tournaments

# All tee-time-services tests
pnpm nx test tee-time-services --runInBand

Test coverage includes:

  • Stableford calculations
  • Countback tie resolution
  • Handicap helpers (course handicap, PCC, CSS)
  • Eligibility and division gates
  • Appeals workflow
  • Results and 2's club

Backend deep dive

For service‑level responsibilities, domain events, and operational guidance, see ./backend.md.