npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-backend-structure

v1.0.3

Published

Production-ready Node.js REST API boilerplate with MongoDB/MySQL support, JWT authentication, user management, and analytics tracking

Readme

🚀 Node.js Backend Structure

The Ultimate Production-Ready Boilerplate for Modern Web Development

License: ISC Node.js Version Maintenance

Stop wasting time setting up the same foundation for every project. Node Backend Structure provides a robust, scalable, and secure starting point for your next big idea. Whether you're building a startup MVP, a corporate API, or a personal project, this boilerplate handles the boring stuff so you can focus on what matters: your business logic.


🌟 Why Use This Boilerplate?

In the modern development landscape, speed and security are paramount. Starting from scratch is error-prone and time-consuming.

  • ⚡ Save 10+ Hours of Setup: Authentication, Database connections, File uploads, and Validation are already done.
  • 🛡️ Enterprise-Grade Security: Built-in JWT authentication, password hashing (Bcrypt), and input validation (Joi) ensure your data is safe.
  • 📈 Scalable Architecture: Designed with a clean MVC (Model-View-Controller) pattern that grows with your application.
  • 🔌 Database Agnostic: Native support for MongoDB (Mongoose) and MySQL (Sequelize). Switch or use both!
  • 🛠️ Developer Experience: Hot-reloading, environment configuration, and standardized error handling make coding a breeze.

🚀 Quick Start

Get your project running in seconds with a single command.

1. Create Your Project

Run this command in your terminal. No need to clone or download zip files manually!

npx node-backend-structure

This will magically scaffold the entire project structure in your current directory.

2. Install Dependencies

npm install

3. Start Coding

npm run start

Your server is now running at http://localhost:3000!


✨ Key Features

  • 🔐 Authentication: Complete user registration and login flow with JWT Bearer tokens.
  • 📝 Input Validation: Request data validation using Joi to prevent bad data from reaching your controllers.
  • 📂 File Uploads: Integrated Multer support for handling profile pictures and file uploads locally.
  • 🗄️ Multi-Database Support:
    • MongoDB (Mongoose) for flexible schema-less data.
    • MySQL (Sequelize) for structured relational data.
  • 📡 Standardized API Responses: Consistent success and error response structures across the entire app.
  • ⚙️ Environment Management: Easy configuration using .env files.

🛠️ Tech Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Databases: MongoDB (Mongoose), MySQL (Sequelize)
  • Authentication: JWT (JSON Web Tokens), Bcrypt
  • Validation: Joi
  • File Handling: Multer
  • Utilities: Axios, Moment-timezone, Dotenv

📂 Project Structure

A clean structure that makes sense.

.
├── config/               # Database and App configuration
│   ├── appConfig.js
│   └── db.js
├── src/
│   ├── controllers/      # Request handlers (Business logic)
│   │   └── userController.js
│   ├── libs/             # Reusable libraries
│   │   ├── encLib.js
│   │   ├── jwtLib.js
│   │   ├── passwordLib.js
│   │   ├── responseLib.js
│   │   └── rsaKeyLib.js
│   ├── middlewares/      # Express middlewares
│   │   ├── auth.js
│   │   ├── fileUpload.js
│   │   └── validator.js
│   ├── models/           # Database models
│   │   └── userModel.js
│   └── routes/           # API route definitions
│       └── userRouter.js
├── views/
│   └── index.html
├── uploads/              # Storage for uploaded files
├── .env.example          # Environment variable template
├── .gitignore
├── app.js                # App entry point
└── package.json          # Dependencies and scripts

⚙️ Configure Environment

  1. Copy the example file:

    cp .env.example .env
  2. Edit .env: Open the .env file and update the following variables:

    • MDB_URI: Your MongoDB connection string.
    • JWT_SECRET: A strong secret key for signing tokens.
    • REST_PORT: Port to run the server (default: 3000).

📖 API Documentation

The boilerplate comes with pre-built endpoints to get you started:

| Method | Endpoint | Description | Auth Required | | :--- | :--- | :--- | :--- | | POST | /api/v1/register | Register a new user | ❌ | | POST | /api/v1/login | Login and get JWT token | ❌ | | GET | /api/v1/users | Get list of users | ✅ | | POST | /api/v1/upload-profile-picture | Upload user avatar | ✅ |


🤝 Contributing

Open source is at the heart of this project. We welcome contributions from everyone!

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/amazing-feature).
  3. Commit your changes (git commit -m 'Add some amazing feature').
  4. Push to the branch (git push origin feature/amazing-feature).
  5. Open a Pull Request.