Sports-Events-System Tailwind Templates

Sports Events System

Java/Spring Boot REST API for sports events with CRUD on matches, teams, stadiums, divisions, and cities. Uses MySQL and Hibernate for data management. Implements MVC, DTO, Repositories, and Dependency Injection, including exception handling. Frontend made with Angular.

⚽ Sports Events System

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.


Index

🌐 Frontend

Frontend Installation

To install and run the frontend application, follow these steps:

  1. Navigate to the frontend directory within the project.
  2. Install dependencies using npm or yarn.
  3. Run the development server.

Frontend Usage

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.

Features Display

🎟 Create Event

👥 Create Team

🏙 Create City

🏟 Create Stadium

🏆 Create Division

🔄 Reactive Rendering

⚠️ Error Popups

✅ Input Validation


ㅤ ㅤ ㅤ ㅤ

⚙ Backend

Installation

Configuration and Application Execution

Follow these steps to configure, install, and run the application. You must have Java 17 and MySQL installed.

Clone the Repository

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

Open the Project in your Integrated Development Environment (IDE)

Open your development environment (IntelliJ IDEA, NetBeans, Eclipse, Spring Tool Suite) and select "Open Project" or its equivalent. Navigate to the project folder you just cloned and open it.

Configure the Database

In the application.properties file, located in the project's resources folder (src/main/resources/application.properties), make the following changes:

Database configuration

spring.datasource.username= your-username

spring.datasource.password= your-password

spring.datasource.url=jdbc:mysql://localhost/your-db-name?useSSL=false&serverTimeZone=UTC

Create the Database

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

Run the Application

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.

ER Model

The Entity-Relationship model corresponding to the database.

API Endpoints

Team

Create, Read, Update, Delete from a Team.

Create 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.

Postman Example

Get Team

  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}

Postman Example

Get All Teams

  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: []

Postman Example

Get Teams by City

  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}

Postman Example

Update Team

  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

Postman Example

Delete Team

  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}

Postman Example

Stadium

Create, Read, Update, Delete from a Stadium.

Create 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 Stadium

  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 All Stadiums

  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

Update Stadium

  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 Stadium

  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

Division

Create, Read, Update, Delete from a Division.

Create 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 Division

  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 All Divisions

  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

Update Division

  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 Division

  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

City

Create, Read, Update, Delete from a City.

Create 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 City

  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 All Cities

  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

Update City

  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 City

  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

Match

Create, Read, Delete from a Match.

Create 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 Match

  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 All Matches

  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 Match

  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

Top categories

Loading Svelte Themes