Skip to content

About

MERN task manager with JWT auth, full CRUD, and a Jest/Supertest CI pipeline via GitHub Actions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

15 Commits

Folders and files

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

Repository files navigation



A full-stack task management web app β€” secure JWT authentication, complete CRUD operations, an automated Jest/Supertest test suite running in CI, and a clean, framework-free frontend, deployed live end to end.


πŸš€ Live Demo Β β€’Β  πŸ“– API Docs Β β€’Β  πŸ› Report Bug Β β€’Β  πŸ’‘ Request Feature


πŸ“‹ Table of Contents


✨ Features

πŸ” Authentication

  • Register with name, email, password
  • Passwords hashed with bcrypt (never stored in plain text)
  • JWT issued on login/register, valid for 30 days
  • Protected routes β€” only accessible with a valid token
  • Auto-redirect to login if session is missing/expired

βœ… Task Management (CRUD)

  • Create tasks with title, description, priority, due date
  • Read β€” view all tasks, scoped to the logged-in user only
  • Update β€” edit details or toggle Pending/Completed
  • Delete β€” remove tasks with a confirmation prompt

πŸ” Search & Filter

  • Real-time search by task title
  • Filter by status: Pending / Completed
  • Filter by priority: Low / Medium / High
  • Filters combine β€” search + status + priority together

🎨 Clean UI

  • Priority-coded left border on task cards (Low/Medium/High)
  • Status & priority badges
  • Responsive layout, works on mobile and desktop
  • No frameworks β€” pure HTML, CSS, and JavaScript

πŸ“Έ Screenshots

Login Page
Login Page
Task Dashboard
Task Dashboard

πŸ› οΈ Tech Stack

πŸ–₯️ Frontend

Technology Purpose
HTML5 Page structure β€” Login, Register, Dashboard
CSS3 Custom styling, no UI framework, responsive layout
JavaScript (ES6+) DOM manipulation, form handling, API calls
Fetch API HTTP requests to the backend, with JWT header attached
localStorage Persists JWT token & user info across page reloads

βš™οΈ Backend

Technology Purpose
Node.js JavaScript runtime
Express.js REST API framework, routing, middleware
bcryptjs Password hashing (salted)
jsonwebtoken JWT generation & verification (30-day expiry)
cors Allows the frontend (different origin) to call the API
dotenv Loads environment variables from .env
Nodemon Auto-restart server on file change (dev only)

πŸ§ͺ Testing & CI/CD

Technology Purpose
Jest Test runner & assertion library
Supertest HTTP assertions against the Express app
mongodb-memory-server Spins up an in-memory MongoDB instance for isolated tests
GitHub Actions Runs the test suite automatically on every push/PR to backend/

πŸ—„οΈ Database

Technology Purpose
MongoDB Atlas Cloud-hosted NoSQL database
Mongoose ODM β€” schemas, validation, queries

☁️ Deployment

Layer Platform
Backend API Render
Frontend Cloudflare Pages
Database MongoDB Atlas

πŸ—‚οΈ Project Structure

task-manager/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── backend-ci.yml           # GitHub Actions CI pipeline
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── db.js                    # MongoDB connection
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ User.js                  # User schema + password hashing hook
β”‚   β”‚   └── Task.js                  # Task schema
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── authMiddleware.js        # JWT verification (protect routes)
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ authController.js        # Register, login, profile
β”‚   β”‚   └── taskController.js        # Create, read, update, delete tasks
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ authRoutes.js            # /api/auth/*
β”‚   β”‚   └── taskRoutes.js            # /api/tasks/*
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   └── auth.test.js             # Jest + Supertest auth route tests
β”‚   β”œβ”€β”€ app.js                       # Express app (routes, middleware)
β”‚   β”œβ”€β”€ server.js                    # App entry point (connects DB, starts server)
β”‚   β”œβ”€β”€ package.json
β”‚   └── .env.example
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html                   # Login page
β”‚   β”œβ”€β”€ register.html                # Register page
β”‚   β”œβ”€β”€ dashboard.html                # Task dashboard (CRUD UI)
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── style.css
β”‚   └── js/
β”‚       β”œβ”€β”€ api.js                   # Fetch wrapper + JWT header
β”‚       β”œβ”€β”€ auth.js                  # Login/register logic
β”‚       └── dashboard.js             # CRUD + filter logic
β”œβ”€β”€ screenshots/
β”‚   β”œβ”€β”€ login-screenshot.png
β”‚   └── dashboard-screenshot.png
β”œβ”€β”€ JWT_GUIDE.md                     # JWT concepts + interview Q&A
└── README.md

πŸ—„οΈ Database Schema

πŸ‘€ User

User {
  name       String   β€” Required
  email      String   β€” Required, unique, lowercase
  password   String   β€” bcrypt hashed (10 salt rounds), min 6 chars
  createdAt  Date
  updatedAt  Date
}

βœ… Task

Task {
  user         ObjectId β†’ User   β€” Owner of this task
  title        String   β€” Required
  description  String   β€” Optional
  priority     Enum     β€” Low | Medium | High (default: Medium)
  dueDate      Date     β€” Optional
  status       Enum     β€” Pending | Completed (default: Pending)
  createdAt    Date
  updatedAt    Date
}

πŸ”Œ API Endpoints

Base URL (production): https://task-manager-api-ie3z.onrender.com/api

πŸ” Auth β€” /api/auth

Method Endpoint Auth Description
POST /register ❌ Register a new user, returns JWT
POST /login ❌ Login, returns JWT
GET /profile βœ… Get logged-in user's profile

βœ… Tasks β€” /api/tasks

Method Endpoint Auth Description
POST / βœ… Create a new task
GET / βœ… Get all tasks (?search=, ?status=, ?priority=)
GET /:id βœ… Get a single task
PUT /:id βœ… Update a task
DELETE /:id βœ… Delete a task

Protected routes require header: Authorization: Bearer <token>


πŸ” Authentication Flow

1. User registers/logs in
2. Server verifies password (bcrypt) and signs a JWT
3. Frontend stores the token in localStorage
4. Every task request sends: Authorization: Bearer <token>
5. Backend middleware verifies the token before granting access
6. Tasks are filtered by user ID β€” each user only sees their own data

πŸ“„ For a full breakdown with interview-style Q&A, see JWT_GUIDE.md.


πŸ§ͺ Testing & CI/CD

The backend has an automated test suite covering the auth flow (registration, duplicate-email rejection, missing-field validation, login, and invalid-credential handling), built with Jest and Supertest against an in-memory MongoDB instance (mongodb-memory-server) β€” no real database or .env file needed to run tests.

Run tests locally:

cd backend
npm install
npm test

Continuous Integration: every push or pull request touching backend/** automatically triggers .github/workflows/backend-ci.yml on GitHub Actions, which:

  1. Checks out the code
  2. Sets up Node.js with npm caching
  3. Installs dependencies with npm ci
  4. Runs the full Jest test suite

The pipeline can also be triggered manually from the Actions tab via workflow_dispatch.


βš™οΈ Environment Variables

Create a .env file inside backend/:

# ── MongoDB Atlas ─────────────────────────────────────────────
# Get from: https://cloud.mongodb.com β†’ Connect β†’ Drivers
MONGO_URI=mongodb+srv://<user>:<password>@cluster0.xxxxx.mongodb.net/taskmanager?appName=Cluster0

# ── JWT ───────────────────────────────────────────────────────
# Use any long random string
JWT_SECRET=your_super_secret_jwt_key

# ── Server ────────────────────────────────────────────────────
PORT=5000

⚠️ Never commit .env files to Git. They are already in .gitignore. Tests do not need this file β€” tests/auth.test.js sets its own JWT_SECRET and spins up an in-memory database.


πŸš€ Getting Started

Prerequisites

node -v   # v20 or higher
npm -v    # v9 or higher

1. Clone the repository

git clone https://github.com/pranavreddy1721/task-manager.git
cd task-manager

2. Backend setup

cd backend
npm install
cp .env.example .env    # then fill in your values (see above)
npm run dev

Runs on http://localhost:5000

Run the test suite:

npm test

3. Frontend setup

cd ../frontend
npx http-server -p 5500

Visit http://localhost:5500

⚠️ If running the frontend locally against the local backend, update API_BASE_URL in frontend/js/api.js to http://localhost:5000/api.


☁️ Deployment

Layer Platform Live URL
Frontend Cloudflare Pages task-manager-17.pages.dev
Backend API Render task-manager-api-ie3z.onrender.com
Database MongoDB Atlas β€”

ℹ️ Render's free tier spins down after inactivity β€” the first request after idling may take 30–50 seconds to respond.


πŸ”’ Security Features

Feature Implementation
Password hashing bcrypt with salted hashing before every save
JWT tokens Signed with server-only secret, 30-day expiry
Protected routes Middleware verifies token on every task request
User-scoped data Tasks filtered by user ID β€” no cross-user access
CORS Enabled so only intended frontend origins can call the API
Environment secrets .env excluded from Git via .gitignore

πŸ—ΊοΈ Roadmap

  • Task categories/tags
  • Due-date sorting and reminders
  • Pagination for large task lists
  • Dark mode toggle
  • Email verification on signup
  • Expand test coverage to task CRUD routes

🀝 Contributing

Contributions are welcome!

# 1. Fork the repo
# 2. Create your feature branch
git checkout -b feature/AmazingFeature

# 3. Commit your changes
git commit -m 'Add some AmazingFeature'

# 4. Push to the branch
git push origin feature/AmazingFeature

# 5. Open a Pull Request

πŸ“„ License

Distributed under the MIT License. See LICENSE for more information.


Built with ❀️ by Pranav Reddy

About

MERN task manager with JWT auth, full CRUD, and a Jest/Supertest CI pipeline via GitHub Actions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages