The Task Management Application allows users to create, update, delete, and manage tasks. Users can also mark tasks as complete and filter/sort tasks based on various criteria. The application includes user authentication to associate tasks with specific users.
- Java 11 or higher
- Maven 3.6+
- PostgreSQL (or any preferred relational database)
git clone https://github.com/your-username/task-management-application.git
cd task_mgt_app
- Update
src/main/resources/application.properties1
with your database and JWT configurations:
spring.datasource.url=jdbc:postgresql://localhost:5432/task_management_db
spring.datasource.username=your_db_username
spring.datasource.password=your_db_password
spring.jpa.hibernate.ddl-auto=update
jwt.secret=your_jwt_secret
mvn clean install
mvn spring-boot:run
The application will start on http://localhost:8080
.
- Swagger Docs
- You can access the api swagger documentation here
http://localhost:8080/swagger-ui/index.html
- You can access the api swagger documentation here
- Register User
POST /register
Request Body:
{
"firstName": "exampleUser",
"lastName": "exampleUser",
"password": "examplePassword",
"email": "[email protected]"
}
Response:
{
"id": 1,
"firstName": "exampleUser",
"lastName": "exampleUser",
"email": "[email protected]"
}
- Login User
POST /login
Request Body:
{
"email": "[email protected]",
"password": "examplePassword"
}
Response:
{
"token": "jwt_token"
}
- Get User by ID
GET /users/{id}
Headers:
Authorization: Bearer jwt_token
Response:
{
"id": 1,
"firstName": "exampleUser",
"lastName": "exampleUser",
"email": "[email protected]"
}
- Update User
PUT /users/{id}
Headers:
Authorization: Bearer jwt_token
Request Body:
{
"id": 1,
"firstName": "exampleUser",
"lastName": "exampleUser",
"email": "[email protected]"
}
Response:
{
"id": 1,
"firstName": "exampleUser",
"lastName": "exampleUser",
"email": "[email protected]"
}
- Delete User
DELETE /users/{id}
Headers:
Authorization: Bearer jwt_token
Response:
json
{
"message": "User deleted successfully"
}
Create Task
POST /users/user_id/tasks
Headers:
Authorization: Bearer jwt_token
Request Body:
{
"title": "Task Title",
"description": "Task Description",
"dueDate": "2024-07-10"
}
Response:
{
"id": 1,
"title": "Task Title",
"description": "Task Description",
"dueDate": "2024-07-10",
"completionStatus": false,
"createdAt": "2024-07-01T12:00:00",
"updatedAt": "2024-07-01T12:00:00"
}
- Get All Tasks of a user
GET /users/{user_id}/tasks
Headers:
Authorization: Bearer jwt_token
Response:
[
{
"id": 1,
"title": "Task Title",
"description": "Task Description",
"dueDate": "2024-07-10",
"completionStatus": false,
"createdAt": "2024-07-01T12:00:00",
"updatedAt": "2024-07-01T12:00:00"
}
]
Update Task
PUT /tasks/{id}
Headers:
Authorization: Bearer jwt_token
Request Body:
{
"title": "Updated Task Title",
"description": "Updated Task Description",
"dueDate": "2024-07-15",
"completionStatus": true
}
Response:
{
"id": 1,
"title": "Updated Task Title",
"description": "Updated Task Description",
"dueDate": "2024-07-15",
"completionStatus": true,
"createdAt": "2024-07-01T12:00:00",
"updatedAt": "2024-07-01T12:30:00"
}
- Delete Task
DELETE /tasks/{id}
Headers:
Authorization: Bearer jwt_token
Response:
{
"message": "Task deleted successfully"
}
- Get Tasks with Filtering and Sorting
GET users/{user_id}/tasks
Headers:
Authorization: Bearer jwt_token
Query Parameters:
completionStatus: (optional) Filter by completion status (true or false)
dueDate: (optional) Filter by due date (e.g., 2024-07-10)
Example Request:
GET users/{user_id}/tasks?completionStatus=false&dueDate=2024-07-10
Response:
[
{
"id": 1,
"title": "Task Title",
"description": "Task Description",
"dueDate": "2024-07-10",
"completionStatus": false,
"createdAt": "2024-07-01T12:00:00",
"updatedAt": "2024-07-01T12:00:00"
}
]
Usage
Send a POST request to /register with the required user details.
Use the received token for subsequent authenticated requests.
Send a POST request to /tasks with the task details.
Use the token received during user registration or login in the Authorization header.
Send a GET request to /tasks with the desired query parameters.
Use the token in the Authorization header.
- src/main/java: Contains the Java source code.
- controller: REST controllers for handling HTTP requests.
- service: Business logic for handling tasks and users.
- repository: JPA repositories for database interactions.
- model: Entity classes representing the database tables.
- config: Configuration classes for security and application settings.
- Fork the repository.
- Create a new branch (git checkout -b feature-branch).
- Make your changes and commit them (git commit -m 'Add some feature').
- Push to the branch (git push origin feature-branch).
- Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.