Before you begin, ensure you have the following installed on your machine:
- Java 17 or higher
- Maven 3.6.3 or higher
- An IDE such as IntelliJ IDEA
- MySQL 8.0 or higher
-
Clone the repository:
git clone https://github.com/TheMarvelFan/task-management-system.git cd task-management-system -
Create Database and Tables:
Create a database named
task_managementin MySQL and run the following SQL queries to create the tables.CREATE TABLE users ( id BIGINT AUTO_INCREMENT PRIMARY KEY, email VARCHAR(255) NOT NULL UNIQUE, username VARCHAR(255) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL ); CREATE TABLE tasks ( id BIGINT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) NOT NULL, description TEXT, due_date DATE, priority ENUM('LOW', 'MEDIUM', 'HIGH') DEFAULT 'LOW', status ENUM('PENDING', 'COMPLETED') DEFAULT 'PENDING', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, user_id BIGINT, is_deleted TINYINT(1) DEFAULT 0, FOREIGN KEY (user_id) REFERENCES users(id) ); CREATE TABLE subtasks ( id BIGINT AUTO_INCREMENT PRIMARY KEY, description TEXT, status ENUM('PENDING', 'COMPLETED') DEFAULT 'PENDING', task_id BIGINT, is_deleted BIT DEFAULT 0, FOREIGN KEY (task_id) REFERENCES tasks(id) );
-
Build the project:
mvn clean install
-
Configure the application properties:
Update the
src/main/resources/application.propertiesfile with your database and JWT configurations. I am including my own application.properties file for reference.jwt.expiration=3600000 jwt.secret=your_secret_key spring.datasource.password=yourpassword spring.datasource.url=jdbc:mysql://localhost:3306/task_management spring.datasource.username=root
-
Run the application:
mvn spring-boot:run
- URL:
/api/auth/register - Method:
POST - Headers:
Content-Type: application/json - Body:
This will return a JWT token which you can use to task and subtask endpoints.
{ "email": "user@example.com", "username": "user", "password": "password" }
- URL:
/api/auth/login - Method:
POST - Headers:
Content-Type: application/json - Body:
This will return a JWT token which you can use to task and subtask endpoints.
{ "emailOrUsername": "user@example.com", "password": "password" }
- URL:
/api/tasks - Method:
POST - Headers:
Content-Type: application/json,Authorization: Bearer <token> - Body:
{ "title": "New Task", "description": "Task description", "dueDate": "2023-12-31", "priority": "HIGH" }
- URL:
/api/tasks/{taskId} - Method:
PUT - Headers:
Content-Type: application/json,Authorization: Bearer <token> - Body:
{ "title": "Updated Task", "description": "Updated description", "dueDate": "2023-12-31", "priority": "MEDIUM" }
- URL:
/api/tasks/{taskId} - Method:
DELETE - Headers:
Authorization: Bearer <token>
- URL:
/api/tasks/{taskId} - Method:
GET - Headers:
Authorization: Bearer <token>
- URL:
/api/tasks - Method:
GET - Headers:
Authorization: Bearer <token> - Params:
priority(optional)dueDate(optional)subtasksCount(optional)title(optional)status(optional)createdAt(optional)updatedAt(optional)page(default: 0)size(default: 10)
- URL:
/api/subtasks/task/{taskId} - Method:
POST - Headers:
Content-Type: application/json,Authorization: Bearer <token> - Body:
{ "description": "SubTask description" }
- URL:
/api/subtasks/{subTaskId}/status/{status} - Method:
PUT - Headers:
Authorization: Bearer <token>
- URL:
/api/subtasks/{subTaskId} - Method:
DELETE - Headers:
Authorization: Bearer <token>
- URL:
/api/subtasks/{subTaskId} - Method:
GET - Headers:
Authorization: Bearer <token>
- URL:
/api/subtasks - Method:
GET - Headers:
Authorization: Bearer <token> - Params:
taskId(optional)page(default: 0)size(default: 10)
You can use tools like Postman or cURL to test the endpoints. Make sure to include the Authorization header with the JWT token for protected endpoints.
Please do not put a trailing slash at the end of the endpoints. For example, use http://localhost:8080/api/tasks instead of http://localhost:8080/api/tasks/.