A modern, full-stack Todo application built with MERN stack featuring OTP-based email authentication, beautiful UI with Tailwind CSS, and JWT token management.
- β OTP-based Login - Secure email verification using 6-digit OTP
- β Email Verification - Nodemailer integration for sending OTPs
- β JWT Authentication - Secure token-based authentication with HTTP-only cookies
- β
Smart Redirections - Automatic routing based on user status
- Existing users β Login β Home
- New users β OTP β Signup β Home
- β CRUD Operations - Create, Read, Update, Delete tasks
- β Task Completion - Mark tasks as complete/incomplete
- β Priority Levels - Low, Medium, High priority tags
- β Filtering - View All, Pending, or Completed tasks
- β Beautiful UI - Modern design with Tailwind CSS and smooth animations
Frontend:
- React 18
- React Router v6
- Tailwind CSS
- Axios
- React Hot Toast
- Lucide React Icons
- Vite
Backend:
- Node.js
- Express.js
- MongoDB with Mongoose
- JWT (jsonwebtoken)
- Nodemailer
- Cookie Parser
- CORS
Before running this project, make sure you have:
- Node.js (v16 or higher)
- MongoDB (running locally or MongoDB Atlas)
- Gmail account (for sending OTPs) with App Password enabled
cd c:\Users\LENOVO\Desktop\fsdcd backend
npm installCreate a .env file in the backend folder:
PORT=5000
CLIENT_URL=http://localhost:3000
# MongoDB
MONGODB_URI=mongodb://localhost:27017/todo-app
# JWT Secret (change this to a random string)
JWT_SECRET=your_super_secret_jwt_key_change_this_to_random_string
# Email Configuration (Gmail)
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-gmail-app-password
# OTP Expiry (in minutes)
OTP_EXPIRY=10Important: To get Gmail App Password:
- Go to Google Account Settings
- Enable 2-Factor Authentication
- Go to Security β App Passwords
- Generate a new app password for "Mail"
- Use that 16-character password in
EMAIL_PASS
cd ../frontend
npm installMake sure MongoDB is running:
# If using local MongoDB
mongodOr use MongoDB Atlas (cloud) and update MONGODB_URI accordingly.
Terminal 1 - Backend:
cd backend
npm run devTerminal 2 - Frontend:
cd frontend
npm run devThe application will be available at:
- Frontend: http://localhost:3000
- Backend: http://localhost:5000
- Enter your email on login page
- Receive OTP in your email
- Enter the 6-digit OTP
- Complete signup with your name
- Get redirected to home page
- Enter your email on login page
- Receive OTP in your email
- Enter the 6-digit OTP
- Get redirected directly to home page
- Add new tasks with title, description, and priority
- Mark tasks as complete by clicking the checkbox
- Edit tasks using the edit icon
- Delete tasks using the trash icon
- Filter tasks by All, Pending, or Completed
fsd/
βββ backend/
β βββ controllers/
β β βββ authController.js
β β βββ taskController.js
β βββ middleware/
β β βββ authMiddleware.js
β βββ models/
β β βββ User.js
β β βββ Task.js
β βββ routes/
β β βββ authRoutes.js
β β βββ taskRoutes.js
β βββ utils/
β β βββ emailService.js
β β βββ otpHelper.js
β βββ server.js
β βββ package.json
β βββ .env
β
βββ frontend/
βββ src/
β βββ api/
β β βββ axios.js
β βββ context/
β β βββ AuthContext.jsx
β βββ pages/
β β βββ Login.jsx
β β βββ VerifyOTP.jsx
β β βββ Signup.jsx
β β βββ Home.jsx
β βββ App.jsx
β βββ main.jsx
β βββ index.css
βββ index.html
βββ vite.config.js
βββ tailwind.config.js
βββ package.json
POST /api/auth/send-otp- Send OTP to emailPOST /api/auth/verify-otp- Verify OTPPOST /api/auth/signup- Complete user signupPOST /api/auth/logout- Logout userGET /api/auth/me- Get current user (protected)
GET /api/tasks- Get all tasks (with optional filter query)POST /api/tasks- Create new taskPUT /api/tasks/:id- Update taskDELETE /api/tasks/:id- Delete taskPATCH /api/tasks/:id/toggle- Toggle task completion
- Gradient Backgrounds - Beautiful purple-indigo gradients
- Smooth Animations - Hover effects and transitions
- Responsive Design - Works on all screen sizes
- Toast Notifications - User-friendly feedback messages
- Loading States - Spinners for async operations
- Icons - Lucide React icons for modern look
- HTTP-only cookies for JWT storage
- OTP expiration (10 minutes by default)
- Protected API routes with JWT verification
- CORS configuration
- Secure password handling (OTP-based, no passwords stored)
- Verify Gmail App Password is correct
- Check if 2FA is enabled on Gmail account
- Ensure
EMAIL_USERandEMAIL_PASSare set in.env
- Make sure MongoDB is running
- Verify
MONGODB_URIin.envis correct - Check MongoDB Atlas whitelist if using cloud
- Verify backend is running on port 5000
- Check CORS settings in
server.js - Ensure proxy is configured in
vite.config.js
This project is open source and available under the MIT License.
Created with β€οΈ using MERN Stack
- React Team
- Express.js
- MongoDB
- Tailwind CSS
- Nodemailer
Happy Coding! π