Language > US/en·
| Others: ES/es·
Small web project used to teach the fundamentals of microservices. Developed with Spring Boot . Utilizes REST for creating a simple product inventory application.
- Spring Boot: Web + MongoDB & Maven.
- REST: RESTful API architecture integration and communication with the product inventory system.
- MongoDB (Atlas): Cloud NoSQL database
Configuration: Java 17+, Maven, Mongo DB
- CRUD Operations: Full support for Create, Read, Update, and Delete operations on the product inventory.
- MongoDB as NOSQL DB: When using a Mongo database you can take advantage of setting up your repository extending of MongoRepository, to get automatic query generation based on naming conventions.
Example (ProductRepository.java):
public interface ProductRepository extends MongoRepository<Product, String>
- Separation of Concerns: The Product class represents the persistent entity stored in the database, while the ProductDTO class is a data transfer object used to communicate with other layers of the applicationinventory.
- Data Mapping: Utilizing ModelMapper to easily map the fields between the Product and ProductDTO classes which can help to achieve precise control over the data that is exposed and transferred in the API.
Example (ProductController.java):
@GetMapping(value = "/byProductName/{productName}")
public ProductDTO getProductByProductName(@PathVariable("productName") String productName) {
return ObjectMapperUtils.map(productService.findByProductName(productName), ProductDTO.class);
}
HTTP Method | Endpoint | Description |
---|---|---|
GET | / |
Retrieves all products in the inventory. |
GET | /byProductName/{productName} |
Retrieves a product by its name. |
POST | /save |
Saves or updates a product in the inventory. |
DELETE | /delete/{productName} |
Deletes a product from the inventory by its name. |
end.