π SmartLeads β Lead Management Dashboard
A full-stack Lead Management Dashboard built with the MERN stack (MongoDB, Express.js, React.js, Node.js) using TypeScript throughout. Features JWT authentication, role-based access control, advanced filtering, CSV export, and a premium glassmorphism UI.
π‘ Test Credentials β Register a new account directly on the live site.
JWT Authentication β Secure register/login with bcrypt password hashing
RBAC β Admin and Sales User roles with permission-based access
Lead CRUD β Create, Read, Update, Delete leads with validation
Advanced Filtering β Filter by status, source, search by name/email β all combinable
Backend Pagination β Proper skip/limit with metadata (10 per page)
Debounced Search β 400ms debounce on search input
CSV Export β Export filtered leads as CSV
Dark Mode β System-preference-aware with manual toggle
Premium glassmorphism design with gradient accents
Responsive layout with collapsible sidebar
Loading skeletons, empty states, and error handling
Animated transitions and micro-interactions
Toast notifications for all actions
Layer
Technology
Frontend
React 19, TypeScript, TailwindCSS v4, Vite
Backend
Node.js, Express.js, TypeScript
Database
MongoDB + Mongoose
Auth
JWT + bcrypt
Deployment
Vercel (frontend) + Render (backend) + MongoDB Atlas
DevOps
Docker + Docker Compose
βββ client/ # React Frontend (Vite)
β βββ src/
β β βββ components/
β β β βββ common/ # Reusable components
β β β βββ layout/ # Layout component
β β β βββ leads/ # Lead-specific components
β β βββ context/ # Auth & Theme contexts
β β βββ hooks/ # Custom hooks (useDebounce)
β β βββ pages/ # Page components
β β βββ services/ # API service layer
β β βββ types/ # TypeScript interfaces
β β βββ App.tsx
β βββ vercel.json # SPA routing config
β βββ Dockerfile
β βββ nginx.conf
βββ server/ # Express Backend
β βββ src/
β β βββ config/ # Database config
β β βββ controllers/ # Route controllers
β β βββ middleware/ # Auth, RBAC, error handling
β β βββ models/ # Mongoose models
β β βββ routes/ # API routes
β β βββ types/ # TypeScript interfaces
β β βββ validators/ # Request validators
β β βββ server.ts
β βββ Dockerfile
βββ docker-compose.yml
βββ .env.example
βββ README.md
Node.js v18+
MongoDB (local or Atlas)
npm or yarn
git clone https://github.com/Amcodeit/smart-lead.git
cd smart-lead
cd server
cp ../.env.example .env # Edit with your MongoDB URI & JWT secret
npm install
npm run dev
cd client
npm install
npm run dev
4. Docker Setup (Alternative)
docker-compose up --build
This project is deployed using a split architecture:
Part
Platform
Notes
Frontend
Vercel
Root dir: client, auto-deploys on push
Backend
Render
Docker-based, root dir: server
Database
MongoDB Atlas
Free M0 cluster
Required Environment Variables
Backend (Render):
Variable
Description
PORT
5000
NODE_ENV
production
MONGODB_URI
MongoDB Atlas connection string
JWT_SECRET
Strong random secret
JWT_EXPIRES_IN
7d
CLIENT_URL
Your Vercel frontend URL
Frontend (Vercel):
Variable
Description
VITE_API_URL
Your Render backend URL + /api
π Environment Variables (Local)
Copy .env.example and configure:
Variable
Description
Default
PORT
Server port
5000
MONGODB_URI
MongoDB connection string
mongodb://localhost:27017/smart-leads
JWT_SECRET
JWT signing secret
(change in production!)
JWT_EXPIRES_IN
Token expiration
7d
CLIENT_URL
Frontend URL for CORS
http://localhost:5173
Method
Endpoint
Description
Access
POST
/api/auth/register
Register new user
Public
POST
/api/auth/login
Login user
Public
GET
/api/auth/me
Get current user profile
Private
Method
Endpoint
Description
Access
GET
/api/leads
Get leads (paginated, filterable)
Private
GET
/api/leads/:id
Get single lead
Private
POST
/api/leads
Create new lead
Private
PUT
/api/leads/:id
Update lead
Private
DELETE
/api/leads/:id
Delete lead
Admin only
GET
/api/leads/export/csv
Export leads as CSV
Private
GET
/api/leads/stats/overview
Get dashboard stats
Private
GET
/api/health
Health check
Public
Query Parameters (GET /api/leads)
Param
Type
Description
status
string
Filter: New, Contacted, Qualified, Lost
source
string
Filter: Website, Instagram, Referral
search
string
Search by name or email
sort
string
latest (default) or oldest
page
number
Page number (default: 1)
limit
number
Records per page (default: 10)
{
"success" : true ,
"message" : " Leads retrieved successfully." ,
"data" : {
"records" : [... ],
"pagination" : {
"currentPage" : 1 ,
"totalPages" : 5 ,
"totalRecords" : 48 ,
"limit" : 10 ,
"hasNextPage" : true ,
"hasPrevPage" : false
}
}
}
Feature
Admin
Sales User
View all leads
β
β (own only)
Create leads
β
β
Update leads
β
(all)
β
(own only)
Delete leads
β
β
Export CSV
β
β
(own only)
Dashboard stats
β
(all)
β
(own only)
# Backend (hot reload with ts-node)
cd server && npm run dev
# Frontend (Vite dev server)
cd client && npm run dev