A Spring Boot application to manage and track Formula 1 drivers, races, teams, and results. This project leverages modern Java development tools and libraries, such as Spring Boot, JPA, Hibernate, Lombok, and MySQL, to create a RESTful API that seamlessly interacts with the database.
- Drivers: Manage driver profiles including details like name, nationality, age, wins, and championships.
- Teams: Create and manage F1 teams, linking drivers and managing their budgets and car models.
- Races: Keep track of race details such as name, track, date, and results.
- Results: Record and retrieve race results, including driver rankings.
- Backend: Java with Spring Boot
- Database: MySQL (with MySQL Driver)
- ORM: JPA/Hibernate
- Utilities: Lombok for cleaner code
- Testing: Postman for API testing
While Creating spring boot project make sure to select maven and in dependencies (Spring data jpa, Spring web, lombok, mysql driver)
- create database name f1db
create database f1db
Update the application.properties file with your MySQL credentials:
spring.datasource.url=jdbc:mysql://localhost:3306/your-databasename
spring.datasource.username=your-username
spring.datasource.password=your-password
spring.jpa.show-sql=true
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
Use Maven to build and run the project:
mvn clean install
mvn spring-boot:run
- Make sure to select the
post
method - In the url provide:
http://localhost:8080/teams/createTeam
- Select
body
and format asraw
- From the drop down menu select
Json
- Provide this within the body
{ "name": "Red Bull Racing", "headquarters": "Milton Keynes, UK", "budget": 450000000.00, "carModel": "RB20", "drivers": [ { "name": "Max Verstappen", "nationality": "Dutch", "age": 27, "wins": 63, "championships": 4 }, { "name": "Sergio Perez", "nationality": "Mexican", "age": 34, "wins": 6, "championships": 0 } ] }
src
βββ main
β βββ java
β β βββ com.f1.tracker.controller
β β β βββ DriverController.java # Handles driver-related API requests
β β β βββ RaceController.java # Handles race-related API requests
β β β βββ RaceResultController.java # Handles race result-related API requests
β β β βββ TeamController.java # Handles team-related API requests
β β βββ com.f1.tracker.entity
β β β βββ DriverEntity.java # Entity representing Driver table
β β β βββ RaceEntity.java # Entity representing Race table
β β β βββ RaceResultEntity.java # Entity representing Race Results table
β β β βββ TeamEntity.java # Entity representing Team table
β β βββ com.f1.tracker.service
β β β βββ DriverService.java # Business logic for Driver
β β β βββ RaceService.java # Business logic for Race
β β β βββ RaceResultService.java # Business logic for Race Results
β β β βββ TeamService.java # Business logic for Team
β β βββ com.f1.tracker.repository
β β β βββ DriverRepository.java # JPA Repository for Driver
β β β βββ RaceRepository.java # JPA Repository for Race
β β β βββ RaceResultRepository.java # JPA Repository for Race Results
β β β βββ TeamRepository.java # JPA Repository for Team
β βββ resources
β βββ application.properties # Application configuration
β βββ data.sql # Sample data for database initialization (if applicable)
βββ test
β βββ java
β β βββ com.f1.tracker # Unit tests for various components
βββ pom.xml # Maven build file containing project dependencies
-
Drivers
GET /drivers - Get all drivers
POST /drivers/createDriver - Add a new driver
PUT /drivers/{id} - Update a driver
DELETE /drivers/{id} - Delete a driver -
Teams
GET /teams - Get all teams
POST /teams/createTeam - Add a new team
PUT /teams/{id} - Update a team
DELETE /teams/{id} - Delete a team -
Race
GET /races - Get all races
POST /races/createRace - Add a new race
PUT /races/{id} - Update a race
DELETE /races/{id} - Delete a race -
Results
GET /results - Get all race results
POST /results/createRaceResult - Add a new result
PUT /results/{id} - Update a result
DELETE /results/{id} - Delete a result
Spring Boot Framework: Simplifies application setup and development.
JPA and Hibernate: Efficient ORM for database interactions.
Lombok: Reduces boilerplate code.**
MySQL Driver: Seamless database connectivity.
Postman: Comprehensive API testing.
-
This is the description of the database driver and teams which uses
@ManyToOne
and@ManyToMany
relationship
Made with β€οΈ using Java and Spring Boot.