Skip to content

About

Task Management REST API

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

14 Commits

Folders and files

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

Repository files navigation

Task Management REST API

A production-ready RESTful API for task management featuring JWT authentication, BCrypt encryption, interactive Swagger documentation, and Docker containerization.

πŸš€ Live Demo

  • API Base URL: http://localhost:8080
  • Swagger UI: http://localhost:8080/swagger-ui.html
  • API Documentation: http://localhost:8080/v3/api-docs

✨ Key Features

  • πŸ” JWT Authentication - Secure token-based authentication with 15 mins token validity
  • πŸ”’ Password Encryption - BCrypt hashing with salt for secure password storage
  • πŸ“ Complete CRUD Operations - Create, read, update, delete tasks with full validation
  • πŸ” Advanced Filtering - Filter by status, search by keyword, get statistics
  • βœ… Input Validation - Comprehensive request validation with custom error messages
  • 🚨 Exception Handling - Professional error responses with proper HTTP status codes
  • πŸ“š Interactive Documentation - Auto-generated Swagger UI for API testing
  • 🐳 Docker Ready - One-command deployment with docker-compose
  • πŸ”„ Stateless Architecture - No server-side sessions, fully scalable

πŸ› οΈ Tech Stack

Category Technologies
Backend Java 17, Spring Boot 3.2.2
Security Spring Security, JWT, BCrypt
Database MySQL 8.0
ORM Spring Data JPA (Hibernate)
Documentation SpringDoc OpenAPI 2.3.0 (Swagger)
Containerization Docker, Docker Compose
Build Tool Maven 3.6+
Utilities Lombok

πŸ“‹ Prerequisites

Option 1: Docker (Recommended)

  • Docker Desktop
  • Git

Option 2: Manual Setup

  • Java 17 or higher
  • MySQL 8.0+
  • Maven 3.6+
  • Git

πŸš€ Quick Start

Method 1: Docker Deployment (Recommended)

# Clone repository
git clone https://github.com/mayanksikhwal/task-management-api.git
cd task-management-api

# Build JAR file
mvn clean package -DskipTests

# Start with Docker Compose (one command!)
docker-compose up --build

That's it! πŸŽ‰

Method 2: Manual Setup

1. Clone and navigate:

git clone https://github.com/mayanksikhwal/task-management-api.git
cd task-management-api

2. Configure MySQL:

CREATE DATABASE taskdb;

3. Update application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/taskdb
spring.datasource.username=YOUR_USERNAME
spring.datasource.password=YOUR_PASSWORD

4. Run application:

mvn clean install -DskipTests
mvn spring-boot:run

Application runs on: http://localhost:8080

πŸ“š API Documentation

Swagger UI (Interactive)

Navigate to: http://localhost:8080/swagger-ui.html

How to use:

  1. Go to Swagger UI
  2. Click "POST /api/auth/login"
  3. Click "Try it out"
  4. Enter credentials and execute
  5. Copy the JWT token from response
  6. Click "πŸ”’ Authorize" button (top right)
  7. Enter: Bearer YOUR_TOKEN
  8. Click "Authorize" β†’ "Close"
  9. Now test all protected endpoints!

API Endpoints

Authentication (Public)

Method Endpoint Description Auth Required
POST /api/auth/register Register new user ❌
POST /api/auth/login Login and receive JWT token ❌

Register Request:

{
  "username": "john",
  "email": "john@example.com",
  "password": "password123"
}

Login Request:

{
  "username": "john",
  "password": "password123"
}

Login Response:

{
  "token": "eyJhbGciOiJIUzI1NiJ9...",
  "userId": 1,
  "username": "john",
  "email": "john@example.com",
  "message": "Login successful"
}

Tasks (Protected - Requires JWT)

Method Endpoint Description
POST /api/tasks Create new task
GET /api/tasks Get all tasks for authenticated user
GET /api/tasks/{id} Get specific task
PUT /api/tasks/{id} Update task
DELETE /api/tasks/{id} Delete task
PATCH /api/tasks/{id}/status Update task status
GET /api/tasks/status/{status} Filter by status (TODO, IN_PROGRESS, COMPLETED)
GET /api/tasks/search?keyword={text} Search tasks by keyword
GET /api/tasks/statistics Get task statistics

Create Task Request:

{
  "title": "Complete documentation",
  "description": "Write comprehensive README",
  "status": "IN_PROGRESS",
  "priority": "HIGH",
  "dueDate": "2026-02-25T18:00:00"
}

All task requests require JWT token in header:

Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...

πŸ“Š Database Schema

Users Table

