Skip to content

This project is a Formula 1 Tracker built using Java Spring Boot with JPA, Hibernate, Lombok, and the MySQL driver..

Notifications You must be signed in to change notification settings

prathampalsingh/Formula-1-Springboot-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Formula 1 πŸš€

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.


πŸ“œ Features

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

πŸ› οΈ Tech Stack

  • Backend: Java with Spring Boot
  • Database: MySQL (with MySQL Driver)
  • ORM: JPA/Hibernate
  • Utilities: Lombok for cleaner code
  • Testing: Postman for API testing

πŸš€ Getting Started

While Creating spring boot project make sure to select maven and in dependencies (Spring data jpa, Spring web, lombok, mysql driver)

1. MySql setup

  1. create database name f1db
create database f1db

2. Configure application.properties

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

3.Build and Run

Use Maven to build and run the project:

  mvn clean install
  mvn spring-boot:run

Postman

  1. Make sure to select the post method
  2. In the url provide:
    http://localhost:8080/teams/createTeam
  3. Select body and format as raw
  4. From the drop down menu select Json
  5. 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
     }
    ]
    }
    

πŸ“‚ Project Structure

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

🧭 API Endpoints

  • 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

✨ Highlights

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.

πŸ’Ύ Database Result

  1. This is the description of the database driver and teams which uses @ManyToOne and @ManyToMany relationship
    f1_manager_desc

  2. As you can see the data is present in the database
    f1_manager_data

Made with ❀️ using Java and Spring Boot.

About

This project is a Formula 1 Tracker built using Java Spring Boot with JPA, Hibernate, Lombok, and the MySQL driver..

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages