Skip to content

Commit 5dee9e8

Browse files
author
SpicyCoder
committed
Design a Scrum Poker game
1 parent f0a51ce commit 5dee9e8

File tree

10 files changed

+543
-6
lines changed

10 files changed

+543
-6
lines changed
Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,68 @@
11
---
2-
title: "Let's build a Scrum Poker 🎴"
3-
summary: "Planned 🔜"
4-
weight: 4
2+
title: "Let's design a Scrum Poker 🎴"
3+
summary: "Scrum Poker is an online, real-time, multiplayer game."
4+
weight: 2
55
---
66

7-
Coming soon ...
7+
Endpoints, Service Contracts and Sequence Diagrams for building a `Scrum Poker` app.
8+
9+
---
10+
11+
## High level design
12+
13+
```mermaid
14+
graph TD
15+
Browser["Browser Clients"]
16+
BFF["Blazor Server App – UI + BFF"]
17+
API["ASP NET 9 Web API"]
18+
Store["State Store"]
19+
PubSub["Pub/Sub Broker"]
20+
21+
Browser -->|User interaction| BFF
22+
BFF -->|HTTP REST calls| API
23+
API -->|Save / retrieve state| Store
24+
API -.->|Publish events| PubSub
25+
PubSub -.->|Event notification| BFF
26+
BFF -->|Push UI updates| Browser
27+
```
28+
29+
---
30+
31+
## Endpoints
32+
33+
| Operation | Method & Path |
34+
| --- | --- |
35+
| [Create New Game](./create-new-game) | **POST** `/games` |
36+
| [Join Existing Game](./join-existing-game) | **POST** `/games/{gameId}/join` |
37+
| [Submit Vote](./submit-vote) | **POST** `/games/{gameId}/vote` |
38+
| [Reset Votes](./reset-votes) | **POST** `/games/{gameId}/votes/reset` |
39+
| [Get Game State](./get-game-state) | **GET** `/games/{gameId}` |
40+
| [Remove a Player](./remove-a-player) | **DELETE** `/admin/games/{gameId}/players/{player}` |
41+
| [End Game](./end-game) | **DELETE** `/admin/games/{gameId}` |
42+
43+
---
44+
45+
## Client Updates - Real-time
46+
47+
This flow is common for all endpoints
48+
49+
```mermaid
50+
sequenceDiagram
51+
participant PubSub as "Pub/Sub Broker"
52+
participant API as "ASP.NET 9 Web API"
53+
participant Store as "State Store"
54+
participant Hub as "SignalR Hub"
55+
participant Clients as "Connected Clients"
56+
57+
PubSub->>API: Event:{gameId,...}
58+
API->>Store: GET game:{gameId}
59+
60+
alt Game not found
61+
API-->>Hub: SendAsync("GameDeleted", gameId)
62+
Hub-->>Clients: GameDeleted event pushed
63+
else Game exists
64+
Store-->>API: GameResponse
65+
API-->>Hub: SendAsync("GameUpdated", GameResponse)
66+
Hub-->>Clients: GameUpdated event pushed
67+
end
68+
```
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
date: '2025-11-15T19:54:22+05:30'
3+
draft: true
4+
title: 'Create New Game'
5+
summary: 'Endpoint to `Create a new Game`'
6+
tags: ['Design', 'Architecture']
7+
weight: 10
8+
---
9+
10+
```mermaid
11+
sequenceDiagram
12+
participant BFF as "Blazor Server App – UI + BFF"
13+
participant API as "ASP.NET 9 Web API"
14+
participant Store as "State Store"
15+
participant PubSub as "Pub/Sub Broker"
16+
17+
BFF->>API: POST /games
18+
alt Semantically invalid data
19+
API-->>BFF: 422 Unprocessable Entity
20+
Note right of API: Payload → Error
21+
else Success
22+
API->>Store: SAVE game:{gameId} {initialState}
23+
API-->>PubSub: PUBLISH GameCreated:{gameId}
24+
API-->>BFF: 201 Created
25+
Note right of API: Payload → GameResponse
26+
end
27+
```
28+
29+
---
30+
31+
## Request
32+
33+
```mermaid
34+
classDiagram
35+
class CreateGameRequest {
36+
+ string player
37+
}
38+
```
39+
40+
---
41+
42+
## Response
43+
44+
```mermaid
45+
classDiagram
46+
class GameResponse {
47+
+ string gameId
48+
+ string[] players
49+
+ DateTime createdAt
50+
+ Vote[] votes
51+
}
52+
class Vote {
53+
+ string player
54+
+ int? value
55+
}
56+
57+
GameResponse o-- Vote : votes
58+
```
59+
60+
---
61+
62+
## Error
63+
64+
```mermaid
65+
classDiagram
66+
class Error {
67+
+ string Code
68+
+ string Message
69+
}
70+
```
71+
72+
---
73+
74+
## Publish - GameCreated
75+
76+
```mermaid
77+
classDiagram
78+
class GameCreatedEvent {
79+
+ string gameId
80+
}
81+
```
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
date: '2025-11-15T20:00:43+05:30'
3+
draft: true
4+
title: 'End Game'
5+
summary: 'Endpoint to `End the game`'
6+
tags: ['Design', 'Architecture']
7+
weight: 70
8+
---
9+
10+
```mermaid
11+
sequenceDiagram
12+
participant SignalR as "SignalR Hub – Disconnection Hook"
13+
participant API as "ASP.NET 9 Web API"
14+
participant Store as "State Store"
15+
participant PubSub as "Pub/Sub Broker"
16+
17+
SignalR->>API: DELETE /admin/games/{gameId}
18+
API->>Store: GET game:{gameId}
19+
20+
alt Game not found
21+
API-->>SignalR: 404 Not Found
22+
Note right of API: Payload → Error
23+
else Success
24+
API->>Store: DELETE game:{gameId}
25+
API-->>PubSub: PUBLISH GameEnded:{gameId}
26+
API-->>SignalR: 204 No Content
27+
end
28+
```
29+
30+
## Publish - GameEnded
31+
32+
```mermaid
33+
classDiagram
34+
class GameEndedEvent {
35+
+ string gameId
36+
}
37+
```
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
date: '2025-11-15T20:00:32+05:30'
3+
draft: true
4+
title: 'Get Game State'
5+
summary: 'Endpoint to `Get current state of the game`'
6+
tags: ['Design', 'Architecture']
7+
weight: 50
8+
---
9+
10+
```mermaid
11+
sequenceDiagram
12+
participant BFF as "Blazor Server App – UI + BFF"
13+
participant API as "ASP.NET 9 Web API"
14+
participant Store as "State Store"
15+
16+
BFF->>API: GET /games/{gameId}
17+
API->>Store: GET game:{gameId}
18+
19+
alt Game not found
20+
API-->>BFF: 404 Not Found
21+
Note right of API: Payload → Error
22+
else Success
23+
API-->>BFF: 200 OK
24+
Note right of API: Payload → GameResponse
25+
end
26+
27+
```
28+
29+
---
30+
31+
## Response
32+
33+
```mermaid
34+
classDiagram
35+
class GameResponse {
36+
+ string gameId
37+
+ string[] players
38+
+ DateTime createdAt
39+
+ Vote[] votes
40+
}
41+
class Vote {
42+
+ string player
43+
+ int? value
44+
}
45+
46+
GameResponse o-- Vote : votes
47+
```
48+
49+
---
50+
51+
## Error
52+
53+
```mermaid
54+
classDiagram
55+
class Error {
56+
+ string Code
57+
+ string Message
58+
}
59+
```
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
date: '2025-11-15T19:58:20+05:30'
3+
draft: true
4+
title: 'Join Existing Game'
5+
summary: 'Endpoint to `Join an existing Game`'
6+
tags: ['Design', 'Architecture']
7+
weight: 20
8+
---
9+
10+
```mermaid
11+
sequenceDiagram
12+
participant BFF as "Blazor Server App – UI + BFF"
13+
participant API as "ASP.NET 9 Web API"
14+
participant Store as "State Store"
15+
participant PubSub as "Pub/Sub Broker"
16+
17+
BFF->>API: POST /games/{gameId}/join
18+
API->>Store: GET game:{gameId}
19+
20+
alt Semantically invalid data
21+
API-->>BFF: 422 Unprocessable Entity
22+
Note right of API: Payload → Error
23+
else Game not found
24+
API-->>BFF: 404 Not Found
25+
Note right of API: Payload → Error
26+
else Player already exists
27+
API-->>BFF: 409 Conflict
28+
Note right of API: Payload → Error
29+
else Success
30+
API->>Store: SAVE game:{gameId} {updatedState}
31+
API-->>PubSub: PUBLISH PlayerJoined:{gameId,player}
32+
API-->>BFF: 200 OK
33+
Note right of API: Payload → GameResponse
34+
end
35+
```
36+
37+
---
38+
39+
## Request
40+
41+
```mermaid
42+
classDiagram
43+
class JoinGameRequest {
44+
+ string player
45+
}
46+
```
47+
48+
---
49+
50+
## Response
51+
52+
```mermaid
53+
classDiagram
54+
class GameResponse {
55+
+ string gameId
56+
+ string[] players
57+
+ DateTime createdAt
58+
+ Vote[] votes
59+
}
60+
class Vote {
61+
+ string player
62+
+ int? value
63+
}
64+
65+
GameResponse o-- Vote : votes
66+
```
67+
68+
---
69+
70+
## Error
71+
72+
```mermaid
73+
classDiagram
74+
class Error {
75+
+ string Code
76+
+ string Message
77+
}
78+
```
79+
80+
---
81+
82+
## Publish - PlayerJoined
83+
84+
```mermaid
85+
classDiagram
86+
class PlayerJoinedEvent {
87+
+ string gameId
88+
+ string player
89+
}
90+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
date: '2025-11-15T20:00:38+05:30'
3+
draft: true
4+
title: 'Remove a Player'
5+
summary: 'Endpoint to `Remove a player from the game`'
6+
tags: ['Design', 'Architecture']
7+
weight: 60
8+
---
9+
10+
```mermaid
11+
sequenceDiagram
12+
participant SignalR as "SignalR Hub – Disconnection Hook"
13+
participant API as "ASP.NET 9 Web API"
14+
participant Store as "State Store"
15+
participant PubSub as "Pub/Sub Broker"
16+
17+
SignalR->>API: DELETE /admin/games/{gameId}/players/{player}
18+
API->>Store: GET game:{gameId}
19+
20+
alt Game or player not found
21+
API-->>SignalR: 404 Not Found
22+
Note right of API: Payload → Error
23+
else Player not in game
24+
API-->>SignalR: 409 Conflict
25+
Note right of API: Payload → Error
26+
else Success
27+
API->>Store: SAVE game:{gameId} {player removed}
28+
API-->>PubSub: PUBLISH PlayerRemoved:{gameId,player}
29+
API-->>SignalR: 204 No Content
30+
end
31+
32+
```
33+
34+
## Publish - PlayerRemoved
35+
36+
```mermaid
37+
classDiagram
38+
class PlayerRemovedEvent {
39+
+ string gameId
40+
+ string player
41+
}
42+
```

0 commit comments

Comments
 (0)