# 1fini/tennisscoresapi architecture

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

- Interactive diagram: https://gitdiagram.com/1fini/tennisscoresapi
- Repository: https://github.com/1fini/tennisscoresapi

## Overview

TennisScoresAPI is the backend for tennis match scoring and tournament administration. Users and the companion WebApp create tournaments, players, match formats, and matches through REST endpoints; courtside scoring submits points, which are checked by the scoring engine, projected onto match state, persisted with match events, and broadcast to live-score subscribers. Match retrieval and analytics expose results. The graph reflects sampled controller, service, scoring, persistence, and startup code; several documented CRUD and format-service links are not shown where their implementations were not sampled.

Main entry points: [`TennisScores.API/Services/LiveScoreService.cs`](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/LiveScoreService.cs) (Point and undo), [`TennisScores.API/Program.cs`](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Program.cs) (ASP.NET API), [`TennisScores.Infrastructure/Data/TennisDbContext.cs`](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Infrastructure/Data/TennisDbContext.cs) (EF data context), [`TennisScores.API/Services/MatchService.cs`](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/MatchService.cs) (Match lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API workflows"]
  node_api_runtime["ASP.NET API<br/>[Program.cs]"]
  node_matches_controller["Match endpoints"]
  node_live_controller["Live-score endpoints"]
  node_players_controller["Player endpoints"]
  node_tournaments_controller["Tournament endpoints"]
  node_formats_controller["Format endpoints"]
  node_match_service["Match lifecycle<br/>[MatchService.cs]"]
  node_live_service["Point and undo"]
  node_player_service["Player management<br/>[PlayerService.cs]"]
  node_tournament_service["Tournament management"]
  node_format_service["Match formats"]
end

subgraph group_domain["Scoring domain"]
  node_scoring_engine["Scoring rules<br/>[ScoringEngine.cs]"]
  node_scoring_state["Scoring state and replay<br/>[ScoringReplay.cs]"]
  node_match_model["Match model<br/>[Match.cs]"]
end

subgraph group_storage["Persistence"]
  node_match_repository["Match repository<br/>[MatchRepository.cs]"]
  node_domain_repositories["Domain repositories"]
  node_data_context["EF data context<br/>[TennisDbContext.cs]"]
  node_unit_of_work["Unit of work<br/>[UnitOfWork.cs]"]
  node_event_repository["Match event journal"]
end

subgraph group_realtime["Live updates"]
  node_score_hub["SignalR score hub<br/>[ScoreHub.cs]"]
  node_score_extensions["Score broadcast"]
end

node_webapp(("WebApp users"))
node_postgres[("PostgreSQL")]
node_subscribers(("Live subscribers"))

node_webapp -->|"calls REST"| node_api_runtime
node_api_runtime -->|"routes requests"| node_matches_controller
node_api_runtime -->|"routes requests"| node_live_controller
node_api_runtime -->|"routes requests"| node_players_controller
node_api_runtime -->|"routes requests"| node_tournaments_controller
node_api_runtime -->|"routes requests"| node_formats_controller
node_matches_controller -->|"delegates"| node_match_service
node_live_controller -->|"delegates"| node_live_service
node_players_controller -->|"delegates"| node_player_service
node_tournaments_controller -->|"delegates"| node_tournament_service
node_formats_controller -->|"delegates"| node_format_service
node_match_service -->|"reads and writes"| node_domain_repositories
node_match_service -->|"commits changes"| node_unit_of_work
node_match_service -->|"calculates analytics"| node_scoring_state
node_live_service -->|"loads match"| node_match_repository
node_live_service -->|"applies point"| node_scoring_engine
node_live_service -->|"replays undo"| node_scoring_state
node_live_service -->|"projects score"| node_domain_repositories
node_live_service -->|"appends events"| node_event_repository
node_live_service -->|"commits changes"| node_unit_of_work
node_live_service -->|"broadcasts update"| node_score_extensions
node_match_repository -->|"queries matches"| node_data_context
node_domain_repositories -->|"accesses data"| node_data_context
node_event_repository -->|"stores events"| node_data_context
node_unit_of_work -->|"saves changes"| node_data_context
node_data_context -->|"reads and writes"| node_postgres
node_score_extensions -->|"dispatches update"| node_score_hub
node_score_hub -->|"sends live score"| node_subscribers

click node_api_runtime "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Program.cs"
click node_matches_controller "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Controllers/MatchesController.cs"
click node_live_controller "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Controllers/LiveScoreController.cs"
click node_players_controller "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Controllers/PlayersController.cs"
click node_tournaments_controller "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Controllers/TournamentsController.cs"
click node_formats_controller "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Controllers/MatchFormatsController.cs"
click node_match_service "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/MatchService.cs"
click node_live_service "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/LiveScoreService.cs"
click node_player_service "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/PlayerService.cs"
click node_tournament_service "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/TournamentService.cs"
click node_format_service "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/MatchFormatService.cs"
click node_scoring_engine "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Domain/Scoring/ScoringEngine.cs"
click node_scoring_state "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Domain/Scoring/ScoringReplay.cs"
click node_match_model "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Domain/Entities/Match.cs"
click node_match_repository "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Infrastructure/Repositories/MatchRepository.cs"
click node_domain_repositories "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Domain/Repositories/IMatchRepository.cs"
click node_data_context "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Infrastructure/Data/TennisDbContext.cs"
click node_unit_of_work "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Infrastructure/UnitOfWork.cs"
click node_event_repository "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Infrastructure/Repositories/MatchEventRepository.cs"
click node_score_hub "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Hubs/ScoreHub.cs"
click node_score_extensions "https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Hubs/ScoreHubExtensions.cs"

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_api_runtime,node_matches_controller,node_live_controller,node_players_controller,node_tournaments_controller,node_formats_controller,node_match_service,node_live_service,node_player_service,node_tournament_service,node_format_service,node_webapp toneBlue
class node_scoring_engine,node_scoring_state,node_match_model,node_postgres toneAmber
class node_match_repository,node_domain_repositories,node_data_context,node_unit_of_work,node_event_repository toneMint
class node_score_hub,node_score_extensions toneRose
class node_subscribers toneIndigo
```

## Components

### API workflows

- [ASP.NET API](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Program.cs): `TennisScores.API/Program.cs`
- [Match endpoints](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Controllers/MatchesController.cs): `TennisScores.API/Controllers/MatchesController.cs`
- [Live-score endpoints](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Controllers/LiveScoreController.cs): `TennisScores.API/Controllers/LiveScoreController.cs`
- [Player endpoints](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Controllers/PlayersController.cs): `TennisScores.API/Controllers/PlayersController.cs`
- [Tournament endpoints](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Controllers/TournamentsController.cs): `TennisScores.API/Controllers/TournamentsController.cs`
- [Format endpoints](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Controllers/MatchFormatsController.cs): `TennisScores.API/Controllers/MatchFormatsController.cs`
- [Match lifecycle](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/MatchService.cs): `TennisScores.API/Services/MatchService.cs`
- [Point and undo](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/LiveScoreService.cs): `TennisScores.API/Services/LiveScoreService.cs`
- [Player management](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/PlayerService.cs): `TennisScores.API/Services/PlayerService.cs`
- [Tournament management](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/TournamentService.cs): `TennisScores.API/Services/TournamentService.cs`
- [Match formats](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Services/MatchFormatService.cs): `TennisScores.API/Services/MatchFormatService.cs`

### Scoring domain

- [Scoring rules](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Domain/Scoring/ScoringEngine.cs): `TennisScores.Domain/Scoring/ScoringEngine.cs`
- [Scoring state and replay](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Domain/Scoring/ScoringReplay.cs): `TennisScores.Domain/Scoring/ScoringReplay.cs`
- [Match model](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Domain/Entities/Match.cs): `TennisScores.Domain/Entities/Match.cs`

### Persistence

- [Match repository](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Infrastructure/Repositories/MatchRepository.cs): `TennisScores.Infrastructure/Repositories/MatchRepository.cs`
- [Domain repositories](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Domain/Repositories/IMatchRepository.cs): `TennisScores.Domain/Repositories/IMatchRepository.cs`
- [EF data context](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Infrastructure/Data/TennisDbContext.cs): `TennisScores.Infrastructure/Data/TennisDbContext.cs`
- [Unit of work](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Infrastructure/UnitOfWork.cs): `TennisScores.Infrastructure/UnitOfWork.cs`
- [Match event journal](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.Infrastructure/Repositories/MatchEventRepository.cs): `TennisScores.Infrastructure/Repositories/MatchEventRepository.cs`

### Live updates

- [SignalR score hub](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Hubs/ScoreHub.cs): `TennisScores.API/Hubs/ScoreHub.cs`
- [Score broadcast](https://github.com/1fini/tennisscoresapi/blob/main/TennisScores.API/Hubs/ScoreHubExtensions.cs): `TennisScores.API/Hubs/ScoreHubExtensions.cs`

### Other components

- **WebApp users**
- **PostgreSQL**
- **Live subscribers**

## Connections

- WebApp users → ASP.NET API: calls REST
- ASP.NET API → Match endpoints: routes requests
- ASP.NET API → Live-score endpoints: routes requests
- ASP.NET API → Player endpoints: routes requests
- ASP.NET API → Tournament endpoints: routes requests
- ASP.NET API → Format endpoints: routes requests
- Match endpoints → Match lifecycle: delegates
- Live-score endpoints → Point and undo: delegates
- Player endpoints → Player management: delegates
- Tournament endpoints → Tournament management: delegates
- Format endpoints → Match formats: delegates
- Match lifecycle → Domain repositories: reads and writes
- Match lifecycle → Unit of work: commits changes
- Match lifecycle → Scoring state and replay: calculates analytics
- Point and undo → Match repository: loads match
- Point and undo → Scoring rules: applies point
- Point and undo → Scoring state and replay: replays undo
- Point and undo → Domain repositories: projects score
- Point and undo → Match event journal: appends events
- Point and undo → Unit of work: commits changes
- Point and undo → Score broadcast: broadcasts update
- Match repository → EF data context: queries matches
- Domain repositories → EF data context: accesses data
- Match event journal → EF data context: stores events
- Unit of work → EF data context: saves changes
- EF data context → PostgreSQL: reads and writes
- Score broadcast → SignalR score hub: dispatches update
- SignalR score hub → Live subscribers: sends live score
