FayyazAK/TASK_MASTER
TaskMaster: Feature-rich to-do list API supporting JWT auth, role-based access, priority levels, multi-level organization, bulk operations, and advanced filtering. Built with Node.js, Express, and MySQL for performance and scalability.
๐ TaskMaster - Advanced To-Do List API
TaskMaster is a powerful, feature-rich RESTful API for managing to-do lists and tasks with robust user authentication, role-based permissions, and comprehensive task organization capabilities.
โญ What Makes TaskMaster Different
Unlike standard to-do list applications, TaskMaster offers:
- Enterprise-grade security with JWT authentication, bcrypt password hashing, and role-based access control
- Multi-level organization with lists and tasks hierarchy for better organization
- Priority management system with customizable priority levels
- Advanced caching with Redis for optimized performance and scalability
- Admin dashboard capabilities for team management and oversight
- Comprehensive API that can support multiple frontend clients (web, mobile, desktop)
- Performance optimizations with database connection pooling and proper indexing
- Scalable architecture with clustering support via PM2
- Advanced filtering for tasks based on due dates, completion status, and priorities
- Bulk operations for efficient task and list management
- Advanced logging with daily log rotation for better debugging and monitoring
- Full HTTPS support with custom SSL certificate configuration
- Rate limiting to prevent API abuse and ensure system stability
- Separate development and production environments with environment-specific configurations
โจ Features
๐ค User Management
- Secure user registration and authentication with JWT
- User profiles with customizable details
- Role-based authorization (admin/regular users)
- Password hashing with bcrypt for top-level security
- Profile update functionality for users
๐ List Management
- Create and organize multiple lists per user
- Detailed list information with timestamps
- Bulk operations for efficient list management
- List statistics showing total tasks and pending tasks
- Automatic timestamp updates when tasks are modified
โ Task Management
- Create, update, and organize tasks within lists
- Multiple priority levels (Low, Medium, High, Urgent)
- Task due dates with status tracking
- Task filtering and search capabilities
- Mark tasks as complete/incomplete
- Task modification with automated list update timestamps
- Due date filtering for overdue and today's tasks
๐ก๏ธ Security
- JWT-based authentication with secure cookie options
- HTTPS support with automatic HTTP to HTTPS redirection
- Rate limiting to prevent abuse and brute force attacks
- Input validation and sanitization against injection attacks
- Helmet security headers to protect against common vulnerabilities
- CORS protection with configurable allowed origins, methods, and headers
๐ Performance
- Redis caching layer with intelligent invalidation strategies
- Connection pooling for database optimization
- Efficient SQL queries with proper indexing
- Clustering support via PM2
- Optimized database schema with appropriate relationships
- Transaction support for data integrity
๐ Logging
- Comprehensive logging with Winston
- Daily log rotation to prevent log file bloat
- Different log levels for development and production
- Separate error and combined logs
- Console logging with colorized output
๐ง Caching Strategy
TaskMaster implements a sophisticated Redis caching strategy:
Cache Implementation
- Cache-Aside Pattern: Check cache first, fall back to database
- Time-Based Expiration: Configurable TTL for all cached items
- Strategic Invalidation: Smart cache clearing when data is modified
- Hierarchical Key Structure: Organized key naming scheme for efficient invalidation
- Namespace Prefixing: Prevents key collisions with other applications
Key Generators
Structured naming convention for cache keys:
users:${userId}- Single user datausers:${userId}:lists- All lists for a userusers:${userId}:lists:${listId}- Specific list datausers:${userId}:tasks- All tasks for a userpriorities- All priority levels
Cache Operations
- Automatic cache invalidation on writes
- Pattern-based invalidation for related entities
- Error-resistant caching with graceful fallbacks
- Optional cache clearing on application startup
๐ ๏ธ Technical Stack
- Backend: Node.js, Express.js 5.x
- Database: MySQL 8+
- Caching: Redis 6+
- Authentication: JWT (JSON Web Tokens)
- Process Manager: PM2
- Security: Helmet, bcrypt, rate-limiting
- Logging: Winston with daily rotation
- Development: Nodemon for hot-reloading
๐ Getting Started
Prerequisites
- Node.js (v18 or higher)
- MySQL (v8.0 or higher)
- Redis (v6.0 or higher)
- npm or yarn
Installation
-
Clone the repository:
git clone https://github.com/YourUsername/TaskMaster.git cd TaskMaster -
Install dependencies:
npm install
-
Create a
.envfile in the root directory with the following variables (use.env-exampleas a template) -
Generate SSL certificates (if using HTTPS):
npm run ssl:generate
-
Start the server:
# Development mode with hot reloading npm start # OR using PM2 npm run pm2:dev
๐ API Endpoints
Authentication
POST /api/auth/signup- Register a new userPOST /api/auth/login- Login userGET /api/auth/current-user- Get current user infoPOST /api/auth/logout- Logout user
User Management
PUT /api/user/update-profile- Update user profile
Lists
GET /api/lists- Get all lists for user (query param: include_tasks)POST /api/lists- Create a new listGET /api/lists/:list_id- Get a specific list (query param: include_tasks)PUT /api/lists/:list_id- Update a listDELETE /api/lists/:list_id- Delete a listDELETE /api/lists/:list_id/clear- Remove all tasks from a listDELETE /api/lists- Delete all lists for userDELETE /api/lists/clear- Clear all tasks from all lists
Tasks
GET /api/tasks- Get all tasks for user (query param: completed)POST /api/tasks- Create a new taskGET /api/tasks/:task_id- Get a specific taskPUT /api/tasks/:task_id- Update a taskDELETE /api/tasks/:task_id- Delete a taskPUT /api/tasks/:task_id/status- Update task completion status
Priorities
GET /api/priorities- Get all priority levelsGET /api/priorities/id/:priority_id- Get priority by IDGET /api/priorities/level/:level- Get priority by level
Admin Routes (admin role required)
GET /api/admin/users- Get all usersGET /api/admin/users/:id- Get user by IDPOST /api/admin/users- Create a new userPUT /api/admin/users/:id- Update a userDELETE /api/admin/users/:id- Delete a userPOST /api/admin/priorities- Create a new priorityPUT /api/admin/priorities/:id- Update a priorityDELETE /api/admin/priorities/:id- Delete a priority
๐ฆ Production Deployment
For production environments:
# Start PM2 in production mode
npm run pm2:start
# Monitor logs
npm run pm2:logs
# Monitor processes
npm run pm2:monit
# Check status
npm run pm2:status๐งช Development
# Restart server on changes using Nodemon
npm start
# Generate SSL certificates
npm run ssl:generate๐ Security Considerations
- Always change default admin credentials in production
- Use environment variables for sensitive information
- Enable HTTPS in production
- Configure proper CORS settings for your frontend
- Set appropriate rate limits based on your application needs
- Regularly update dependencies to mitigate security vulnerabilities
๐ Performance Optimization
- Redis caching for frequently accessed data
- Database connection pooling
- Proper SQL indexing
- PM2 clustering for load distribution
- Rate limiting to prevent overload
๐งฉ Future Improvements
- Add unit and integration testing
- Implement Swagger/OpenAPI documentation
- Consider TypeScript for type safety
- Add Docker configuration for easier deployment
- Implement Continuous Integration/Deployment pipelines
๐ License
This project is licensed under the ISC License. See the LICENSE file for details.
๐ฅ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ง Contact
For questions or support, please open an issue in the GitHub repository.
Made with โค๏ธ by Fayyaz AK