A modern, feature-rich Customer Relationship Management (CRM) application built with the MERN stack. This application provides comprehensive customer and lead management capabilities with real-time updates, drag-and-drop functionality, and an intuitive dashboard.
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Installation & Setup
- Environment Variables
- Running the Application
- API Documentation
- Database Schema
- Testing
- Deployment
- Contributing
- User registration and login with JWT tokens
- Protected routes and middleware
- Role-based access control
- Secure password hashing with bcrypt
- Complete CRUD operations for customers
- Advanced search and filtering
- Pagination support
- Drag-and-drop row reordering
- Bulk operations (delete multiple customers)
- Customer detail views with lead management
- Lead creation and management under customers
- Lead status tracking (New, Contacted, Converted, Lost)
- Lead value tracking
- Status-based filtering
- Real-time updates via WebSocket
- Interactive dashboard with KPI cards
- Customer and lead statistics
- Time-series charts using Recharts
- Real-time data visualization
- Responsive design with Tailwind CSS
- Dark/Light theme support
- Modern component library (shadcn/ui)
- Smooth animations and transitions
- Drag-and-drop interface
- Toast notifications
- WebSocket integration for live updates
- Real-time notifications
- Live data synchronization
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - ODM for MongoDB
- JWT - Authentication tokens
- Joi - Data validation
- Socket.io - Real-time communication
- Jest - Testing framework
- bcryptjs - Password hashing
- React 19 - UI library
- Vite - Build tool and dev server
- Redux Toolkit - State management
- React Router - Client-side routing
- Tailwind CSS - Utility-first CSS
- shadcn/ui - Component library
- Recharts - Data visualization
- @dnd-kit - Drag and drop
- Socket.io Client - Real-time communication
- Axios - HTTP client
- ESLint - Code linting
- Prettier - Code formatting
- Jest - Unit testing
- Nodemon - Development server
crm/
βββ backend/ # Node.js/Express backend
β βββ src/
β β βββ config/ # Database configuration
β β βββ controllers/ # Route controllers
β β βββ middlewares/ # Custom middleware
β β βββ models/ # Mongoose models
β β βββ routes/ # API routes
β β βββ validators/ # Joi validation schemas
β β βββ app.js # Express app configuration
β β βββ server.js # Server entry point
β βββ tests/ # Backend tests
β βββ package.json
β βββ jest.config.js
βββ frontend/ # React frontend
β βββ src/
β β βββ api/ # API configuration
β β βββ components/ # Reusable components
β β β βββ ui/ # shadcn/ui components
β β β βββ modals/ # Modal components
β β β βββ Sidebar/ # Navigation components
β β βββ hooks/ # Custom React hooks
β β βββ lib/ # Utility functions
β β βββ pages/ # Page components
β β βββ redux/ # Redux store and slices
β β βββ App.jsx # Main app component
β β βββ main.jsx # App entry point
β βββ public/ # Static assets
β βββ package.json
β βββ vite.config.js
βββ README.md
Before running this application, make sure you have the following installed:
- Node.js (v18 or higher)
- npm (v8 or higher)
- MongoDB (local installation or MongoDB Atlas account)
git clone https://github.com/grep-many/crm.git
cd crm
Install backend dependencies:
cd backend
npm install
Install frontend dependencies:
cd ../frontend
npm install
Create a .env
file in the backend
directory:
# Server Configuration
PORT=5000
# Database
MONGODB_URI=mongodb://localhost:27017/crm_database
# For MongoDB Atlas: mongodb+srv://username:password@cluster.mongodb.net/crm_database
# JWT Configuration
JWT_SECRET=your_super_secret_jwt_key_here
JWT_EXPIRES_IN=7d
# CORS Configuration
CORS_ORIGIN=http://localhost:5173
Create a .env
file in the frontend
directory:
# API Configuration
VITE_API_URL=http://localhost:5000/api
- Start the Backend Server:
cd backend
npm run dev
The backend will start on http://localhost:5000
- Start the Frontend Development Server:
cd frontend
npm run dev
The frontend will start on http://localhost:5173
- Access the Application:
Open your browser and navigate to
http://localhost:5173
- Build the Frontend:
cd frontend
npm run build
- Start the Backend in Production:
cd backend
npm start
Method | Endpoint | Description | Body |
---|---|---|---|
POST | /api/auth/register |
Register a new user | { name, email, password } |
POST | /api/auth/login |
Login user | { email, password } |
Method | Endpoint | Description | Query Parameters |
---|---|---|---|
GET | /api/customers |
Get all customers | page , limit , search |
POST | /api/customers |
Create new customer | { name, email, phone, company } |
GET | /api/customers/:id |
Get customer by ID | - |
PUT | /api/customers/:id |
Update customer | { name, email, phone, company } |
DELETE | /api/customers/:id |
Delete customer | - |
Method | Endpoint | Description | Query Parameters |
---|---|---|---|
GET | /api/customers/:customerId/leads |
Get customer leads | status |
POST | /api/customers/:customerId/leads |
Create new lead | { title, description, value, status } |
PUT | /api/customers/:customerId/leads/:leadId |
Update lead | { title, description, value, status } |
DELETE | /api/customers/:customerId/leads/:leadId |
Delete lead | - |
Event | Description | Data |
---|---|---|
connect |
Client connects | - |
disconnect |
Client disconnects | - |
customer_updated |
Customer data updated | { customer } |
lead_updated |
Lead data updated | { lead, customerId } |
{
_id: ObjectId,
name: String,
email: String (unique),
passwordHash: String,
role: String (default: 'user'),
createdAt: Date,
updatedAt: Date
}
{
_id: ObjectId,
name: String,
email: String,
phone: String,
company: String,
ownerId: ObjectId (ref: User),
createdAt: Date,
updatedAt: Date
}
{
_id: ObjectId,
customerId: ObjectId (ref: Customer),
title: String,
description: String,
status: String (enum: ['New', 'Contacted', 'Converted', 'Lost']),
value: Number,
createdAt: Date,
updatedAt: Date
}
cd backend
npm test
-
Set Environment Variables:
PORT
(auto-set by platform)MONGODB_URI
JWT_SECRET
-
Deploy:
cd backend
git push heroku main
-
Set Environment Variables:
VITE_API_URL
(your deployed backend URL)
-
Deploy:
cd frontend
npm run build
# Upload dist folder to your hosting platform
The project includes optimized Docker configuration for easy deployment:
- Clone and navigate to the project:
git clone https://github.com/grep-many/crm.git
cd crm
- Start all services:
docker-compose up -d
- Access the application:
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- MongoDB: localhost:27017
- Frontend: React app with Vite dev server (Port 5173)
- Backend: Node.js API server (Port 5000)
- MongoDB: Database with persistent storage (Port 27017)
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop all services
docker-compose down
# Rebuild and start
docker-compose up --build -d
# Remove all containers and volumes
docker-compose down -v
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- shadcn/ui for the beautiful component library
- Tailwind CSS for the utility-first CSS framework
- React and Express.js communities
- MongoDB for the database solution
Happy Coding! π