A Kotlin Spring Boot API backend to record high scores. It allows users to sign up, log in with JWT, record their game scores, view leaderboards, and manage privacy settings.
- JDK 21
- Gradle 8.x (included with the project)
- Spring Boot 3.3.3
- Kotlin
- Spring Security (JWT)
- H2 Database (Embedded)
- Gradle
- Spring Data JPA
- Springdoc OpenAPI (Swagger UI)
-
Clone the repository:
git clone https://github.com/yourusername/Score.git cd Score -
Build the project:
./gradlew build
-
Run the application:
./gradlew bootRun
The application will start at
http://localhost:8080.
To run tests for the application:
./gradlew test-
POST /api/auth/signup
Registers a new user.
Request:{ "username": "string", "password": "string" } -
POST /api/auth/login
Authenticates user and returns a JWT token.
Request:{ "username": "string", "password": "string" } -
PUT /api/user/password
Allows the logged-in user to change their password.
Request:{ "old_password": "string", "new_password": "string" }
-
POST /api/score/record
Records the score for a user.
Request:{ "player_id": "UUID", "user_name": "string", "start_time": "ISO-8601 format", "end_time": "ISO-8601 format", "score": "int" } -
GET /api/scoreboard
Fetches the public scoreboard with pagination.
Request Parameters:page: Page number (default = 0)size: Page size (default = 10)
Response:
{ "content": [ { "player_id": "UUID", "user_name": "string", "score": "int" } ], "total_pages": "int", "total_elements": "int", "current_page": "int" } -
GET /api/leaderboard
Fetches the global leaderboard with pagination.
Request Parameters:page: Page number (default = 0)size: Page size (default = 10)
Response:
{ "content": [ { "user_name": "string", "score": "int" } ], "total_pages": "int", "total_elements": "int", "current_page": "int" } -
PUT /api/scoreboard/privacy
Sets the user's scoreboard privacy to public or private.
Request:{ "is_private": "true/false" }
- GET /api/game/download
Provides a page or link to download the game.