Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Node.js Backend Starter

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.


✨ Features

  • ✅ 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

📁 Project 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

🛠 Tech Stack

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • JWT Authentication
  • Joi Validation
  • Multer
  • Swagger
  • Node Cron
  • ESLint
  • Prettier

📦 Installation

Clone the repository

git clone https://github.com/your-username/nodejs-backend-starter.git

Move into the project

cd nodejs-backend-starter

Install dependencies

npm install

Create environment file

cp .env.example .env

Configure your environment variables.

Start development server

npm run dev

Start production server

npm start

📦 Production Dependencies

npm install express mongoose dotenv cors helmet compression morgan jsonwebtoken bcryptjs cookie-parser express-rate-limit express-mongo-sanitize hpp multer joi uuid dayjs node-cron

🧰 Development Dependencies

npm install -D nodemon eslint prettier eslint-config-prettier eslint-plugin-prettier

🔒 Included Security Features

  • Helmet
  • CORS
  • Rate Limiter
  • Mongo Sanitize
  • HPP Protection
  • JWT Authentication
  • Password Hashing (bcrypt)
  • Cookie Parser

📚 API Architecture

Routes
   │
Controllers
   │
Services
   │
Repositories
   │
MongoDB

This layered architecture keeps the project clean, maintainable, and easy to scale.


📖 API Response Format

Success

{
  "success": true,
  "message": "Request completed successfully.",
  "data": {}
}

Error

{
  "success": false,
  "message": "Something went wrong.",
  "errors": []
}

🌍 Environment Variables

PORT=5000

NODE_ENV=development

MONGO_URI=

JWT_SECRET=

JWT_EXPIRES_IN=7d

🚀 Future Enhancements

  • 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

🤝 Contributing

Contributions are welcome.

  1. Fork the repository.
  2. Create a new feature branch.
  3. Commit your changes.
  4. Push to your branch.
  5. Open a Pull Request.

⭐ Support

If you find this project useful, consider giving it a ⭐ on GitHub.

It helps others discover the project and motivates future improvements.


📄 License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages