I have my API in Spring Boot. I have 2 APIs:
API 1 : Product
API 2 : Ingredient
A product consists of ingredients.
Here is my Ingredient Entity class:
public class Ingredient{
private Long id;
private String name;
private String unit;
private Double quantity = 0.0;
private Double componentCost = 0.0;
private Double componentPrice = 0.0;
}
I have my product Entity class as follows:
public class Product{
private Long id;
private String name;
@OneToMany(cascade= CascadeType.ALL)
@JoinColumn
private List<Ingredient> productComponents = new ArrayList<>(); <----
private Double quantity = 0.0;
}
As we can see productComponents is a List of "Ingredients" class type.
I realized that I am creating them in a Monolithic style, I want to create them following the Microservices architectural design.
This means that I have to create a separate project for each API.
My Question: How to achieve the following in the microservices way:
private List<Ingredient> productComponents = new ArrayList<>();
Since we are going to have "Product" in a project, and "Ingredient" in a separate project ?
Is there a better design to the above example ?