A production-ready Node.js + Express.js backend starter with a scalable architecture, best practices, authentication-ready structure, validation, middleware, cron jobs, Swagger documentation, and clean code organization.
Designed for developers who want to start building REST APIs quickly without spending time setting up the project structure.
- ✅ Clean & Scalable Architecture
- ✅ Express.js REST API
- ✅ MongoDB & Mongoose Integration
- ✅ JWT Authentication Ready
- ✅ Role-Based Authorization (RBAC)
- ✅ Request Validation (Joi)
- ✅ Global Error Handling
- ✅ Async Error Wrapper
- ✅ Standard API Response Format
- ✅ File Upload Support (Multer)
- ✅ Security Middlewares
- ✅ Logging
- ✅ Swagger API Documentation
- ✅ Cron Jobs Support
- ✅ Background Jobs
- ✅ ESLint & Prettier Configuration
- ✅ Environment Configuration
- ✅ Production Ready Folder Structure
backend/
│
├── src/
│ ├── app.js
│ ├── server.js
│ │
│ ├── config/
│ │ ├── db.js
│ │ └── env.js
│ │
│ ├── constants/
│ │
│ ├── controllers/
│ │ └── auth.controller.js
│ │
│ ├── services/
│ │ └── auth.service.js
│ │
│ ├── repositories/
│ │ └── auth.repository.js
│ │
│ ├── models/
│ │ └── UserModel.js
│ │
│ ├── routes/
│ │ ├── auth.routes.js
│ │ └── index.js
│ │
│ ├── middlewares/
│ │ ├── auth.middleware.js
│ │ ├── role.middleware.js
│ │ ├── error.middleware.js
│ │ ├── validate.middleware.js
│ │ └── upload.middleware.js
│ │
│ ├── validations/
│ │ └── auth.validation.js
│ │
│ ├── utils/
│ │ ├── ApiError.js
│ │ ├── ApiResponse.js
│ │ ├── asyncHandler.js
│ │ └── logger.js
│ │
│ ├── helpers/
│ │ ├── constants.js
│ │ └── messages.js
│ │
│ ├── cron/
│ │ ├── visa.cron.js
│ │ └── document.cron.js
│ │
│ ├── jobs/
│ │ └── notification.job.js
│ │
│ ├── docs/
│ │ └── swagger.js
│ │
│ └── uploads/
│
├── .env
├── .env.example
├── .gitignore
├── .eslintrc.json
├── .prettierrc
├── package.json
└── README.md
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT Authentication
- Joi Validation
- Multer
- Swagger
- Node Cron
- ESLint
- Prettier
Clone the repository
git clone https://github.com/your-username/nodejs-backend-starter.gitMove into the project
cd nodejs-backend-starterInstall dependencies
npm installCreate environment file
cp .env.example .envConfigure your environment variables.
Start development server
npm run devStart production server
npm startnpm install express mongoose dotenv cors helmet compression morgan jsonwebtoken bcryptjs cookie-parser express-rate-limit express-mongo-sanitize hpp multer joi uuid dayjs node-cronnpm install -D nodemon eslint prettier eslint-config-prettier eslint-plugin-prettier- Helmet
- CORS
- Rate Limiter
- Mongo Sanitize
- HPP Protection
- JWT Authentication
- Password Hashing (bcrypt)
- Cookie Parser
Routes
│
Controllers
│
Services
│
Repositories
│
MongoDB
This layered architecture keeps the project clean, maintainable, and easy to scale.
{
"success": true,
"message": "Request completed successfully.",
"data": {}
}{
"success": false,
"message": "Something went wrong.",
"errors": []
}PORT=5000
NODE_ENV=development
MONGO_URI=
JWT_SECRET=
JWT_EXPIRES_IN=7d- Refresh Token Authentication
- Email Verification
- Password Reset
- Redis Caching
- Docker Support
- CI/CD Pipeline
- Unit & Integration Testing
- Socket.IO Support
- AWS S3 File Upload
- Queue Management (BullMQ)
- Multi-Tenant Architecture
Contributions are welcome.
- Fork the repository.
- Create a new feature branch.
- Commit your changes.
- Push to your branch.
- Open a Pull Request.
If you find this project useful, consider giving it a ⭐ on GitHub.
It helps others discover the project and motivates future improvements.
This project is licensed under the MIT License.