A full-stack Lead Management System built with the MERN stack (MongoDB, Express.js, React, Node.js) to help businesses capture, manage, track, and convert leads into customers.
- Authentication & Authorization: JWT-based authentication with role-based access control
- Lead Management: Complete CRUD operations for leads with advanced filtering and search
- Lead Scoring: Automatic lead scoring based on various factors
- Status Pipeline: Customizable lead status workflow (New β Contacted β Qualified β Negotiation β Closed Won/Lost)
- User Management: Team member management with different roles (Admin, Sales Manager, Sales Executive)
- Communication Tracking: Log and track all interactions with leads
- Analytics Dashboard: Visual insights and performance metrics
- Role-based Permissions: Different access levels based on user roles
- Lead Assignment: Assign leads to team members
- Bulk Operations: Bulk assign leads to users
- Overdue Tracking: Track overdue follow-ups and tasks
- Real-time Notifications: In-app notifications for important events
- Responsive Design: Mobile-friendly interface
- Data Export: Export leads and reports
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication
- bcryptjs - Password hashing
- express-validator - Input validation
- cors - Cross-origin resource sharing
- dotenv - Environment variables
- React - UI library
- Vite - Build tool
- Redux Toolkit - State management
- React Router - Routing
- Tailwind CSS - Styling
- shadcn/ui - UI components
- Lucide React - Icons
- React Hook Form - Form handling
- Zod - Schema validation
- Axios - HTTP client
- Sonner - Toast notifications
lead-management-system/
βββ backend/
β βββ config/
β β βββ database.js
β βββ controllers/
β β βββ authController.js
β β βββ leadController.js
β β βββ userController.js
β β βββ interactionController.js
β βββ middleware/
β β βββ auth.js
β β βββ validation.js
β βββ models/
β β βββ User.js
β β βββ Lead.js
β β βββ Interaction.js
β βββ routes/
β β βββ auth.js
β β βββ users.js
β β βββ leads.js
β β βββ interactions.js
β βββ utils/
β βββ uploads/
β βββ .env
β βββ server.js
β βββ package.json
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ ui/
β β β βββ Layout.jsx
β β β βββ AuthLayout.jsx
β β β βββ Sidebar.jsx
β β β βββ Header.jsx
β β βββ pages/
β β β βββ auth/
β β β β βββ Login.jsx
β β β β βββ Register.jsx
β β β βββ leads/
β β β βββ users/
β β β βββ Dashboard.jsx
β β β βββ Profile.jsx
β β β βββ Analytics.jsx
β β βββ store/
β β β βββ slices/
β β β β βββ authSlice.js
β β β β βββ leadSlice.js
β β β β βββ userSlice.js
β β β β βββ interactionSlice.js
β β β βββ store.js
β β βββ hooks/
β β βββ lib/
β β βββ App.jsx
β β βββ main.jsx
β βββ .env
β βββ package.json
β βββ vite.config.js
βββ README.md
- Node.js (v18 or higher)
- MongoDB (local or MongoDB Atlas)
- npm or pnpm
-
Clone the repository
git clone <repository-url> cd lead-management-system
-
Backend Setup
cd backend npm install # Create .env file cp .env.example .env # Edit .env with your configuration # Start the server npm run dev
-
Frontend Setup
cd frontend pnpm install # Create .env file echo "VITE_API_URL=http://localhost:5000/api" > .env # Start the development server pnpm run dev
NODE_ENV=development
PORT=5000
MONGODB_URI=mongodb://localhost:27017/lead_management_system
JWT_SECRET=your_jwt_secret_key_here
JWT_EXPIRE=30d
CLIENT_URL=http://localhost:3000
# Email Configuration (SendGrid)
SENDGRID_API_KEY=your_sendgrid_api_key_here
FROM_EMAIL=[email protected]
# Twilio Configuration (SMS/WhatsApp)
TWILIO_ACCOUNT_SID=your_twilio_account_sid_here
TWILIO_AUTH_TOKEN=your_twilio_auth_token_here
TWILIO_PHONE_NUMBER=your_twilio_phone_number_here
VITE_API_URL=http://localhost:5000/api
- Full system access
- User management (create, update, delete users)
- All lead operations
- System analytics and reports
- Role assignment
- User management (create, update users)
- All lead operations
- Team analytics and reports
- Lead assignment
- View all team activities
- Personal lead management
- View assigned leads only
- Create and update own interactions
- Personal performance metrics
Register a new user
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"password": "password123",
"role": "Sales Executive",
"phone": "+1234567890",
"department": "Sales"
}
Login user
{
"email": "[email protected]",
"password": "password123"
}
Get current user profile (Protected)
Update user profile (Protected)
Change password (Protected)
Get all leads with filtering and pagination (Protected) Query parameters:
page
: Page numberlimit
: Items per pagesearch
: Search termstatus
: Lead statussource
: Lead sourcepriority
: Lead priorityassignedTo
: Assigned user ID
Create new lead (Protected)
{
"firstName": "Jane",
"lastName": "Smith",
"email": "[email protected]",
"phone": "+1234567890",
"company": "ABC Corp",
"source": "Website",
"assignedTo": "user_id"
}
Get single lead (Protected)
Update lead (Protected)
Delete lead (Admin/Manager only)
Get lead statistics (Protected)
Get overdue leads (Protected)
Bulk assign leads (Admin/Manager only)
Get all users (Admin/Manager only)
Create new user (Admin/Manager only)
Get single user (Protected)
Update user (Protected)
Delete user (Admin only)
Get user statistics (Admin/Manager only)
Get all interactions (Protected)
Create new interaction (Protected)
Get single interaction (Protected)
Update interaction (Protected)
Delete interaction (Protected)
Get interactions for specific lead (Protected)
Get upcoming tasks (Protected)
Get overdue tasks (Protected)
Get interaction statistics (Protected)
The application uses a modern, responsive design with:
- Dark/Light theme support
- Mobile-first responsive design
- Accessible components
- Consistent design system
- Professional color palette
- Smooth animations and transitions
- Set up MongoDB Atlas or your preferred MongoDB hosting
- Configure environment variables for production
- Deploy to platforms like Heroku, Railway, or AWS
- Ensure CORS is configured for your frontend domain
- Build the production version:
pnpm run build
- Deploy the
dist
folder to platforms like Vercel, Netlify, or AWS S3 - Configure environment variables for production API URL
cd backend
npm test
cd frontend
pnpm test
- Database indexing for faster queries
- Pagination for large datasets
- Lazy loading for React components
- Memoization for expensive calculations
- Optimized bundle size with code splitting
- Caching strategies for API responses
- JWT token authentication
- Password hashing with bcrypt
- Input validation and sanitization
- CORS protection
- Rate limiting (recommended for production)
- Environment variable protection
- Role-based access control
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
For support and questions:
- Create an issue in the repository
- Contact the development team
- Check the documentation
- Email integration (SendGrid)
- SMS/WhatsApp integration (Twilio)
- Advanced analytics and reporting
- CSV import/export functionality
- Kanban board for lead pipeline
- Calendar integration
- Mobile app (React Native)
- API rate limiting
- Advanced search with Elasticsearch
- Real-time notifications with WebSocket
Built with β€οΈ using the MERN stack