Skip to content
Discussion options

You must be logged in to vote

For a MERN app that is expected to grow, I’d recommend moving from a pure layer-based structure (controllers, routes, models, etc.) to a feature-based structure with shared infrastructure.

That usually scales better because React encourages breaking the UI into reusable pieces and reusing logic through custom hooks, while Express is designed around routers and middleware that can be grouped by concern. ([React]1)

A good rule is:

  • Group business code by feature: auth, users, products, dashboard
  • Keep cross-cutting code shared: middleware, utils, config, lib, types, validators

So instead of this:

backend/
  controllers/
  models/
  routes/

prefer something like this:

backend/
  src/
    ap…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sandaru3n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Ask and answer questions about GitHub features and usage Programming Help Discussions around programming languages, open source and software development Welcome 🎉 Used to greet and highlight first-time discussion participants. Welcome to the community! source:ui Discussions created via Community GitHub templates
2 participants