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.
- Java 17
- Spring Boot (Web, Data JPA, Actuator)
- Hibernate ORM
- MySQL
- Maven
- Lombok
- 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
Layered structure:
controller- REST endpointsservice- business logicrepository- data access (Spring Data JPA + JPQL)fighter/model,country/model- JPA entitiesfighter/dto- request/response DTOsexception- custom exceptions + global handler
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 |
dateOfBirthin JSON body uses formatdd-MM-yyyy.
dobquery parameter in PATCH isyyyy-MM-dd.
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
}git clone https://github.com/stajkovic-luka/FighterAPI.git
cd FighterAPIEdit src/main/resources/application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/ufc_stats
spring.datasource.username=spring
spring.datasource.password=springCreate the database and (optionally) import seed data from data.sql.
./mvnw spring-boot:runAPI will be available at:
http://localhost:8080/ufc/fighters
Still in active development...