Skip to content
Discussion options

You must be logged in to vote

A scalable Node.js structure should be feature-based rather than purely layer-based.
Instead of:

/controllers  
/services  
/routes  

Prefer grouping by feature:

/modules  
  /auth  
    auth.controller.js  
    auth.service.js  
    auth.routes.js  
  /users  
    user.controller.js  
    user.service.js  
    user.routes.js  

Why?

  1. Better scalability – each feature is self-contained.
  2. Easier onboarding – developers work inside one domain folder.
  3. Reduced cross-dependency mess.

For production apps:

  • Use a central error middleware.
  • Keep business logic in services.
  • Keep controllers thin.
  • Avoid placing logic in routes.

This keeps your app maintainable as it grows.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants