Comments (1)
@webberwang, thanks for your question! There are several completely valid arguments for doing it either way.
Background information here is that Sequelize does want you to have all the modules in a single folder to initialize them, but if we really needed to separate concerns by splitting up the models, that would certainly be a priority. That being said, we've made a conscious decision for this project to build this as a monolith.
One of the key properties of the monolith is that, while it does have logical boundaries around the services (users
, forum
), there is a single database that it relies on. This means that the models for users
and forum
are both on the same database instance. That led me to make the decision to put all the models in a shared folder.
Alternatively, one could argue that putting the Sequelize models in the subdomain that they belong could yield a better developer experience, because it would mean less flipping between the shared folder and the target modules folder. That's a great argument, and I welcome you to make that decision for yourself. If it works better for you and your team, I think that's an idea. It would, however, mean you have to do a little more stitching to get all the models initialized. You may need to write a script to throw all of the models in a shared folder before initializing Sequelize.
In a truly distributed architecture, rather than a monolithic one like this, current best practices are to implement the Database per service pattern. In an architecture like this, we would have not only the logical boundaries but physical ones as well. That means loosely coupled services. In this architecture, a member
from forum
knows nothing about a user
from the users
subdomain; this complicates transactions across services, but it's a necessary complexity. This project is predominantly about demonstrating the main DDD ideas in practice; hopefully, you're seeing how a distributed architecture would only add to that challenge, and how it influenced the folder structure here.
I hope that was helpful. Let me know if you have any more questions.
from ddd-forum.
Related Issues (20)
- Why entity id is implemented as Entity and not ValueObject?
- Running `npm install` inside public/app modifies package-lock.json
- Controller validation with Joi HOT 4
- What to do with persistence data if business rules change HOT 1
- [Question] Uniqueness validation & constructing domain objects in read operations (queries)
- There are no tests? HOT 1
- Guard against value objects
- UserId as Value Object || Entity ? HOT 1
- `null` values in the `Map.toDomain(c)` return. HOT 4
- [Question] How best to break up large use cases? HOT 1
- [Question] Sharing of errors between client & server. HOT 1
- [Question] Passing type and not using it in interface
- [Question]: Why not use Result everywhere? HOT 5
- [Question]: Usage of left/right monad & try/catch HOT 2
- [Question]: userId property in User class (also postId in Post etc.) HOT 3
- Making local dev easier and cleaning up the docs HOT 1
- Auto Logout if Refresh Token Expire frontend App?
- [Question] Typescript errors in Result class
- Injection of Domain Services
- Combined error in result issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ddd-forum.