# Dart Board Counter - Project Idea and Initial Plan

## Installation
Please read the installation at [Docker Setup](./DOCKER.md).

## Project Idea

Build a focused web app for tracking X01 dart games (301/501/etc.) with a fast input flow, clear scoreboard, and reliable game state handling.

Core concept:
- Users create a game mode and players.
- The app guides each throw (number, multiplier, bull, out).
- Scores, turns, bust rules, and win conditions are updated automatically.
- Finished and aborted games remain visible for review.

The goal is to replace paper scoring with a digital counter that is fast enough to use during real play.

# How to stress test
Before these tests can be run, the docker setup must be completed and running. the port in the commands below must be changed to the port of the docker setup.
## Preparations
First we need to get a JWT token from the API to make authenticated requests. The following command authenticates and sets the JWT environment variable or the current shell session.
```bash
export JWT=$(curl -s -X POST http://localhost:8088/api/login_check \
  -H "Content-Type: application/json" \
  -d '{"email":"demo@example.com","password":"demo1234"}' \
  | grep -o '"token":"[^"]*"' | cut -d'"' -f4)
```

Test if the JWT is set correctly.
```bash
curl -H "Authorization: Bearer $JWT" http://localhost:8088/api/me
```

This request loads the user profile and returns the user's information. If the response looks like this, you are ready.
```json
{"user":{"id":"019c9e77-3e19-7d66-bd7e-24b48aa23263","email":"demo@example.com","roles":["ROLE_USER"],"createdAt":"2026-02-27T09:39:01+00:00"}}
```

## Stress Test Results
### Approximate 1000 req/s with hey
With hey you usually cannot directly set “1000 requests per second”, you control concurrency instead. The resulting requests/sec is whatever the system can sustain.
`concurrency ≈ requests per second × normal average response time`
With an average endpoint latency of ≈ `200ms = 0.20s`
`1000rps * 0.20s = 200 concurrency`. So with 200 concurrent connections you can sustain 1000 requests per second when the average response time is 200ms.

### hey test 1 (local)
with 50 concurrent connections for 10 seconds:
```bash
hey -z 10s -c 50 \
  -H "Authorization: Bearer $JWT" \
  http://localhost:8088/api/me
```

<details>
<summary>Results...</summary>

![hey test results](./docs/hey-test-1.png)
</details>

### hey test 2 (local)
with 200 concurrent connections for 10 seconds

```bash
hey -z 10s -c 200 \
  -H "Authorization: Bearer $JWT" \
  http://localhost:8088/api/me
```
<details>
<summary>Results...</summary>

![hey test results](./docs/hey-test-2.png)
</details>

### hey test 3 (local)
with 500 concurrent connections for 10 seconds

```bash
hey -z 10s -c 500 \
  -H "Authorization: Bearer $JWT" \
  http://localhost:8088/api/me
```
<details>
<summary>Results...</summary>

![hey test results](./docs/hey-test-3.png)
</details>

### k6 1000req/s test
```bash
URI=http://localhost:8088 k6 run k6-stress-test.js
```
![hey test results](./docs/k6-test-1.png)
