A professional full-stack lead management dashboard built with the MERN stack for efficient lead tracking and management.
Live Demo β’ GitHub Repo β’ API Docs
- Overview
- Features
- Tech Stack
- Quick Start
- Documentation
- Project Structure
- Screenshots
- API Endpoints
- Contributing
LeadFlow is a production-ready lead management system designed to help sales teams efficiently capture, organize, and nurture leads. Built with modern web technologies, it features a responsive dashboard, advanced filtering, real-time search, and role-based access control.
- π Secure JWT Authentication with token refresh mechanism
- π Advanced Filtering & Search - Filter by status, source, search by name/email
- π CSV Export - Download leads data for external analysis
- π₯ Role-Based Access - Admin and Sales user roles
- π± Fully Responsive - Works seamlessly on mobile, tablet, desktop
- π Dark Mode - Modern dark/light theme support
- β‘ Optimized Performance - Debounced search, pagination, caching
- π³ Docker Ready - Complete containerization with Docker Compose
- π¦ Production Deployment - Deployed on Vercel (frontend) and cloud services
| Feature | Description |
|---|---|
| JWT Authentication | Secure token-based auth with refresh tokens |
| Lead CRUD | Create, read, update, delete lead records |
| Advanced Filtering | Filter by status, source, search by name/email |
| Pagination | Backend pagination (10 records/page) |
| CSV Export | Export leads as CSV for offline use |
| Role-Based Access | Admin and Sales User roles |
| Responsive Design | Mobile, tablet, desktop optimized |
| Dark Mode | Full dark/light theme support |
| Feature | Description |
|---|---|
| Debounced Search | Optimized search performance |
| Real-time Validation | Form validation with Zod |
| Error Handling | Comprehensive error management |
| Loading States | Skeleton loaders and spinners |
| Empty States | Helpful messaging when no data |
| Toast Notifications | Success/error feedback with Sonner |
| Docker Compose | Multi-container orchestration |
| API Documentation | Complete API reference |
Framework: Next.js 16 (React 19)
Language: TypeScript 5
Styling: TailwindCSS 4 + Dark Mode
UI Components: shadcn/ui (Radix UI)
Forms: React Hook Form + Zod
State: Zustand + TanStack Query
HTTP Client: Axios with interceptors
Notifications: Sonner
Icons: Lucide React
Deployment: Vercel
Runtime: Node.js 20
Framework: Express.js 5
Language: TypeScript 5
Database: MongoDB 6 + Mongoose
Authentication: JWT + bcrypt
Validation: Zod schemas
Container: Docker + Docker Compose
Deployment: Render/Railway/AWS
- Node.js v18+ (Download)
- MongoDB Local or MongoDB Atlas (Free)
- pnpm or npm
- Docker & Docker Compose (Optional, for containerized setup)
cd server
# Install dependencies
pnpm install
# Setup environment
cp .env.example .env
# Configure .env (see ENV_GUIDE.md)
# - Set MONGODB_URI
# - Configure JWT secrets
# - Set CLIENT_URL
# Start development server
pnpm devcd client
# Install dependencies
pnpm install
# Setup environment
cp .env.example .env.local
# Configure .env.local
# - Set NEXT_PUBLIC_API_URL to http://localhost:5000/api
# Start development server
pnpm devAccess Application:
- Frontend: http://localhost:3000
- Backend: http://localhost:5000
# Start all services
docker compose up -d
# Wait for initialization (30 seconds)
sleep 30
# Verify services
docker compose ps
# Access application
# Frontend: http://localhost:3000
# Backend: http://localhost:5000See DOCKER_SETUP.md for detailed Docker guide.
Complete documentation for all aspects of the project:
| Document | Description |
|---|---|
| SETUP_GUIDE.md | Step-by-step installation and setup |
| API_DOCUMENTATION.md | Complete API endpoints reference |
| ARCHITECTURE.md | System design and patterns |
| DEPLOYMENT.md | Production deployment guide |
| ENV_GUIDE.md | Environment variables configuration |
| DOCKER_SETUP.md | Docker containerization guide |
lead-flow/
βββ server/ # Backend (Node.js)
β βββ src/
β β βββ app.ts # Express app configuration
β β βββ server.ts # Server entry point
β β βββ config/
β β β βββ db.ts # MongoDB connection
β β β βββ env.ts # Environment config
β β βββ middlewares/
β β β βββ auth.middleware.ts # JWT authentication
β β βββ models/
β β β βββ user.ts # User schema
β β β βββ lead.ts # Lead schema
β β βββ modules/
β β β βββ auth/ # Authentication module
β β β β βββ auth.routes.ts
β β β β βββ auth.controllers.ts
β β β β βββ auth.validations.ts
β β β βββ lead/ # Lead management module
β β β βββ lead.routes.ts
β β β βββ lead.controllers.ts
β β β βββ lead.validations.ts
β β βββ types/
β β β βββ user.d.ts
β β β βββ lead.d.ts
β β βββ utils/
β β βββ apiHandler.ts # API response handler
β β βββ asyncHandler.ts # Async middleware
β β βββ jwt.ts # JWT utilities
β βββ Dockerfile
β βββ .env.example
β βββ package.json
β βββ tsconfig.json
β
βββ client/ # Frontend (Next.js)
β βββ app/
β β βββ page.tsx # Home page
β β βββ layout.tsx # Root layout
β β βββ globals.css # Global styles
β β βββ (auth)/ # Auth routes group
β β β βββ login/page.tsx
β β β βββ register/page.tsx
β β β βββ layout.tsx
β β βββ dashboard/ # Dashboard routes
β β βββ page.tsx
β β βββ ...
β βββ components/
β β βββ ui/ # UI components
β β βββ ... # Feature components
β βββ lib/
β β βββ utils.ts
β β βββ api.ts # API client
β βββ public/ # Static files
β βββ Dockerfile
β βββ .env.example
β βββ package.json
β βββ tsconfig.json
β
βββ docker-compose.yml # Docker orchestration
βββ .env.docker # Docker environment variables
βββ README.md # Project overview
βββ SETUP_GUIDE.md # Installation guide
βββ API_DOCUMENTATION.md # API reference
βββ ARCHITECTURE.md # Architecture details
βββ DEPLOYMENT.md # Deployment guide
βββ ENV_GUIDE.md # Environment configuration
βββ DOCKER_SETUP.md # Docker guide
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register new user |
| POST | /api/auth/login |
User login |
| GET | /api/auth/me |
Get current user |
| POST | /api/auth/refresh-token |
Refresh access token |
| POST | /api/auth/logout |
User logout |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/lead |
Create lead |
| GET | /api/lead |
Get all leads (with filters) |
| GET | /api/lead/:id |
Get single lead |
| PATCH | /api/lead/:id |
Update lead |
| DELETE | /api/lead/:id |
Delete lead |
See API_DOCUMENTATION.md for complete details with examples.
- Password Hashing: bcrypt with salt rounds
- JWT Authentication: Secure token-based auth
- CORS: Configured for production domains only
- Input Validation: Zod schemas on frontend and backend
- HTTP-Only Cookies: For secure token storage
- HTTPS: Enforced in production
- Environment Secrets: Never committed to repository
NODE_ENV=development
PORT=5000
MONGODB_URI=mongodb://localhost:27017/lead-flow
JWT_SECRET=your_jwt_secret_key_here
JWT_REFRESH_SECRET=your_refresh_secret_key_here
CLIENT_URL=http://localhost:3000NEXT_PUBLIC_API_URL=http://localhost:5000/apiSee ENV_GUIDE.md for detailed configuration.
- Push code to GitHub
- Connect repository to Vercel
- Set environment variables
- Deploy
Live: https://ashutosh-lead.vercel.app/
- Create account on Render or Railway
- Connect GitHub repository
- Configure environment variables
- Deploy
See DEPLOYMENT.md for detailed steps.
Register/Login β JWT Token Generated β Token Stored (Secure)
β
Protected Routes β Verify JWT β Extract User Info
β
Token Expired β Use Refresh Token β New Access Token
β
Logout β Clear Tokens
- Create: Add new leads with validation
- Read: View single lead or all leads with pagination
- Update: Modify lead status, source, etc.
- Delete: Remove leads from system
- Filter: By status and source
- Search: Debounced search by name/email
- Export: Download leads as CSV
- Real-time lead statistics
- Lead status distribution chart
- Quick add lead form
- Lead list with filters
- CSV export functionality
- Responsive on all devices
# Test API
curl http://localhost:5000/api/health
# Test with authentication
curl -H "Authorization: Bearer {token}" http://localhost:5000/api/leadEmail: test@example.com
Password: TestPassword123
Professional commit messages following conventional commits:
feat: add authentication system
feat: implement lead management CRUD
feat: add advanced filtering and search
feat: add CSV export functionality
fix: resolve CORS issues
docs: add comprehensive documentation
chore: update dependencies
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'feat: add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License. See LICENSE file for details.
LeadFlow is built as a full-stack internship assignment showcasing:
- β Professional code structure and architecture
- β Complete TypeScript implementation
- β Modern frontend with React and Next.js
- β Scalable backend with Express.js
- β Database design with MongoDB
- β Docker containerization
- β Production deployment
- β Comprehensive documentation
- Live App: https://ashutosh-lead.vercel.app/
- GitHub: https://github.com/as-ga/lead-flow
- API Docs: API_DOCUMENTATION.md
- Setup Guide: SETUP_GUIDE.md
- Architecture: ARCHITECTURE.md
- Deployment: DEPLOYMENT.md
- Environment Config: ENV_GUIDE.md
Check out the documentation files or review the codebase. For issues, open a GitHub issue.
Made with β€οΈ by Ashutosh Gaurav
β βββ app/ # Next.js pages
β β βββ dashboard/ # Main dashboard
β β βββ login/ # Auth pages
β β βββ register/
β βββ components/ # React components
β β βββ ui/ # UI components
β β βββ leads/ # Lead components
β βββ hooks/ # Custom hooks
β βββ lib/ # Utilities
β β βββ api.ts # API client
β β βββ store.ts # Zustand stores
β β βββ validations.ts # Zod schemas
β β βββ types.ts # TypeScript types
β βββ public/ # Static files
β
βββ SETUP_GUIDE.md # Setup instructions
βββ README.md # This file
- User registers with email and password
- Backend hashes password with bcrypt
- JWT tokens issued (access + refresh)
- Tokens stored in localStorage
- Automatic refresh on token expiry
- Create: Add new leads with name, email, source, remarks
- Read: View leads with pagination and filtering
- Update: Edit lead status, source, remarks
- Delete: Remove leads with confirmation
- Search by name or email (debounced)
- Filter by status (New, Contacted, Qualified, Lost)
- Filter by source (Website, Instagram, Referral)
- Sort by latest or oldest
- All filters work together
- Server-side pagination (10 per page)
- Navigation buttons and page numbers
- Total count and page metadata
- β JWT token-based authentication
- β Password hashing with bcrypt
- β Protected API routes
- β CORS configuration
- β Input validation (Zod + backend schemas)
- β Role-based access control
POST /api/auth/register - Register user
POST /api/auth/login - Login user
GET /api/auth/logout - Logout user
POST /api/auth/refresh-token - Refresh token
POST /api/auth/logout-all - Logout all sessions
POST /api/lead/create - Create lead
GET /api/lead/get - Get all leads (paginated)
GET /api/lead/get/:id - Get lead details
GET /api/lead/update/:id - Update lead
DELETE /api/lead/delete/:id - Delete lead
page - Page number (default: 1)
limit - Records per page (default: 10)
search - Search by name/email
status - Filter by new/contacted/qualified/lost
source - Filter by website/instagram/referral
sort - latest or oldest
- [β ] User registration flow
- [β ] User login flow
- [β ] Create new lead
- [β ] Update lead
- [β ] Delete lead
- [β ] Search leads (debounced)
- [β ] Filter by status
- [β ] Filter by source
- [β ] Pagination (previous/next)
- [β ] CSV export
- [β ] Logout