Do not take this question of uncoupling too literally because it risks doing so in the wrong place.
Try to bring the idea of micro service to the real world and see what happens. Imagine the following situation:
- You enter a restaurant and sit at a TABLE;
- The waiter come and take the ORDER and take the TABLE number;
- The waiter, takes the ORDER up to kitchen who prepares the REQUEST and doorbell when you are
ready;
- The waiter serves the dish on the TABLE;
- You consume the ORDER and ask the waiter THE ACCOUNT;
- The waiter go to Té the cashier, ask for the BILL and give it to you;
- You go up to the cashier, pays the bill and leaves.
Note that in this case micro services are represented by waiter, kitchen and cashier.
The waiter doesn’t know anything about making food, the kitchen doesn’t know anything about serving and the cashier only knows they have to charge, meaning they are UNCOUPLED and work independently.
But see that they all have the customer view (represented by MESA) and ORDER. Here it is clear that you should not separate these entities and what happens in this type of architecture is the data REDUNDANCY because each service has to have a copy of the REQUEST with the TABLE number.
Therefore, Microservices although independent and asynchronous have to store the same information and to ensure this have to have an efficient form of communication (sockets is a good example).
If you read the article from Martin Fowler will see that it recommends to start same monolithic and create micro services only when necessary. To do this at the beginning is waste of time.
I have no experience with micro services, but if I understand correctly you want to decouple
Pedido
ofCliente
, so that they can reside in separate systems (maybe in different Bds, or even in different servers), is that it? If yes, I don’t know anything ready in Django to do that, I believe you would have to store in the fieldcliente
not a foreign key but a simple (integer? string?) value that uniquely identifies that same customer between different services. So to get the customer associated with that order, you would make aCliente.objects.get(xxx=p.cliente).nome
.– mgibsonbr
That, is, doesn’t really have much information yet on how to do this in practice, in theory we see tons of articles saying what it is, showing the advantages but showing an implementation example is difficult, in that case then I would lose a good part of the advantages of Django’s ORM, I would have to do a very manual job. I don’t have more time, I’ll do monolithic and there in front we change the architecture, vlw
– Rodrigo Rodrigues