Skip to content

as-ga/lead-flow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

54 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LeadFlow - Smart Leads Dashboard

A professional full-stack lead management dashboard built with the MERN stack for efficient lead tracking and management.

GitHub Node Next.js TypeScript MongoDB Docker Status

Live Demo β€’ GitHub Repo β€’ API Docs


πŸ“‹ Table of Contents


🎯 Overview

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.

Key Highlights

  • πŸ” 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

✨ Features

βœ… Core Features

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

πŸš€ Advanced Features

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

πŸ› οΈ Tech Stack

Frontend Stack

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

Backend Stack

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

πŸš€ Quick Start

Prerequisites

  • Node.js v18+ (Download)
  • MongoDB Local or MongoDB Atlas (Free)
  • pnpm or npm
  • Docker & Docker Compose (Optional, for containerized setup)

Option 1: Local Setup

Backend

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 dev

Frontend

cd 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 dev

Access Application:

Option 2: Docker Setup

# 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:5000

See DOCKER_SETUP.md for detailed Docker guide.


πŸ“š Documentation

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

πŸ“ Project Structure

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

πŸ”Œ API Endpoints

Authentication Routes

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

Lead Routes

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.


πŸ” Security

  • 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

πŸ“¦ Environment Variables

Backend (.env)

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:3000

Frontend (.env.local)

NEXT_PUBLIC_API_URL=http://localhost:5000/api

See ENV_GUIDE.md for detailed configuration.


πŸš€ Deployment

Frontend (Vercel)

  1. Push code to GitHub
  2. Connect repository to Vercel
  3. Set environment variables
  4. Deploy

Live: https://ashutosh-lead.vercel.app/

Backend (Render/Railway)

  1. Create account on Render or Railway
  2. Connect GitHub repository
  3. Configure environment variables
  4. Deploy

See DEPLOYMENT.md for detailed steps.


πŸ“Š Features in Detail

Authentication Flow

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

Lead Management

  • 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

Dashboard Features

  • Real-time lead statistics
  • Lead status distribution chart
  • Quick add lead form
  • Lead list with filters
  • CSV export functionality
  • Responsive on all devices

πŸ§ͺ Testing

Manual Testing

# Test API
curl http://localhost:5000/api/health

# Test with authentication
curl -H "Authorization: Bearer {token}" http://localhost:5000/api/lead

Test Credentials

Email: test@example.com
Password: TestPassword123

πŸ“ Git Commit History

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

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'feat: add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

πŸ“„ License

This project is licensed under the MIT License. See LICENSE file for details.


πŸ‘¨β€πŸ’Ό About

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

πŸ”— Links


πŸ’¬ Questions?

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

πŸ“š Key Features Explained

Authentication Flow

  1. User registers with email and password
  2. Backend hashes password with bcrypt
  3. JWT tokens issued (access + refresh)
  4. Tokens stored in localStorage
  5. Automatic refresh on token expiry

Lead Management

  • 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

Advanced Filtering

  • 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

Pagination

  • Server-side pagination (10 per page)
  • Navigation buttons and page numbers
  • Total count and page metadata

πŸ” Security

  • βœ… JWT token-based authentication
  • βœ… Password hashing with bcrypt
  • βœ… Protected API routes
  • βœ… CORS configuration
  • βœ… Input validation (Zod + backend schemas)
  • βœ… Role-based access control

πŸ“Š API Endpoints

Authentication


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

Leads


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

Query Parameters


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

πŸ§ͺ Testing Checklist

  • [βœ…] 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

About

LeadFlow - Smart Leads Dashboard

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors