Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Score API

Description

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.

Requirements

  • JDK 21
  • Gradle 8.x (included with the project)

Dependency

  • Spring Boot 3.3.3
  • Kotlin
  • Spring Security (JWT)
  • H2 Database (Embedded)
  • Gradle
  • Spring Data JPA
  • Springdoc OpenAPI (Swagger UI)

Build and Run the Application

  1. Clone the repository:

    git clone https://github.com/yourusername/Score.git
    cd Score
  2. Build the project:

    ./gradlew build
  3. Run the application:

    ./gradlew bootRun

    The application will start at http://localhost:8080.


Running Automated Tests

To run tests for the application:

./gradlew test

API Routes

1. Auth and User Management

  • 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"
    }

2. Score Recording and Scoreboard

  • 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"
    }

3. Game Download

  • GET /api/game/download
    Provides a page or link to download the game.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages