Giter Site home page Giter Site logo

Comments (1)

stemmlerjs avatar stemmlerjs commented on May 12, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.