Question about references to objects from different module #20
Replies: 4 comments 2 replies
-
Hi, For the first part of your question, I used a dedicated database for each module instead of having a single database with different schemas for each module. Most of the time, a single database with separate schemas per module is sufficient when we don’t have a large application and know we won’t be moving to a microservices architecture soon. This approach is more straightforward and easier to maintain. However, on the other hand, we can separate databases for each module when we know the system is large, and the likelihood of migrating to microservices is high. Although this setup is more complex, it simplifies things when we eventually move to microservices, as each module will already have its own database, reducing additional work. Note: To retrieve data from one module for another, I currently use REST or gRPC, which is not the most performant approach. I've created issue #18 to implement a gateway pattern for synchronous communication between modules using in-memory calls with MediatR, allowing autonomous operation for each module. Regarding the booking bounded context, it currently manages book reservations and will handle payments in the future. The separation of the boundaries here is just an example, and I’ve considered each boundary responsible for its own dedicated business functionality. |
Beta Was this translation helpful? Give feedback.
-
Hi. |
Beta Was this translation helpful? Give feedback.
-
How you avoid circular dependencies with that approach? With gRPC you can achieve that easily, but with Mediatr approach Flight module would need a reference to Booking module, and the other way around. How do you make that work? You would maybe need to create separate projects containing only the interfaces? |
Beta Was this translation helpful? Give feedback.
-
Excellent, thanks for clarifying. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi.
I've got a question about how the different modules are structured in the solution.
So we have modules for Flight, Booking and Passenger (well, and Users but that's not relevant for my question).
My point is how you define these modules and how you reference each others.
Let me put an example.
A Booking depends on a Flight and a Passenger. Let's say we want to add a new feature in Booking module which is GetBookingById and the response must contain booking details plus fight details: do we need to make a call to Flight service for it and then aggregate booking and flight in the same response object?
With that context, wouldn't make more sense Flight and Booking live in the same module? That way a simple
b.Include(b => b .Flight)
would make life easier.Another argument would be: a Booking is a secondary entity, it cannot exist if we don't have a flight, so is it the same boundaries and therefore same module?
Sorry if too generic, just trying to understand whether you've organized the solution like that to illustrate how the architecture works or because is the correct thing to do in this domain?
Beta Was this translation helpful? Give feedback.
All reactions