Git Product home page Git Product logo

lucianomp9 / sports-events-system Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 560 KB

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.

Java 35.22% HTML 18.59% TypeScript 37.53% CSS 8.55% JavaScript 0.10%
angular dto-pattern exception-handling hibernate java mvc mysql springboot tailwind

sports-events-system's Introduction

โšฝ 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-event

๐Ÿ‘ฅ Create Team

create-team

๐Ÿ™ Create City

create-city

๐ŸŸ Create Stadium

create-stadium

๐Ÿ† Create Division

create-division

๐Ÿ”„ Reactive Rendering

reactive-rendering

โš ๏ธ Error Popups

error-handling

โœ… Input Validation

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.

ER Model

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

post_team

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

image

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 image

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 image

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 image

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 image

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

image

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

image

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

image

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

image

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

image

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

image

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

image

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

image

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

image

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

image

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

image

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

image

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

image

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

image

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

image

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

image

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

image image

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

image

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

image

sports-events-system's People

Contributors

lucianomp9 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.