A production-ready RESTful API for task management featuring JWT authentication, BCrypt encryption, interactive Swagger documentation, and Docker containerization.
- API Base URL:
http://localhost:8080 - Swagger UI:
http://localhost:8080/swagger-ui.html - API Documentation:
http://localhost:8080/v3/api-docs
- π 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
| 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 |
Option 1: Docker (Recommended)
- Docker Desktop
- Git
Option 2: Manual Setup
- Java 17 or higher
- MySQL 8.0+
- Maven 3.6+
- Git
# 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 --buildThat's it! π
- Application: http://localhost:8080
- Swagger UI: http://localhost:8080/swagger-ui.html
- MySQL: localhost:3306 (auto-configured)
1. Clone and navigate:
git clone https://github.com/mayanksikhwal/task-management-api.git
cd task-management-api2. 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_PASSWORD4. Run application:
mvn clean install -DskipTests
mvn spring-boot:runApplication runs on: http://localhost:8080
Navigate to: http://localhost:8080/swagger-ui.html
How to use:
- Go to Swagger UI
- Click "POST /api/auth/login"
- Click "Try it out"
- Enter credentials and execute
- Copy the JWT token from response
- Click "π Authorize" button (top right)
- Enter:
Bearer YOUR_TOKEN - Click "Authorize" β "Close"
- Now test all protected endpoints!
| 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"
}| 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...
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
);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
);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
# 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- 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
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
Run tests:
mvn testSkip tests during build:
mvn clean install -DskipTestsTest with Postman:
- Import endpoints from Swagger
- Set up environment variables
- Test authentication flow
- Test CRUD operations
- 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
- 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
Mayank Sikhwal
- GitHub: @mayanksikhwal
- LinkedIn: Mayank Sikhwal
- Email: sikhwalmayank251@gmail.com
- Location: Hyderabad, India
This project is open source and available for educational purposes.
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!