CREATE TABLE users (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(20) UNIQUE NOT NULL,
    email VARCHAR(255) UNIQUE NOT NULL,
    password VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Tasks Table

CREATE TABLE tasks (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(100) NOT NULL,
    description VARCHAR(1000),
    status ENUM('TODO', 'IN_PROGRESS', 'COMPLETED') DEFAULT 'TODO',
    priority ENUM('LOW', 'MEDIUM', 'HIGH') DEFAULT 'MEDIUM',
    due_date TIMESTAMP,
    user_id BIGINT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

🐳 Docker Configuration

Docker Compose Services

MySQL Container:

  • Image: mysql:8.0
  • Port: 3306
  • Database: taskdb
  • User: admin
  • Password: admin123

App Container:

  • Base: eclipse-temurin:17-jdk-alpine
  • Port: 8080
  • Auto-connects to MySQL

Docker Commands

# Start containers
docker-compose up

# Start in background
docker-compose up -d

# Stop containers
docker-compose down

# Stop and remove all data
docker-compose down -v

# View running containers
docker ps

# View logs
docker-compose logs -f

# Restart after code changes
mvn clean package -DskipTests
docker-compose up --build

# Access MySQL container
docker exec -it taskmanagement-mysql mysql -uadmin -padmin123 taskdb

πŸ”’ Security Features

  • Password Encryption: BCrypt with salt (irreversible hashing)
  • JWT Tokens: 15-mins validity, signed with HS256
  • Stateless Sessions: No server-side session storage
  • Protected Endpoints: All task operations require valid JWT
  • Input Validation: Request data validation with error messages
  • CORS Enabled: Configurable for frontend integration
  • SQL Injection Prevention: JPA/Hibernate parameterized queries

πŸ—οΈ Project Structure

task-management-api/
β”œβ”€β”€ src/main/java/com/mayank/taskmanagement/
β”‚   β”œβ”€β”€ config/              # Security & Swagger configuration
β”‚   β”‚   β”œβ”€β”€ SecurityConfig.java
β”‚   β”‚   └── SwaggerConfig.java
β”‚   β”œβ”€β”€ controller/          # REST API endpoints
β”‚   β”‚   β”œβ”€β”€ AuthController.java
β”‚   β”‚   └── TaskController.java
β”‚   β”œβ”€β”€ dto/                 # Data Transfer Objects
β”‚   β”‚   β”œβ”€β”€ AuthResponse.java
β”‚   β”‚   β”œβ”€β”€ LoginRequest.java
β”‚   β”‚   β”œβ”€β”€ RegisterRequest.java
β”‚   β”‚   β”œβ”€β”€ TaskRequest.java
β”‚   β”‚   └── TaskResponse.java
β”‚   β”œβ”€β”€ entity/              # JPA entities
β”‚   β”‚   β”œβ”€β”€ Task.java
β”‚   β”‚   └── User.java
β”‚   β”œβ”€β”€ enums/               # Enumerations
β”‚   β”‚   β”œβ”€β”€ TaskPriority.java
β”‚   β”‚   └── TaskStatus.java
β”‚   β”œβ”€β”€ exception/           # Custom exceptions & handler
β”‚   β”‚   β”œβ”€β”€ BadRequestException.java
β”‚   β”‚   β”œβ”€β”€ ResourceNotFoundException.java
β”‚   β”‚   β”œβ”€β”€ UnauthorizedException.java
β”‚   β”‚   β”œβ”€β”€ ErrorResponse.java
β”‚   β”‚   └── GlobalExceptionHandler.java
β”‚   β”œβ”€β”€ filter/              # JWT authentication filter
β”‚   β”‚   └── JwtAuthenticationFilter.java
β”‚   β”œβ”€β”€ repository/          # JPA repositories
β”‚   β”‚   β”œβ”€β”€ TaskRepository.java
β”‚   β”‚   └── UserRepository.java
β”‚   β”œβ”€β”€ service/             # Business logic
β”‚   β”‚   β”œβ”€β”€ TaskService.java
β”‚   β”‚   └── UserService.java
β”‚   β”œβ”€β”€ util/                # Utility classes
β”‚   β”‚   └── JwtUtil.java
β”‚   └── TaskManagementApiApplication.java
β”œβ”€β”€ src/main/resources/
β”‚   └── application.properties
β”œβ”€β”€ src/test/
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ .dockerignore
β”œβ”€β”€ .gitignore
β”œβ”€β”€ pom.xml
└── README.md

πŸ§ͺ Testing

Run tests:

mvn test

Skip tests during build:

mvn clean install -DskipTests

Test with Postman:

  1. Import endpoints from Swagger
  2. Set up environment variables
  3. Test authentication flow
  4. Test CRUD operations

πŸ“ˆ Project Metrics

  • API Endpoints: 11
  • Database Tables: 2
  • Docker Containers: 2
  • Security Layers: 3 (JWT + BCrypt + Spring Security)
  • Development Time: 4 days
  • Test Coverage: Unit tests with JUnit

🎯 Future Enhancements

  • Email notifications on task events
  • File attachments for tasks
  • Task comments and activity log
  • User profile management
  • Task categories and tags
  • React/Angular frontend
  • Cloud deployment (AWS/Railway)
  • Comprehensive JUnit test suite
  • CI/CD pipeline with GitHub Actions

πŸ‘¨β€πŸ’» Author

Mayank Sikhwal

πŸ“ License

This project is open source and available for educational purposes.

πŸ™ Acknowledgments

Built with Spring Boot ecosystem, secured with industry-standard practices, documented with Swagger, and containerized with Docker.


⭐ If you find this project useful, please star this repository!

πŸ› Found a bug? Open an issue!

πŸ’‘ Have suggestions? Pull requests are welcome!

About

Task Management REST API

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages