A CRUD system for managing sports events, implementing operations on matches, teams, stadiums, divisions, and cities. This system includes both backend REST API and a frontend application built with Angular
.
The backend API is developed using Java
and Spring Boot
, with Hibernate for object-relational mapping. MySQL
is used as the database. Design patterns such as MVC, DTO, Repositories, and Dependency Injection are implemented, along with exception handling.
To install and run the frontend application, follow these steps:
Once the frontend application and the backend API is running, you can access it through a web browser. The application provides a user-friendly interface for interacting with the Sports Events system.
Follow these steps to configure, install, and run the application. You must have Java 17 and MySQL installed.
First, clone this repository to your local machine using the following command in your terminal:
git clone https://github.com/lucianomp9/Sports-Events-System.git
In the application.properties file, located in the project's resources folder (src/main/resources/application.properties), make the following changes:
spring.datasource.username= your-username
spring.datasource.password= your-password
spring.datasource.url=jdbc:mysql://localhost/your-db-name?useSSL=false&serverTimeZone=UTC
Open your MySQL client and create the database with the name specified in the previous URL. Use the database creation script provided at: src/main/resources/scripts/bd_script.sql
Once you have configured the database and saved the changes in application.properties, you can run the application. Find the main class "MatchescrudApplication" (annotated with @SpringBootApplication) and click the run button in your development environment.
The Entity-Relationship model corresponding to the database.
Create, Read, Update, Delete from a Team.
POST localhost:8080/api/v1/team
Parameter | Type | Description | Example |
---|---|---|---|
name | String |
By Body | Barcelona F.C. |
division | Division |
By Body or by ID (if exists) | Spanish League |
city | City |
By Body or by ID (if exists) | Barcelona |
stadium | Stadium |
By Body or by ID (if exists) | Camp Nou, 99354 |
URL: localhost:8080/api/v1/team
Method: POST
Response:
201 - CREATED: name,division,city,stadium
409 - CONFLICT: (Team/Division/City/Stadium) Already Exists, (Division/City/Stadium) With ID (id) Not Found
[!NOTE] If (Division/City/Stadium) doesn't exist, it is created automatically. You can then use them with another team via their ID. Home and Away matches lists are created empty.
GET localhost:8080/api/v1/team/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL | 5 |
URL: localhost:8080/api/v1/team/{id}
Method: GET
Response:
200 - OK: id, name, division, city, stadium, homeMatches, awayMatches (TeamDTO)
404 - NOT FOUND: No team was found with id: {id}
GET localhost:8080/api/v1/team
Parameter | Type | Description | Example |
---|---|---|---|
No parameters required. |
URL: localhost:8080/api/v1/team/{id}
Method: GET
Response:
200 - OK: JSON array containing TeamDTO objects. If no teams exist, it returns an empty array: []
GET localhost:8080/api/v1/teamByCity/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL | 4 |
URL: localhost:8080/api/v1/teamByCity/{id}
Method: GET
Response:
200 - OK: JSON array containing TeamDTO objects. If no teams exist, it returns an empty array: []
409 - CONFLICT: No city was found with id: {id}
PUT localhost:8080/api/v1/team/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL | 5 |
name | String |
By body | Independiente |
division | Division |
By Body or by ID (if exists) | Primera Division |
city | City |
By Body or by ID (if exists) | Avellaneda |
stadium | Stadium |
By Body or by ID (if exists) | Libertadores de America Ricardo Enrique Bochini, 42069 |
URL: localhost:8080/api/v1/team/{id}
Method: PUT
Response:
200 - OK: id, name, division, city, stadium, homeMatches, awayMatches (TeamDTO)
404 - NOT FOUND: No team was found with id: {id}
409 - CONFLICT: (Division/City/Stadium) With ID (id) Not Found
DELETE localhost:8080/api/v1/team/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL | 5 |
URL: localhost:8080/api/v1/team/{id}
Method: DELETE
Response:
200 - OK: id, name, division, city, stadium, homeMatches, awayMatches (TeamDTO)
404 - NOT FOUND: No team was found with id: {id}
Create, Read, Update, Delete from a Stadium.
POST localhost:8080/api/v1/stadium
Parameter | Type | Description | Example |
---|---|---|---|
name | String |
By body | "Old Trafford" |
capacity | int |
By body | 74310 |
URL: localhost:8080/api/v1/stadium
Method: POST
Response:
201 - CREATED: id, name, capacity. (StadiumDTO)
409 - CONFLICT: Stadium with name {name} already exists
Postman Example
GET localhost:8080/api/v1/stadium/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL. | 7 |
URL: localhost:8080/api/v1/stadium/{id}
Method: GET
Response:
200 - OK: id, name, capacity. (StadiumDTO)
404 - NOT FOUND: Stadium with ID {id} Not Found.
Postman Example
GET localhost:8080/api/v1/stadium
Parameter | Type | Description | Example |
---|---|---|---|
No parameters required. |
URL: localhost:8080/api/v1/stadium
Method: GET
Response:
200 - OK: JSON array containing StadiumDTO objects. If no stadium exist, it returns an empty array: []
Postman Example
PUT localhost:8080/api/v1/stadium/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL. | 7 |
name | String |
By body | "Anfield" |
capacity | int |
By body | 61276 |
URL: localhost:8080/api/v1/stadium/{id}
Method: PUT
Response:
200 - OK: id, name, capacity. (StadiumDTO)
404 - NOT FOUND: Stadium with ID {id} Not Found.
Postman Example
DELETE localhost:8080/api/v1/stadium/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL. | 7 |
URL: localhost:8080/api/v1/stadium/{id}
Method: DELETE
Response:
200 - OK: id, name, capacity. (StadiumDTO)
404 - NOT FOUND: Stadium with ID {id} Not Found.
Postman Example
Create, Read, Update, Delete from a Division.
POST localhost:8080/api/v1/division
Parameter | Type | Description | Example |
---|---|---|---|
name | String |
By body | "Premier League" |
URL: localhost:8080/api/v1/division
Method: POST
Response:
201 - CREATED: id, name. (DivisionDTO)
409 - CONFLICT: Division with name {name} already exists
Postman Example
GET localhost:8080/api/v1/division/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL. | 5 |
URL: localhost:8080/api/v1/division/{id}
Method: GET
Response:
200 - OK: id, name. (DivisionDTO)
404 - NOT FOUND: Division with ID {id} Not Found.
Postman Example
GET localhost:8080/api/v1/division
Parameter | Type | Description | Example |
---|---|---|---|
No parameters required. |
URL: localhost:8080/api/v1/division
Method: GET
Response:
200 - OK: JSON array containing DivisionDTO objects. If no division exist, it returns an empty array: []
Postman Example
PUT localhost:8080/api/v1/division/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL. | 5 |
name | String |
By body | "Bundesliga" |
URL: localhost:8080/api/v1/division/{id}
Method: PUT
Response:
200 - OK: id, name. (DivisionDTO)
404 - NOT FOUND: Division with ID {id} Not Found.
Postman Example
DELETE localhost:8080/api/v1/division/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL. | 5 |
URL: localhost:8080/api/v1/division/{id}
Method: DELETE
Response:
200 - OK: id, name. (DivisionDTO)
404 - NOT FOUND: Division with ID {id} Not Found.
Postman Example
Create, Read, Update, Delete from a City.
POST localhost:8080/api/v1/city
Parameter | Type | Description | Example |
---|---|---|---|
name | String |
By body | "Cordoba" |
URL: localhost:8080/api/v1/city
Method: POST
Response:
201 - CREATED: id, name. (CityDTO)
409 - CONFLICT: City with name {name} already exists
Postman Example
GET localhost:8080/api/v1/city/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL. | 6 |
URL: localhost:8080/api/v1/city/{id}
Method: GET
Response:
200 - OK: id, name. (CityDTO)
404 - NOT FOUND: City with ID {id} Not Found.
Postman Example
GET localhost:8080/api/v1/city
Parameter | Type | Description | Example |
---|---|---|---|
No parameters required. |
URL: localhost:8080/api/v1/city
Method: GET
Response:
200 - OK: JSON array containing CityDTO objects. If no division exist, it returns an empty array: []
Postman Example
PUT localhost:8080/api/v1/city/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL. | 6 |
name | String |
By body | "Manchester" |
URL: localhost:8080/api/v1/city/{id}
Method: PUT
Response:
200 - OK: id, name. (CityDTO)
404 - NOT FOUND: City with ID {id} Not Found.
Postman Example
DELETE localhost:8080/api/v1/city/{id}
Parameter | Type | Description | Example |
---|---|---|---|
id | Long |
By URL. | 6 |
URL: localhost:8080/api/v1/city/{id}
Method: DELETE
Response:
200 - OK: id, name. (CityDTO)
404 - NOT FOUND: City with ID {id} Not Found.
Postman Example
Create, Read, Delete from a Match.
POST localhost:8080/api/v1/match
Parameter | Type | Description | Example |
---|---|---|---|
date | LocalDate |
By Body | 2024-01-21 |
time | LocalTime |
By Body | 14:00:00 |
homeTeam | Team |
By Body or by ID (if exists) | {id: 6} |
awayTeam | Team |
By Body or by ID (if exists) | {id: 7} |
homeGoals | int |
By Body | 5 |
awayGoals | int |
By Body | 4 |
spectators | int |
By Body | 56325 |
ticketPrice | BigDecimal |
By Body | 20.5 |
URL: localhost:8080/api/v1/match
Method: POST
Response:
201 - CREATED: uuid, stadium, date, time, homeTeam, awayTeam, homeGoals, awayGoals, spectators, revenue (MatchResponseDTO)
404 - NOT FOUND: Team with id {id} Not Found.
[!NOTE] The Match UUID is generated automatically when the match is created.
The Match Stadium is automatically assigned by taking the home team's stadium.
The Match Revenue is calculated using the following operation: spectators * ticketPrice
Each Match is automatically added, as appropriate, to the HomeMatches or AwayMatches list of each team.
Postman Example
GET localhost:8080/api/v1/match/{uuid}
Parameter | Type | Description | Example |
---|---|---|---|
uuid | UUID |
By URL. | 46940236-7a1a-4a40-9e13-18ca3dbad218 |
URL: localhost:8080/api/v1/match/{uuid}
Method: GET
Response:
201 - CREATED: uuid, stadium, date, time, homeTeam, awayTeam, homeGoals, awayGoals, spectators, revenue (MatchResponseDTO)
404 - NOT FOUND: No match was found with UUID: {uuid}
Postman Example
GET localhost:8080/api/v1/match
Parameter | Type | Description | Example |
---|---|---|---|
No parameters required. |
URL: localhost:8080/api/v1/match
Method: GET
Response:
200 - OK: JSON array containing MatchResponseDTO objects. If no matches exist, it returns an empty array: []
Postman Example
DELETE localhost:8080/api/v1/match/{uuid}
Parameter | Type | Description | Example |
---|---|---|---|
uuid | UUID |
By URL. | b4abec48-e410-455a-82d3-7bd18f34e1af |
URL: localhost:8080/api/v1/match/{uuid}
Method: DELETE
Response:
200 - OK: uuid, stadium, date, time, homeTeam, awayTeam, homeGoals, awayGoals, spectators, revenue (MatchResponseDTO)
404 - NOT FOUND: No match was found with UUID: {uuid}
Postman Example