Quick Form Fill Backend is a simple API developed using Spring Boot, designed to manage CRUD (Create, Read, Update, Delete) operations for products. This backend service provides an easy way to handle product data, facilitating integration with front-end applications.
- Key Features
- Tools and Technologies Used
- Prerequisites
- Installation Instructions
- Insomnia Requests
- Usage Examples
- 🆕 Create Products: Add new products with information such as name, price, and description.
- 🔍 Read Products: Retrieve a list of all products or get details of a specific product by its ID.
- ✏️ Update Products: Modify existing product information to keep your data up-to-date.
- 🗑️ Delete Products: Remove products that are no longer needed.
- Aspect: Implements cross-cutting concerns.
- H2 Database: Embedded SQL database.
- Java: General-purpose programming language.
- Lombok: Reduces code verbosity.
- ModelMapper: Facilitates object mapping.
- Reflection: Allows examining and modifying classes at runtime.
- Spring Boot Starter Data JPA: Facilitates database access.
- Spring Boot Starter Test: Support for automated testing.
- Spring Boot Starter Web: Facilitates web application development.
Before running the application, ensure you have the following prerequisites installed:
- Git: Widely-used distributed version control system.
- Java 17: A stable version of the Java Development Kit (JDK).
git clone https://github.com/esperanca-leonardo/quick-form-fill-backend.git
cd quick-form-fill-backend
Depending on your operating system, follow the commands below to start the application.
-
.\mvnw.cmd spring-boot:run
-
First, give execute permission to the script
chmod u+x mvnw
Then, run the command to start the application
./mvnw spring-boot:run
For greater convenience, an Insomnia file containing all the API requests has been created. This allows you to easily test the endpoints without having to manually configure each request. The file is named InsomniaRequests.json
and is located in the root of the project.
To use this file, follow these steps
- Open Insomnia.
- Go to
Application
>Preferences
>Data
tab. - Click on
Import Data
and selectFrom File
. - Choose the
InsomniaRequests.json
file from the root of the project. - The requests will be imported and ready to use.
Below are examples of how to use the Quick Form Fill Backend API endpoints in different scenarios. These examples can help you understand how to interact with the API effectively. By default, the application will run on localhost:8080
.
-
-
To create a new product, send a
POST
request to the/products
endpoint with the product details in the request body. The request body should be in JSON format as shown below{ "name": "Wireless Mouse", "description": "A high-precision wireless mouse", "category": "Electronics", "price": 29.99, "amount": 150, "supplier": "TechSupplier Co.", "brand": "TechBrand" }
-
If the product is created successfully, the API will respond with a status code
201 Created
and the details of the newly created product in the response body{ "id": 1, "name": "Wireless Mouse", "description": "A high-precision wireless mouse", "category": "Electronics", "price": 29.99, "amount": 150, "supplier": "TechSupplier Co.", "brand": "TechBrand" }
-
-
-
To retrieve details of a specific product by its ID, send a
GET
request to the/products/{id}
endpoint, replacing{id}
with the actual product ID. If the product with the specified ID exists, the API will respond with a status code200 OK
and the details of the product in the response body{ "id": 1, "name": "Wireless Mouse", "description": "A high-precision wireless mouse", "category": "Electronics", "price": 29.99, "amount": 150, "supplier": "TechSupplier Co.", "brand": "TechBrand" }
-
If the product with the specified ID, in this case
2
, is not found, the API will respond with a status code404 Not Found
and an error message in the response body{ "status": 404, "timestamp": "2024-05-17T23:00:03-03:00", "type": "https://quickformfill.com.br/product-not-found", "title": "Product not found", "detail": "Product not found with ID: 2" }
-
-
-
To retrieve a list of all products, send a
GET
request to the/products
endpoint. If the request is successful, the API will respond with a status code200 OK
and an array of product details in the response body. For example[ { "id": 1, "name": "Wireless Mouse", "description": "A high-precision wireless mouse", "category": "Electronics", "price": 29.99, "amount": 150, "supplier": "TechSupplier Co.", "brand": "TechBrand" } ]
-
-
-
To update an existing product, send a PUT request to the
/products/{id}
endpoint with the updated product details in the request body. Replace{id}
with the actual product ID. The request body should be in JSON format as shown below.{ "name": "Ergonomic Wireless Mouse", "description": "An ergonomic wireless mouse with additional buttons", "category": "Electronics", "price": 39.99, "amount": 200, "supplier": "TechSupplier Co.", "brand": "TechBrand" }
-
If the product with the specified ID exists and is successfully updated, the API will respond with a status code
200 OK
and the updated details of the product in the response body{ "id": 1, "name": "Ergonomic Wireless Mouse", "description": "An ergonomic wireless mouse with additional buttons", "category": "Electronics", "price": 39.99, "amount": 200, "supplier": "TechSupplier Co.", "brand": "TechBrand" }
-
If the product with the specified ID, in this case
2
, is not found, the API will respond with a status code404 Not Found
and an error message in the response body{ "status": 404, "timestamp": "2024-05-17T23:00:03-03:00", "type": "https://quickformfill.com.br/product-not-found", "title": "Product not found", "detail": "Product not found with ID: 2" }
-
-
-
To delete an existing product, send a DELETE request to the
/products/{id}
endpoint. Replace{id}
with the actual product ID you want to delete. If the product with the specified ID is successfully deleted, the API will respond with a status code204 No Content
and no response body. -
If the product with the specified ID, in this case
2
, is not found, the API will respond with a status code404 Not Found
and an error message in the response body{ "status": 404, "timestamp": "2024-05-17T23:00:03-03:00", "type": "https://quickformfill.com.br/product-not-found", "title": "Product not found", "detail": "Product not found with ID: 2" }
-