Skip to content

CRUD API of F1 drivers 🏁🏎️ that showcases the use of Spring Boot, MySQL & Docker as its main technologies.

License

Notifications You must be signed in to change notification settings

MatiasCarabella/formula1-driver-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

69 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

    Formula 1 Driver API

Java 21 LTS Spring Boot Maven MySQL Docker Swagger Postman Collection

This Formula 1 Driver API is a fully dockerized RESTful service for managing Formula 1 driver data. Built with Spring Boot and MySQL, it offers endpoints for CRUD operations, seamless local or containerized deployment, and API documentation via Swagger and Postman.

Setup Instructions

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/MatiasCarabella/formula1-driver-API.git
cd formula1-driver-API
  1. Build and start the application using Docker Compose:
 docker compose up --build 

This will automatically build the Docker containers and start the application.

  1. Access the application on http://localhost:9096/api. You should get the following response:
{
    "message": "Ready to go! 🚦🏁",
    "status": 200
}

Project Structure

formula1-driver-API/
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ main
β”‚   β”‚   β”œβ”€β”€ java
β”‚   β”‚   β”‚   └── com
β”‚   β”‚   β”‚       └── motorsport
β”‚   β”‚   β”‚           └── formula1
β”‚   β”‚   β”‚               β”œβ”€β”€ Formula1Application.java
β”‚   β”‚   β”‚               β”œβ”€β”€ controller
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ IDriverController.java
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ IPingController.java
β”‚   β”‚   β”‚               β”‚   └── impl
β”‚   β”‚   β”‚               β”‚       β”œβ”€β”€ DriverController.java
β”‚   β”‚   β”‚               β”‚       └── PingController.java
β”‚   β”‚   β”‚               β”œβ”€β”€ entity
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ Driver.java
β”‚   β”‚   β”‚               β”‚   └── Response.java
β”‚   β”‚   β”‚               β”œβ”€β”€ repository
β”‚   β”‚   β”‚               β”‚   └── DriverRepository.java
β”‚   β”‚   β”‚               β”œβ”€β”€ response
β”‚   β”‚   β”‚               β”‚   └── ResponseHandler.java
β”‚   β”‚   β”‚               β”œβ”€β”€ usecase
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ ICreateDrivers.java
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ IDeleteDriver.java
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ IGetAllDrivers.java
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ IGetDriversFromJson.java
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ IGetDriversWithFilters.java
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ IGetDuplicateDrivers.java
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ IInitializeDatabase.java
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ IIsDatabasePopulated.java
β”‚   β”‚   β”‚               β”‚   β”œβ”€β”€ IUpdateDriver.java
β”‚   β”‚   β”‚               β”‚   └── impl
β”‚   β”‚   β”‚               β”‚       β”œβ”€β”€ CreateDrivers.java
β”‚   β”‚   β”‚               β”‚       β”œβ”€β”€ DeleteDriver.java
β”‚   β”‚   β”‚               β”‚       β”œβ”€β”€ GetAllDrivers.java
β”‚   β”‚   β”‚               β”‚       β”œβ”€β”€ GetDriversFromJson.java
β”‚   β”‚   β”‚               β”‚       β”œβ”€β”€ GetDriversWithFilters.java
β”‚   β”‚   β”‚               β”‚       β”œβ”€β”€ GetDuplicateDrivers.java
β”‚   β”‚   β”‚               β”‚       β”œβ”€β”€ InitializeDatabase.java
β”‚   β”‚   β”‚               β”‚       β”œβ”€β”€ IsDatabasePopulated.java
β”‚   β”‚   β”‚               β”‚       └── UpdateDriver.java
β”‚   β”‚   β”‚               └── util
β”‚   β”‚   β”‚                   └── DocumentationHelper.java
β”‚   β”‚   └── resources
β”‚   β”‚       β”œβ”€β”€ application.properties
β”‚   β”‚       └── data
β”‚   β”‚           └── drivers.json
β”‚   └── test
β”‚       └── java
β”‚           └── com
β”‚               └── motorsport
β”‚                   └── formula1
β”‚                       └── usecase
β”‚                           └── impl
β”‚                               β”œβ”€β”€ CreateDriversTest.java
β”‚                               β”œβ”€β”€ DeleteDriverTest.java
β”‚                               β”œβ”€β”€ GetAllDriversTest.java
β”‚                               β”œβ”€β”€ GetDriversFromJsonTest.java
β”‚                               β”œβ”€β”€ GetDriversWithFiltersTest.java
β”‚                               β”œβ”€β”€ GetDuplicateDriversTest.java
β”‚                               β”œβ”€β”€ InitializeDatabaseTest.java
β”‚                               β”œβ”€β”€ IsDatabasePopulatedTest.java
β”‚                               └── UpdateDriverTest.java
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ mvnw
β”œβ”€β”€ mvnw.cmd
β”œβ”€β”€ pom.xml
β”œβ”€β”€ .gitignore
│── LICENSE
└── README.md

Usage

API Endpoints

Endpoint Method Description
/api GET Check the service status with a message
/api/drivers GET Get all drivers, with optional filters
/api/drivers POST Add new drivers to the database
/api/drivers/{id} PUT Update driver information by ID
/api/drivers/{id} DELETE Delete a driver by ID
/api/drivers/initialize POST Initialize the database with sample data

API Documentation

Swagger

Once the application is running, you can access the generated OpenAPI docs at:

Postman

You can also view and test the API using the following Postman docs:

Running Code Quality and Tests Locally

If you have Java and Maven installed locally, you can use the following commands:

Format code with Spotless

mvn spotless:apply

Run all tests

mvn test

License

This project is licensed under the MIT License.

Acknowledgements

About

CRUD API of F1 drivers 🏁🏎️ that showcases the use of Spring Boot, MySQL & Docker as its main technologies.

Topics

Resources

License

Stars

Watchers

Forks