# Nodly

**Nodly** is a powerful, interactive CLI tool for instantly scaffolding modern Node.js and Express.js backend projects.  
With Nodly, you can generate a production-ready API server in seconds—complete with your choice of database, mailer, queue, and socket integrations.  
Add controllers, routers, and middlewares with a single command.  
Nodly is perfect for rapid prototyping, scalable API development, and teams who want to skip boilerplate and focus on building features.

---

> **No more manual setup!**  
> Nodly solves the problem of adding and configuring every database, mailer, queue, and socket integration.  
> Just select your options in the CLI and Nodly sets up everything for you—databases, mailers, queues, and sockets are all ready to use out of the box!

---

## ✨ Why Use Nodly?

- **Rapid Prototyping:** Instantly scaffold production-ready Express.js apps with best practices.
- **Customizable:** Choose your stack—databases, queues, mailers, and more—during setup.
- **Productivity:** Add controllers, routers, and middlewares with a single command.
- **Consistency:** Enforces a modular, maintainable project structure.
- **Extensible:** Easily integrate new features or swap technologies as your project grows.

---

## ✨ Features

- Interactive CLI for project setup
- Express.js app scaffolding
- Database, mailer, and queue integrations (BullMQ, RabbitMQ, Kafka)
- Easily add controllers, routers, and middlewares
- Modular and extensible structure
- TypeScript & JavaScript support
- Built-in essential middlewares

---

## 🚀 Installation

Install Nodly globally via npm:

```sh
npm install -g nodly
```

Or use with npx (no global install needed):

```sh
npx nodly
```

---

## 🛠️ Usage

### Create a New Project

```sh
nodly
```

Follow the interactive prompts to scaffold your project with your preferred options.

### Add a Middleware

```sh
nodly add middleware <name>
```
Creates a new middleware file in the `middlewares` directory.

### Add a Controller

```sh
nodly add controller <name>
```
Creates a new controller file in the `controllers` directory.

### Add a Router

```sh
nodly add router <name>
```
Creates a new router file in the `routes` directory.

---

## 🏗️ Supported Databases & ORMs

During project setup, Nodly lets you choose from popular databases and ORMs:

- **MongoDB** (with [Mongoose](https://mongoosejs.com/))
- **PostgreSQL** (with [Prisma](https://www.prisma.io/), [Supabase](https://supabase.com/), [Drizzle](https://orm.drizzle.team/), [TypeORM](https://typeorm.io/))
- **MySQL** (with [Prisma](https://www.prisma.io/), [Drizzle](https://orm.drizzle.team/), [TypeORM](https://typeorm.io/))
- **SQLite** (with [Prisma](https://www.prisma.io/), [Drizzle](https://orm.drizzle.team/), [TypeORM](https://typeorm.io/))
- **Firebase** (with [Firebase Admin SDK](https://firebase.google.com/docs/admin/setup))
- **Redis** (for caching and queues)
- **No ORM:** You can also opt for raw drivers if you prefer.

---

## 🧩 Built-in Middlewares

Nodly includes essential Express middlewares out of the box:

- **Body Parser:** Parses incoming request bodies (JSON, URL-encoded).
- **CORS:** Enables Cross-Origin Resource Sharing.
- **Morgan:** HTTP request logging.
- **Error Handler:** Centralized error handling.
- **Custom Middlewares:** Easily add your own with `nodly add middleware <name>`.

---

## ⚡ Integrations

- **Databases:** MongoDB, PostgreSQL, MySQL, Redis (with Mongoose, Supabase, Drizzle, TypeORM or Prisma)
- **Mailers:** Nodemailer integration (optional)
- **Queues:** BullMQ, RabbitMQ, Kafka (producer/consumer structure)
- **Socket.IO:** Optional real-time support

---

## 📦 Project Structure

```
my-nodly-app/
	|- Dockerfile
	|- server.js
	|- .env
	|- utils/
        |- apiresponses.js
        |- generaterandomid.js
	|- routes/
		|- app.route.js
	|- controllers/
		|- app.controller.js
	|- config/
		|- databases/
		    |- redis.js
		    |- mongoose.js
		    |- mysql2.js
		    |- postgresql.js
		    |- prisma.js
		    |- supabase.js
		    |- typeorm.js
            |- firebase.js
		    |- drizzle.js
		|- queues/
		    |- bullmq/
				|- bullmq.js
		    |- rabbitmq/
				|- rabbitmq.js
		    |- kafka/
				|- producer.js
				|- consumer.js
        |- mailers/
		    |- nodemailer.js
        |- sockets/
            |- socketIO.js
	|- middlewares/
		|- app.middleware.js
```

---

## 📖 Example Commands

```sh
nodly add controller user   # Add new Controller
nodly add middleware auth   # Add new Middleware
nodly add router product    # Add new Router
```

---

## 📝 Scripts

After scaffolding, use standard npm scripts:

```sh
npm install
npm start      # Starts the server
npm run dev    # Starts the server with hot-reloading (and initializes Nodemailer if enabled)
```

---

> **Note:**  
> **All required dependencies are installed automatically!**  
> When you scaffold a new project with Nodly, it installs everything you need—including Express, CORS, Morgan, dotenv, nodemon, express-rate-limit, JWT, and all other core, queue, mailer, and database packages you select.  
> **You do not need to manually install any of these dependencies again.**  
> Just run `npm install` in your generated project and you’re ready to go!

---

## 🧑‍💻 Contributing

Contributions are welcome!  
Fork the repo, create a branch, and submit a pull request.

---

## 💬 Support

For issues, open a ticket on [GitHub Issues](https://github.com/m-irtazaghaffar/nodly/issues).

---

## 🔗 Links

- [Made by M-IrtazaGhaffar](https://github.com/m-irtazaghaffar)
- [NPM Package](https://www.npmjs.com/package/nodly)

---
