A full-stack Customer Relationship Management system with AI-powered lead scoring and automatic assignment capabilities.
- 📊 Lead Management: Complete CRUD operations for lead management
- 🤖 AI Lead Scoring: Automatic lead scoring (0-100) using Google Gemini AI
- 🎯 Auto-Assignment: Smart lead assignment based on AI scores:
- High Priority (70-100): → Senior Sales Rep
- Medium Priority (40-69): → Junior Sales Rep
- Low Priority (0-39): → Nurture Later
- 📈 Dashboard: Real-time assignment distribution and lead analytics
- 🎨 Modern UI: Clean, responsive interface with Material-UI components
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite, Material-UI (MUI) |
| Backend | Node.js, Express.js |
| Database | PostgreSQL with Sequelize ORM |
| AI Integration | Google Gemini AI (gemini-1.5-flash) |
| Styling | Material-UI Components & Custom CSS |
crm-system/
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── App.jsx # Main application component
│ │ ├── App.css # Styling
│ │ └── main.jsx # Application entry point
│ ├── package.json
│ └── vite.config.js
├── backend/ # Node.js backend API
│ ├── config/
│ │ └── database.js # Database configuration
│ ├── controllers/
│ │ └── leadController.js # Lead CRUD operations
│ ├── models/
│ │ └── Lead.js # Lead database model
│ ├── routes/
│ │ └── leadRoutes.js # API route definitions
│ ├── services/
│ │ ├── aiService.js # Gemini AI integration
│ │ └── assignmentService.js # Auto-assignment logic
│ ├── .env # Environment variables (create from .env.example)
│ ├── package.json
│ └── index.js # Server entry point
├── .env.example # Environment variables template
└── README.md # This file
- Node.js (v16 or higher)
- PostgreSQL (v12 or higher)
- Google Gemini API Key (Get it here)
git clone <repository-url>
cd crm-system- Install PostgreSQL (if not already installed)
- Create database and user:
-- Connect to PostgreSQL as superuser
sudo -u postgres psql
-- Create database and user
CREATE DATABASE crm_db;
CREATE USER crm_user WITH ENCRYPTED PASSWORD 'crm_pass';
GRANT ALL PRIVILEGES ON DATABASE crm_db TO crm_user;
-- Exit PostgreSQL
\q# Navigate to backend directory
cd backend
# Install dependencies
npm install
# Create environment file
cp ../.env.example .env
# Edit .env file with your configurations
nano .envConfigure your .env file:
PORT=5003
DB_HOST=localhost
DB_PORT=5432
DB_NAME=crm_db
DB_USER=crm_user
DB_PASS=crm_pass
GEMINI_API_KEY=your_actual_gemini_api_key_hereStart the backend server:
# Development mode (with auto-restart)
npm run dev
# OR Production mode
npm startThe backend will be running at http://localhost:5003
# Navigate to frontend directory (from project root)
cd frontend
# Install dependencies
npm install
# Start the development server
npm run devThe frontend will be running at http://localhost:5173
| Variable | Description | Example |
|---|---|---|
PORT |
Backend server port | 5003 |
DB_HOST |
PostgreSQL host | localhost |
DB_PORT |
PostgreSQL port | 5432 |
DB_NAME |
Database name | crm_db |
DB_USER |
Database username | crm_user |
DB_PASS |
Database password | crm_pass |
GEMINI_API_KEY |
Google Gemini AI API key | AIzaSy... |
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Get all leads |
GET |
/:id |
Get lead by ID |
POST |
/ |
Create new lead |
PUT |
/:id |
Update lead |
DELETE |
/:id |
Delete lead |
POST |
/:id/score |
AI Score & Auto-assign lead |
Create a Lead:
curl -X POST http://localhost:5003/api/leads \
-H "Content-Type: application/json" \
-d '{
"name": "John Smith",
"email": "john@example.com",
"source": "Website",
"interestLevel": "High",
"description": "Enterprise client with $100k budget"
}'Score & Auto-assign:
curl -X POST http://localhost:5003/api/leads/1/scoreThe system uses Google Gemini AI to analyze leads based on:
- Interest Level: Customer's expressed interest
- Source: Lead acquisition channel
- Description: Detailed lead information
- Budget Indicators: Financial capability signals
- Urgency Factors: Timeline requirements
if (score >= 70) {
assignedTo = 'Senior Sales Rep'; // High-value leads
} else if (score >= 40) {
assignedTo = 'Junior Sales Rep'; // Medium-value leads
} else {
assignedTo = 'Nurture Later'; // Low-value leads
}- 📊 Dashboard: Real-time assignment statistics
- 🔍 Lead Details: Comprehensive lead view with AI analysis
- ✏️ Inline Editing: Edit leads directly in the table
- 🎯 Smart Actions: Context-aware action buttons
- 📱 Responsive Design: Works on all device sizes
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
🎉 Happy CRM-ing!