Skip to content

Repository files navigation

CRM Backend App

A simple and scalable CRM (Customer Relationship Management) backend built with Node.js, Express.js, MongoDB, and Mongoose. It includes secure JWT authentication, bcrypt password hashing, and role-based access control for Admin and Users.


📁 Project Structure

crm-backend/
├── config/
│ └── connectDB.js # Database connection setup
│
├── controller/
│ ├── auth.controller.js # Signup & Signin logic
│ └── user.controller.js # User CRUD operations
│
├── middleWare/
│ ├── verifyUserRequest.mw.js
│ ├── VerifyUserRequest.mw.js
│ ├── adminAuth.mw.js
│ └── ...
│
├── model/
│ └── user.model.js # Mongoose user schema
│
├── router/
│ ├── api.router.js # Base route aggregator
│ ├── auth/
│ │ └── auth.router.js
│ └── user/
│ └── user.router.js
│
├── .env # Environment variables
├── package.json
└── server.js # Main entry file

⚙️ Installation & Setup

1️⃣ Clone the repository

git clone https://github.com/<your-username>/crm-backend.git
cd crm-backend

2️⃣ Install dependencies

npm install

3️⃣ Configure environment variables

Create a .env file in the root directory and add:

PORT=7777
MONGO_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/crm
JWT_SECRET=<your-secret-key>

4️⃣ Run the server

node index.js

Server will start on:

http://localhost:7777

🧠 Features

✅ User authentication (signup & signin) ✅ JWT-based secure session management ✅ Role-based authorization (Admin, User) ✅ Admin can view and manage all users ✅ Input validation middleware ✅ Modular & maintainable folder structure


🔐 API Endpoints Overview

MethodEndpointDescriptionAccess
POST/crm/api/v1/auth/signupRegister a new userPublic
POST/crm/api/v1/auth/signinSign in a userPublic
GET/crm/api/v1/users/Get all usersAdmin only
GET/crm/api/v1/users/:idGet a user by IDAdmin only
PUT/crm/api/v1/users/:idUpdate user detailsAdmin only

🧑‍💻 Author

dc

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages