Skip to content

About

A full-stack MERN task management app with JWT auth, task CRUD, search/filter/sort, dashboard statistics, and user profiles. Built with MongoDB, Express.js, React.js, and Node.js.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βœ… TaskFlow

A full-stack MERN task management application

Organize your work. Track your progress. Stay productive.

Features β€’ Screenshots β€’ Quick Start β€’ API Docs β€’ Tech Stack


πŸ“Έ Screenshots

Login Dashboard
Login Dashboard
Create Task Modal My Tasks (Search, Filter & Sort)
Create Task My Tasks
User Profile MongoDB Atlas Collections
Profile MongoDB Atlas

🌟 Features

πŸ” Authentication & Security

  • Secure user registration with field validation
  • JWT-based login with configurable token expiry (default 7 days)
  • bcrypt password hashing (salt rounds: 12) β€” plain-text passwords never stored
  • Protected API routes β€” every endpoint validates the JWT
  • Data isolation β€” users can only access their own tasks (enforced at DB query level)
  • Sensitive fields (password) excluded from all API responses

πŸ“‹ Task Management (Full CRUD)

  • Create tasks with title, description, priority, status, and due date
  • View, update, and delete your tasks
  • Status tracking β€” Pending β†’ In Progress β†’ Completed
  • Priority levels β€” Low / Medium / High
  • Overdue highlighting β€” tasks past their due date are visually flagged

πŸ” Search, Filter & Sort

  • Case-insensitive partial search by task title
  • Filter by status and priority simultaneously
  • Sort by creation date (newest/oldest) or due date
  • Pagination β€” 10 tasks per page with navigation controls

πŸ“Š Dashboard Statistics

  • Total tasks count
  • Pending / In Progress / Completed counts
  • Overdue task count (non-completed tasks past due date)
  • Completion percentage β€” (Completed / Total) Γ— 100
  • Animated progress bar

πŸ‘€ User Profile

  • View your name, email, and account creation date
  • Update your display name

πŸš€ Quick Start

Prerequisites

Tool Version
Node.js v18+
npm v9+
MongoDB Local or Atlas

1. Clone the repository

git clone https://github.com/Keerthanareddy1106/taskflow-mern.git
cd taskflow-mern

2. Configure environment variables

cp server/.env.example server/.env

Edit server/.env:

PORT=5000
MONGO_URI=mongodb://localhost:27017/taskflow
JWT_SECRET=your_super_long_random_secret_here
JWT_EXPIRES_IN=7d
NODE_ENV=development

⚠️ Never commit .env to version control. It is already listed in .gitignore.

3. Install dependencies

# Install both server and client dependencies
cd server && npm install
cd ../client && npm install

4. Run the application

Terminal 1 β€” Backend (port 5000):

cd server
npm run dev

Terminal 2 β€” Frontend (port 5173):

cd client
npm run dev

5. Open in browser

http://localhost:5173

Register a new account and start managing your tasks!


πŸ“‘ REST API Reference

Base URL: http://localhost:5000/api

Authentication: Add Authorization: Bearer <token> header to all protected requests.


πŸ”‘ Auth Endpoints

Method Endpoint Auth Description
POST /auth/register ❌ Register a new user
POST /auth/login ❌ Login and receive JWT
GET /auth/me βœ… Get current user info

Register

POST /api/auth/register
Content-Type: application/json

{
  "name": "Jane Doe",
  "email": "jane@example.com",
  "password": "secret123",
  "confirmPassword": "secret123"
}

Login

POST /api/auth/login
Content-Type: application/json

{
  "email": "jane@example.com",
  "password": "secret123"
}

Response:

{
  "success": true,
  "data": {
    "token": "eyJhbGc...",
    "user": { "_id": "...", "name": "Jane Doe", "email": "jane@example.com" }
  }
}

πŸ“‹ Task Endpoints

All task endpoints require Authorization: Bearer <token>

Method Endpoint Description
POST /tasks Create a new task
GET /tasks Get all tasks (filterable)
GET /tasks/stats Get dashboard statistics
GET /tasks/:id Get a single task
PUT /tasks/:id Update a task
DELETE /tasks/:id Delete a task

Query Parameters for GET /tasks

Parameter Type Values Default
search string Any text β€”
status string Pending | In Progress | Completed β€”
priority string Low | Medium | High β€”
sortBy string createdAt | dueDate | title createdAt
order string asc | desc desc
page number β€” 1
limit number max 100 10

Example:

GET /api/tasks?status=Pending&priority=High&sortBy=dueDate&order=asc&page=1&limit=10
Authorization: Bearer <token>

Create / Update Task Body

{
  "title": "Design database schema",
  "description": "Define collections, fields, and relationships",
  "priority": "High",
  "status": "In Progress",
  "dueDate": "2024-12-31"
}

Stats Response

{
  "success": true,
  "data": {
    "stats": {
      "total": 15,
      "pending": 5,
      "inProgress": 4,
      "completed": 6,
      "overdue": 2,
      "completionPercentage": 40
    }
  }
}

πŸ‘€ User Endpoints

Method Endpoint Description
GET /users/profile Get user profile
PATCH /users/profile Update profile name

πŸ“‹ HTTP Status Codes

Code Meaning
200 Success
201 Created
400 Bad Request / Validation Error
401 Unauthorized (missing / invalid / expired token)
403 Forbidden
404 Not Found
409 Conflict (e.g., duplicate email)
500 Internal Server Error

πŸ—„οΈ Database Design

Users Collection

{
  _id:       ObjectId,
  name:      String  (required, 2–50 chars),
  email:     String  (required, unique, lowercase),
  password:  String  (bcrypt hash β€” never returned in responses),
  createdAt: Date,
  updatedAt: Date
}

Tasks Collection

{
  _id:         ObjectId,
  title:       String  (required, max 200 chars),
  description: String  (optional, max 1000 chars),
  status:      "Pending" | "In Progress" | "Completed",
  priority:    "Low" | "Medium" | "High",
  dueDate:     Date | null,
  userId:      ObjectId (ref: User),  // ownership field
  createdAt:   Date,
  updatedAt:   Date
}

Indexes:

  • { userId: 1 } β€” fast per-user queries
  • { userId: 1, status: 1 } β€” status filtering
  • { userId: 1, priority: 1 } β€” priority filtering
  • { userId: 1, dueDate: 1 } β€” due date sorting
  • { title: "text" } β€” full-text search

πŸ—οΈ Project Structure

taskflow-mern/
β”‚
β”œβ”€β”€ client/                        # React.js frontend (Vite)
β”‚   └── src/
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ Sidebar.jsx        # Navigation sidebar
β”‚       β”‚   β”œβ”€β”€ TaskModal.jsx      # Create/Edit task form
β”‚       β”‚   β”œβ”€β”€ ConfirmDialog.jsx  # Delete confirmation
β”‚       β”‚   └── Shared.jsx         # Badges, Spinner, EmptyState
β”‚       β”œβ”€β”€ context/
β”‚       β”‚   └── AuthContext.jsx    # Auth state & token management
β”‚       β”œβ”€β”€ pages/
β”‚       β”‚   β”œβ”€β”€ Login.jsx          # Login page
β”‚       β”‚   β”œβ”€β”€ Register.jsx       # Registration page
β”‚       β”‚   β”œβ”€β”€ Dashboard.jsx      # Stats & recent tasks
β”‚       β”‚   β”œβ”€β”€ Tasks.jsx          # Task list with CRUD
β”‚       β”‚   └── Profile.jsx        # Profile management
β”‚       β”œβ”€β”€ routes/
β”‚       β”‚   └── ProtectedRoute.jsx # Route guards
β”‚       β”œβ”€β”€ services/
β”‚       β”‚   β”œβ”€β”€ api.js             # Axios instance + interceptors
β”‚       β”‚   └── taskflowService.js # API service functions
β”‚       β”œβ”€β”€ App.jsx                # Router & providers
β”‚       β”œβ”€β”€ main.jsx               # Entry point
β”‚       └── index.css              # Custom responsive CSS
β”‚
β”œβ”€β”€ server/                        # Node.js / Express backend
β”‚   └── src/
β”‚       β”œβ”€β”€ config/
β”‚       β”‚   └── database.js        # MongoDB connection
β”‚       β”œβ”€β”€ controllers/
β”‚       β”‚   β”œβ”€β”€ authController.js  # Register, Login, GetMe
β”‚       β”‚   β”œβ”€β”€ taskController.js  # Task CRUD + Stats
β”‚       β”‚   └── userController.js  # Profile CRUD
β”‚       β”œβ”€β”€ middleware/
β”‚       β”‚   β”œβ”€β”€ authMiddleware.js  # JWT protect middleware
β”‚       β”‚   β”œβ”€β”€ errorMiddleware.js # Centralized error handler
β”‚       β”‚   └── validationMiddleware.js
β”‚       β”œβ”€β”€ models/
β”‚       β”‚   β”œβ”€β”€ User.js            # Mongoose User schema
β”‚       β”‚   └── Task.js            # Mongoose Task schema
β”‚       β”œβ”€β”€ routes/
β”‚       β”‚   β”œβ”€β”€ authRoutes.js
β”‚       β”‚   β”œβ”€β”€ taskRoutes.js
β”‚       β”‚   └── userRoutes.js
β”‚       β”œβ”€β”€ utils/
β”‚       β”‚   └── generateToken.js   # JWT signing helper
β”‚       β”œβ”€β”€ validators/
β”‚       β”‚   β”œβ”€β”€ authValidators.js  # Registration & login rules
β”‚       β”‚   └── taskValidators.js  # Task create/update rules
β”‚       └── server.js              # Express app entry point
β”‚
β”œβ”€β”€ .gitignore
β”œβ”€β”€ package.json                   # Root dev scripts
└── README.md

πŸ› οΈ Tech Stack

Category Technology
Frontend React 18, React Router v6, Vite
HTTP Client Axios (with interceptors)
Backend Node.js 18+, Express.js 4.x
Database MongoDB, Mongoose ODM
Authentication JSON Web Tokens (JWT), bcryptjs
Validation express-validator
Icons Lucide React
Notifications react-hot-toast

πŸ§ͺ Testing Guide

Using Postman

  1. Register β†’ POST /api/auth/register
  2. Login β†’ POST /api/auth/login β†’ copy token
  3. Set header Authorization: Bearer <token> on all task requests
  4. Create tasks β†’ POST /api/tasks
  5. Test filtering β†’ GET /api/tasks?status=Pending&priority=High
  6. Test isolation β†’ Register a second user and verify you cannot see the first user's tasks
  7. Dashboard β†’ GET /api/tasks/stats

Test Checklist

  • Register with valid data
  • Register with duplicate email β†’ expect 409
  • Login with wrong password β†’ expect 401
  • Access /tasks without token β†’ expect 401
  • Create task without title β†’ expect 400
  • Create, read, update, delete a task
  • Filter by status and priority
  • Search by partial title (case-insensitive)
  • Verify another user's tasks are not returned
  • Verify dashboard stats are accurate

πŸ”’ Security Considerations

Measure Implementation
Password hashing bcrypt with 12 salt rounds
Token secret Stored in .env, never in source code
Password field select: false in Mongoose β€” excluded from all responses
Ownership enforcement userId filter on every task query/mutation
Input validation express-validator on all POST/PUT/PATCH endpoints
Error messages Generic messages for auth failures (no user enumeration)
Production errors Stack traces only in development mode

πŸ—ΊοΈ Roadmap

Priority Feature
πŸ”΅ High Automated tests (Jest + Supertest)
πŸ”΅ High CI/CD pipeline (GitHub Actions)
🟑 Medium Refresh token + revocation
🟑 Medium Email reminders for approaching deadlines
🟑 Medium Kanban drag-and-drop board
🟒 Low Team collaboration & task assignment
🟒 Low Real-time updates via Socket.IO
🟒 Low Google OAuth login
🟒 Low File attachments
🟒 Low Admin dashboard

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m "feat: add my feature"
  4. Push the branch: git push origin feature/my-feature
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License.


Built with ❀️ using the MERN Stack

⬆ Back to Top

About

A full-stack MERN task management app with JWT auth, task CRUD, search/filter/sort, dashboard statistics, and user profiles. Built with MongoDB, Express.js, React.js, and Node.js.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages