A simple Task Management REST API built with Spring Boot, JPA, and H2 in-memory database. This project allows you to create, read, update, delete, filter, and paginate tasks.
- Create, update, delete, and retrieve tasks by ID
- Retrieve all tasks or paginated tasks with sorting
- Filter tasks by status, due date, or both
- Retrieve tasks with due date up to a specific date
- Input validation and global exception handling
- In-memory H2 database with sample data
- Swagger/OpenAPI documentation
- Dockerized application for easy deployment
- Java 11
- Spring Boot 2.7.5
- Spring Data JPA
- H2 Database
- Maven
- Swagger/OpenAPI (springdoc-openapi-ui)
- Docker
Method | Endpoint | Description |
---|---|---|
POST | /v1/tasks |
Create a new task |
GET | /v1/tasks/{id} |
Get a task by ID |
PUT | /v1/tasks/{id} |
Update a task by ID |
DELETE | /v1/tasks/{id} |
Delete a task by ID |
GET | /v1/tasks |
Get all tasks |
GET | /v1/tasks/paginated |
Get paginated and sorted tasks |
GET | /v1/tasks/filter |
Filter tasks by status and/or due date |
GET | /v1/tasks/till-date |
Get tasks with due date up to a specific date |
/v1/tasks/filter?status=TODO&dueDate=2024-06-01
— filter by status and due date (both optional)/v1/tasks/paginated?page=0&size=10&sortBy=dueDate&direction=ASC
— pagination and sorting
-
Task
id
: Long (auto-generated)title
: String (required)description
: Stringstatus
: Enum (TODO
,IN_PROGRESS
,DONE
)dueDate
: LocalDate
-
ApiResponseDto<T>
message
: Stringdata
: Tsuccess
: boolean
- Uses H2 in-memory database
- Sample data is loaded on startup (see
src/main/resources/schema.sql
) - H2 Console available at: http://localhost:8080/h2-console
- Swagger UI: http://localhost:8080/swagger-ui/index.html
- OpenAPI docs: http://localhost:8080/v3/api-docs
-
Clone the repository
git clone <your-repo-url> cd <project-directory>
-
Build the project
mvn clean install
-
Run the application
mvn spring-boot:run
or run the
TaskManagementApplication
main class from your IDE. -
Access the API
- API base URL:
http://localhost:8080/v1/tasks
- Swagger UI: http://localhost:8080/swagger-ui.html
- H2 Console: http://localhost:8080/h2-console
- API base URL:
Note:
- Default H2 credentials:
- Username:
sa
- Password: (leave blank)
- Username:
- JDBC URL:
jdbc:h2:mem:testdb
-
Generate Javadoc using Maven
mvn javadoc:javadoc
-
Generate Javadoc for a Specific File :
Run the following command to generate Javadoc for TestController.java :javadoc -d docs/ src/main/java/org/mikhi/taskM/controller/TestController.java
-
Output The generated Javadoc will be available in:
target/site/apidocs/
-
View the Javadoc Open the following file in a browser:
target/site/apidocs/index.html
-
Navigate to your TestController documentation.
The application is now Dockerized (also for easy deployment). Follow the steps below to build and run the Docker container:
(This project comes with a Dockerfile to easily build and run the Spring Boot application in a containerized environment.)
-
Create a Dockerfile in root directory
You can refer dockerfile in root dir for details
-
Build the Docker image
docker build -t task-management-api .
instead of 'task-management-api' , we can use any name
-
Run the Docker container
docker run -p 8080:8080 task-management-api
-
Access the API
- API base URL:
http://localhost:8080/v1/tasks
- Swagger UI: http://localhost:8080/swagger-ui.html
- API base URL:
The application is hosted and accessible at: mikhi-task-mgmt-java-sp-app
plain-text-link : https://mikhi-task-mgmt-java-sp-app.onrender.com/swagger-ui/index.html
(a big thanks to Render for providing free hosting )
🕒 Note: This project is hosted on Render's free tier. It may take up to 30 seconds to load after periods of inactivity.
A background ping keeps it active most of the time.
> P.S. This project stays online thanks to [UptimeRobot](https://uptimerobot.com/), which pings the site every few minutes. I'm currently using the free tier to keep it running.