TaskMaster - MERN Stack Task Management App
A full-stack task management application built with the MERN stack (MongoDB, Express.js, React, Node.js) using Next.js framework.
π Features
- User Authentication: Secure registration and login with JWT tokens
- Task Management: Create, read, update, and delete tasks
- Task Status: Mark tasks as complete or incomplete
- Protected Routes: Dashboard accessible only to authenticated users
- Responsive Design: Mobile-friendly interface with Tailwind CSS
- Real-time Updates: Instant task updates without page refresh
- Form Validation: Client-side and server-side validation
- Secure Password Storage: Passwords hashed with bcrypt
π οΈ Tech Stack
Frontend
- Next.js 14 - React framework with App Router
- React 18 - UI library with hooks and context
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - Modern UI components
- Lucide React - Beautiful icons
Backend
- Next.js API Routes - Serverless API endpoints
- JWT - JSON Web Tokens for authentication
- bcryptjs - Password hashing
Database
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
π¦ Installation & Setup
Prerequisites
- Node.js (v18 or higher)
- MongoDB Atlas account or local MongoDB installation
- Git
1. Clone the Repository
```bash
git clone https://github.com/yourusername/taskmaster-app.git
cd taskmaster-app
```
2. Install Dependencies
```bash
npm install
```
3. Environment Variables
Create a `.env.local` file in the root directory:
```env
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/taskmaster
JWT_SECRET=your-super-secret-jwt-key-here
```
4. MongoDB Setup
- Create a MongoDB Atlas account at mongodb.com
- Create a new cluster
- Get your connection string
- Replace the MONGODB_URI in your `.env.local` file
5. Run the Application
```bash
npm run dev
```
The application will be available at `http://localhost:3000`
ποΈ Project Structure
```
taskmaster-app/
βββ app/
β βββ api/
β β βββ auth/
β β β βββ login/route.ts
β β β βββ register/route.ts
β β βββ tasks/
β β βββ route.ts
β β βββ [id]/route.ts
β βββ auth/
β β βββ login/page.tsx
β β βββ register/page.tsx
β βββ dashboard/page.tsx
β βββ layout.tsx
β βββ page.tsx
βββ components/ui/
βββ contexts/
β βββ AuthContext.tsx
βββ lib/
β βββ mongodb.ts
βββ models/
β βββ User.ts
β βββ Task.ts
βββ types/
βββ global.d.ts
```
π API Endpoints
Authentication
- `POST /api/auth/register` - Register a new user
- `POST /api/auth/login` - Login user
Tasks (Protected)
- `GET /api/tasks` - Get all tasks for authenticated user
- `POST /api/tasks` - Create a new task
- `PUT /api/tasks/:id` - Update a task
- `DELETE /api/tasks/:id` - Delete a task
ποΈ Database Schema
User Model
```javascript
{
name: String (required),
email: String (required, unique),
password: String (required, hashed),
timestamps: true
}
```
Task Model
```javascript
{
title: String (required),
description: String,
completed: Boolean (default: false),
userId: ObjectId (ref: User),
timestamps: true
}
```
π Authentication Flow
- User registers with name, email, and password
- Password is hashed using bcrypt
- User logs in with email and password
- Server validates credentials and returns JWT token
- Token is stored in localStorage and sent with API requests
- Protected routes verify token before allowing access
π¨ UI Components
The application uses a modern, responsive design with:
- Clean landing page with call-to-action
- Secure authentication forms with validation
- Interactive dashboard with task statistics
- Intuitive task management interface
- Mobile-responsive design
π Deployment
Frontend (Vercel)
- Push code to GitHub
- Connect repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy automatically
Database (MongoDB Atlas)
- Already cloud-hosted
- Configure IP whitelist and database users
π§ͺ Testing
Manual Testing Checklist
π Security Features
- Password hashing with bcrypt
- JWT token authentication
- Protected API routes
- Input validation and sanitization
- CORS protection
- Environment variable protection
π€ Contributing
- Fork the repository
- Create a 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
π License
This project is licensed under the MIT License.
π¨βπ» Author
Your Name
π Acknowledgments
- Next.js team for the amazing framework
- shadcn for the beautiful UI components
- MongoDB for the flexible database solution
- Vercel for seamless deployment