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
- β¨ Features
- πΈ Screenshots
- π οΈ Tech Stack
- ποΈ Project Structure
- ποΈ Database Schema
- π API Endpoints
- π Authentication Flow
- π§ͺ Testing & CI/CD
- βοΈ Environment Variables
- π Getting Started
- βοΈ Deployment
- π Security Features
- πΊοΈ Roadmap
- π€ Contributing
|
|
|
|
Login Page |
Task Dashboard |
| 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/ |
| Technology | Purpose |
|---|---|
| Cloud-hosted NoSQL database | |
| Mongoose | ODM β schemas, validation, queries |
| Layer | Platform |
|---|---|
| Backend API | |
| Frontend | Cloudflare Pages |
| Database | MongoDB Atlas |
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
User {
name String β Required
email String β Required, unique, lowercase
password String β bcrypt hashed (10 salt rounds), min 6 chars
createdAt Date
updatedAt Date
}
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
}
Base URL (production): https://task-manager-api-ie3z.onrender.com/api
| 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 |
| 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>
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.
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 testContinuous Integration: every push or pull request touching backend/** automatically triggers .github/workflows/backend-ci.yml on GitHub Actions, which:
- Checks out the code
- Sets up Node.js with npm caching
- Installs dependencies with
npm ci - Runs the full Jest test suite
The pipeline can also be triggered manually from the Actions tab via workflow_dispatch.
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.envfiles to Git. They are already in.gitignore. Tests do not need this file βtests/auth.test.jssets its ownJWT_SECRETand spins up an in-memory database.
node -v # v20 or higher
npm -v # v9 or highergit clone https://github.com/pranavreddy1721/task-manager.git
cd task-managercd backend
npm install
cp .env.example .env # then fill in your values (see above)
npm run devRuns on http://localhost:5000
Run the test suite:
npm testcd ../frontend
npx http-server -p 5500Visit http://localhost:5500
β οΈ If running the frontend locally against the local backend, updateAPI_BASE_URLinfrontend/js/api.jstohttp://localhost:5000/api.
| 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.
| 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 |
- 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
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 RequestDistributed under the MIT License. See LICENSE for more information.
Built with β€οΈ by Pranav Reddy

