
Express.js is the most popular Node.js framework for web development. It’s fast and has a large community behind it. It is easy to learn and also has a lot of modules and middleware available for use.
Well organized expess.js project structure example
A good project structure is really important cause it will help you maintain the project in long run. This is a production project structure that can help you organize the code. DiscountChai follow this project structure. I will explain further how I organized the project below:

Folder Structure
routes – This folder will contain routes for each resource. It can be further broken down by versions like v1 or v2 to separate the route files by the version of the API.
const – Here you will define constants based on your projects needs.
configs – all your configurations settings define here. For example database config
controllers – This folder holds all the controllers needed for the application. These controller methods get the request from the routes and convert them to HTTP responses with the use of any middleware as necessary.
error_handler – This is were you implement all the error handler for your application. Like mongodb error, jwt error and multer error handler.
helpers – It also known as utils. All utility function goes here. It will also act as a place to put shared logic. For example a simple helper to calculate paginate SQL query can be put in general.helper.js
middleware – All your middleware goes here for example authentication, logging, validation middleware.
models – Define all your business domain model here.
repositories – Define all your database query here.
seed – define your database seed here.
services – It contain all your business logic. For example user.service.js will contain all user related logic. After performing the business logic it will call user.repository.js if needed.
templates – it contain email template for signup, other promotion.
Conclusion
Thank you for taking time to read, In this article, we have seen how to organize express project. By following this structure adding new feature and fixing bug was easy for me. This structure helps me to scale up the DiscountChai application easily.