A RESTful API for managing tasks, built with Spring Boot. This project allows users to create, retrieve, update, and delete tasks, organize them by status, and integrate with a database using Spring Data JPA. The API is designed to be testable, extensible, and secure (with optional Spring Security in later stages).
The Task Manager API enables users to:
- Create, retrieve, update, and delete tasks
- Organize tasks by status (e.g., pending, completed)
- Integrate with a database using Spring Data JPA
- Be tested using
@WebMvcTestor@SpringBootTestand MockMvc - Optionally secure endpoints using Spring Security (planned for later stages)
- Java: 17+
- Spring Boot: Framework for building the application
- Spring Web: For creating RESTful APIs
- Spring Data JPA: For database integration
- H2 Database: In-memory database for development and testing (MySQL/PostgreSQL support planned)
- JUnit + MockMvc: For unit and integration testing
- (Optional later) Spring Security with JWT or basic authentication
The project follows a clean, layered architecture with packages organized by responsibility. Below is the structure of the source code:
Task-Manager-API
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com.example.task_manager_api
│ │ │ ├── controller
│ │ │ │ └── TaskController.java # REST controller for task endpoints
│ │ │ ├── model
│ │ │ │ ├── Task.java # Task entity
│ │ │ │ └── TaskStatus.java # Enum for task status
│ │ │ │ └── TaskStatus.java # TaskRequest entity
│ │ │ ├── repository
│ │ │ │ └── TaskRepository.java # JPA repository for Task entity
│ │ │ ├── service
│ │ │ │ └── TaskService.java # Service layer for business logic
│ │ │ └── TaskManagerApiApplication.java # Main Spring Boot application class
│ │ └── resources
│ │ └── application.properties # Application configuration
│ └── test
│ ├── java
│ │ └── com.example.task_manager_api
│ │ ├── controller
│ │ │ └── TaskControllerTest.java # Tests for TaskController
│ │ ├── service
│ │ │ └── TaskServiceTest.java # Tests for TaskService
│ │ └── TaskManagerApiApplicationTests.java # Application context tests
└── pom.xml # Maven dependencies and build configuration
com.example.task_manager_api.controller: Contains REST controllers (e.g.,TaskController) that handle HTTP requests and responses.com.example.task_manager_api.model: Defines the data models, including theTaskentity andTaskStatusenum.com.example.task_manager_api.repository: Contains Spring Data JPA repositories (e.g.,TaskRepository) for database operations.com.example.task_manager_api.service: Implements business logic in service classes (e.g.,TaskService).com.example.task_manager_api(root package): Contains the main application class (TaskManagerApiApplication).
Tests are organized similarly under src/test/java, mirroring the main package structure for clarity.
- ✅ Initialize Spring Boot project (done)
- ✅ Add required dependencies (
spring-boot-starter-web,spring-boot-starter-data-jpa,h2,spring-boot-starter-test) - ✅ Create main application class (
TaskManagerApiApplication)
- ✅ Define
Taskentity with fields:id,taskName,description,dueDate,status,tags - ✅ Define
TaskStatusenum for task status (e.g.,TODO,IN_PROGRESS,DONE)
- ✅ Create
TaskRepositoryextendingJpaRepository<Task, Long>
- ✅ Create
TaskServiceto encapsulate business logic (add, update, get, delete)
- ✅ Create
TaskControllerwith REST endpoints:GET /api/task→ List all tasksPOST /api/task→ Create a taskGET /api/task/{id}→ Get task by IDPUT /api/task/{id}→ Update a taskDELETE /api/task/{id}→ Delete a taskGET /api/task/status/{status}→ Filter by statusGET /api/task/due?before=...→ Tasks due before date
- ✅ Test
TaskService(unit test with mocks) - ✅ Unit test
TaskControllerusing@SpringBootTestand MockMvc - ✅ Use MockMvc to simulate HTTP requests
- ✅ Use
@Valid,@NotNull,@Size, etc., on request DTOs - ⏳ Create custom error responses using
@ControllerAdvice
- ⏳ Filtering tasks by status or due date (e.g.,
GET /api/task?status=completed) - ⏳ Add pagination support
- ⏳ Spring Security with login or token authentication
- ⏳ Dockerize the app
- ⏳ Deploy to Heroku, Render, or Railway
- Set up Spring Boot project ✅
- Define
Taskmodel and enum ✅ - Create repository with Spring Data JPA ✅
- Build controller and service for CRUD ✅
- Validate input (e.g.,
taskNamenot blank) ⏳
- Add unit tests for the service layer ⏳
- Add integration tests for controllers using
@SpringBootTest✅
- Use Docker + PostgreSQL ⏳
- Add filtering endpoints ⏳
- Add Swagger/OpenAPI documentation ⏳
- Optional: Add authentication (JWT) ⏳
- Java 17 or higher
- Maven for dependency management and building the project
-
Clone the repository:
git clone <repository-url> cd Task-Manager-API
-
Install dependencies:
mvn clean install
-
Run the application:
mvn spring-boot:run
The API will be available at
http://localhost:8080. -
Access the H2 Console (for development):
- URL:
http://localhost:8080/h2-console - JDBC URL:
jdbc:h2:mem:testdb - Username:
sa - Password: (leave blank)
- URL:
- Use tools like Postman or curl to test the endpoints.
- Example: Create a task
curl -X POST http://localhost:8080/api/task \ -H "Content-Type: application/json" \ -d '{"taskName":"Test Task","description":"Some Description","status":"TODO","dueDate":"2025-05-10","tags":["work","test"]}'
- Run all tests:
mvn test - Tests are located in
src/test/java/com/example/task_manager_api.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/task |
List all tasks |
| POST | /api/task |
Create a new task |
Additional endpoints (planned):
GET /api/task/{id}– Get task by IDPUT /api/task/{id}– Update a taskDELETE /api/task/{id}– Delete a taskGET /api/task/status/{status}– Filter tasks by status
- Add Spring Security with JWT or basic authentication to secure endpoints.
This project is licensed under the MIT License – see the LICENSE file for details.
Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request.