Skip to content

stajkovic-luka/FighterAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FighterAPI - UFC Fighter Statistics REST API

REST API for managing and querying UFC fighter data using a Kaggle-based dataset.
Built with Spring Boot and Hibernate, with focus on clean layered architecture and practical backend patterns.

Tech Stack

  • Java 17
  • Spring Boot (Web, Data JPA, Actuator)
  • Hibernate ORM
  • MySQL
  • Maven
  • Lombok

Key Features

  • CRUD operations for fighters
  • Pagination support for list endpoints
  • Filtering by stance, wins, and age
  • DTO-based request/response mapping
  • Custom JPQL queries in repository layer
  • Centralized exception handling for API errors

Architecture

Layered structure:

  • controller - REST endpoints
  • service - business logic
  • repository - data access (Spring Data JPA + JPQL)
  • fighter/model, country/model - JPA entities
  • fighter/dto - request/response DTOs
  • exception - custom exceptions + global handler

API Endpoints

Base path: /ufc

Method Endpoint Description
GET /fighters?page=0&size=25 Get paginated list of fighters
GET /fighters/{id} Get fighter by ID
POST /fighters Create a new fighter
PATCH /fighters?name={name}&dob={yyyy-MM-dd} Update fighter score (wins/losses/draws)
DELETE /fighters/{id} Delete fighter by ID
GET /fighters/stats?p=0&pageSize=25&stance={STANCE} Filter fighters by stance
GET /fighters/stats2?age={minAge}&wins={minWins}&p=0&size=40 Filter by minimum age and wins
GET /fighters/total Get total fighter count

dateOfBirth in JSON body uses format dd-MM-yyyy.
dob query parameter in PATCH is yyyy-MM-dd.

Example Request (Create Fighter)

POST /ufc/fighters
Content-Type: application/json

{
  "name": "John Doe",
  "countryName": "Serbia",
  "nickname": "The Example",
  "wins": 10,
  "losses": 2,
  "draws": 0,
  "height": 182.5,
  "weight": 77.1,
  "reach": 188.0,
  "stance": "ORTHODOX",
  "dateOfBirth": "15-04-1998",
  "significantStrikesLanded": 4.2,
  "significantStrikesAbsorbed": 3.1,
  "significantStrikesAccuracy": 52.3,
  "significantStrikesDeffence": 58.7,
  "avgTakedownsLanded": 1.3,
  "avgSubmissionsAttempted": 0.4,
  "takedownAccuracy": 46.0,
  "takedownDefense": 71.5
}

Local Setup

1. Clone repository

git clone https://github.com/stajkovic-luka/FighterAPI.git
cd FighterAPI

2. Configure MySQL

Edit src/main/resources/application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/ufc_stats
spring.datasource.username=spring
spring.datasource.password=spring

Create the database and (optionally) import seed data from data.sql.

3. Run application

./mvnw spring-boot:run

API will be available at:

http://localhost:8080/ufc/fighters

Status

Still in active development...

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages