Skip to content

REST API for Task Manager using Spring Boot 3, Java 17, and MongoDB. Provides CRUD operations and command execution with validation. Built for Kaiburr Assessment 2025.

Notifications You must be signed in to change notification settings

ShyamAnand2/Kaiburr-Assessment-Task1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kaiburr Assessment - Task 1: Java REST API

Author: Shyam Anand
Date: October 19, 2025

Overview

This project implements a Java-based REST API for managing task objects that represent shell commands. The application is built using Spring Boot 3.5.6, MongoDB for data persistence, and provides endpoints for creating, searching, updating, deleting, and executing shell commands.

Technology Stack

  • Java: 17
  • Framework: Spring Boot 3.5.6
  • Database: MongoDB (Local instance)
  • Build Tool: Maven
  • Testing: Postman

Project Structure

C:.
|   .gitattributes
|   .gitignore
|   Dockerfile
|   HELP.md
|   mvnw
|   mvnw.cmd
|   pom.xml
|   structure.txt
|   
+---.mvn
|   \---wrapper
|           maven-wrapper.properties
|           
+---.vscode
|       settings.json
|       
+---Kubernetes_YAML
|       app-deployment.yaml
|       mongodb-deployment.yaml
|       rbac.yaml
|       
+---src
|   +---main
|   |   +---java
|   |   |   \---com
|   |   |       \---platinum
|   |   |           \---task_manager
|   |   |                   CorsConfig.java
|   |   |                   PlatinumTaskManagerApplication.java
|   |   |                   Task.java
|   |   |                   TaskController.java
|   |   |                   TaskExecution.java
|   |   |                   TaskRepository.java
|   |   |                   
|   |   \---resources
|   |       |   application.properties
|   |       |   
|   |       +---static
|   |       \---templates
|   \---test
|       \---java
|           \---com
|               \---platinum
|                   \---task_manager
|                           TaskManagerApplicationTests.java
|                           
\---target
    |   task-manager-0.0.1-SNAPSHOT.jar
    |   task-manager-0.0.1-SNAPSHOT.jar.original
    |   
    +---classes
    |   |   application.properties
    |   |   
    |   \---com
    |       \---platinum
    |           \---task_manager
    |                   CorsConfig.class
    |                   PlatinumTaskManagerApplication.class
    |                   Task.class
    |                   TaskController.class
    |                   TaskExecution.class
    |                   TaskRepository.class
    |                   
    +---generated-sources
    |   \---annotations
    +---generated-test-sources
    |   \---test-annotations
    +---maven-archiver
    |       pom.properties
    |       
    +---maven-status
    |   \---maven-compiler-plugin
    |       +---compile
    |       |   \---default-compile
    |       |           createdFiles.lst
    |       |           inputFiles.lst
    |       |           
    |       \---testCompile
    |           \---default-testCompile
    |                   createdFiles.lst
    |                   inputFiles.lst
    |                   
    \---test-classes
        \---com
            \---platinum
                \---task_manager
                        TaskManagerApplicationTests.class

Setup and Installation

Prerequisites

  • Java 17 or higher
  • Maven
  • MongoDB (running locally on port 27017)

Steps to Run

  1. Clone the repository: git clone https://github.com/ShyamAnand2/Kaiburr-Assessment-Task1.git cd Kaiburr-Assessment-Task1

  2. Ensure MongoDB is running: mongod --dbpath=C:\data\db

  3. Build and run the application: mvnw.cmd spring-boot:run

  4. The application will start on: http://localhost:8080

Data Model

Task Object

{ "id": "string", "name": "string", "owner": "string", "command": "string", "taskExecutions": [ { "startTime": "date", "endTime": "date", "output": "string" } ] }

API Endpoints

1. Create a Task

Endpoint: POST /tasks
Description: Creates a new task with the specified name, owner, and command.

Request Body: { "name": "platinum-test", "owner": "Shyam", "command": "echo platinum" }

Screenshot: Task-1-POST


2. Get All Tasks

Endpoint: GET /tasks
Description: Returns a list of all tasks stored in the database.

Screenshot: Task-1-GET


3. Search Tasks by Name

Endpoint: GET /tasks/search?name={searchString}
Description: Searches for tasks where the name contains the specified string.

Example: GET /tasks/search?name=platinum

Screenshot: Task-1-GET-2


5. Update a Task

Endpoint: PUT /tasks/{id}
Description: Updates an existing task with new data.

Request Body: { "name": "platinum-updated", "owner": "Shyam", "command": "echo updated" }

Screenshot:

Before: When we specifically create a platinum-original task to showcase the update functionality Task-1-UPDATE-1

After: The GET with all the tasks to showcase that PUT was used to update platinum-original to platinum-updated. Task-1-UPDATE-2


6. Delete a Task

Endpoint: DELETE /tasks/{id}
Description: Deletes a task by its ID.

Example: DELETE /tasks/671234abcd5678ef

Screenshot:

Before: Refer to the ID fo the task which was deleted to showcase functionality. Task-1-DELETE

After: One of them missing, run with the DELETE command. Task-1-DELETE-2


7. Execute Task Command

Endpoint: PUT /tasks/{id}/execute
Description: Executes the shell command associated with the task and stores the execution result (startTime, endTime, output) in the taskExecutions array.

Example: PUT /tasks/671234abcd5678ef/execute

Note: No request body required. Only commands starting with "echo " are allowed for security reasons.

Screenshot - After Execution: Task-1-EXECUTE The time stamp in the taskExecutions bar shows the time when the code has been executed, and the table in the Preview part shows how many times the task has been executed.


Security Considerations

  • Command validation is implemented to allow only safe echo commands
  • Commands must start with "echo " to be executed
  • This prevents execution of potentially malicious or unsafe shell commands

MongoDB Data Verification

The following screenshot shows the tasks stored in MongoDB Compass: Task-1-MONGO


Testing with Postman

All endpoints were tested using Postman. The screenshots above demonstrate:

  • Request URL and HTTP method
  • Request body (where applicable)
  • Response with status code
  • Timestamp and author name visible

Sample Request/Response

Create Task Example

Request: POST http://localhost:8080/tasks Content-Type: application/json

{ "name": "platinum-two", "owner": "Shyam", "command": "echo platinum 2" }

Response: { "id": "68f4e3925c39df428267296f", "name": "platinum-two", "owner": "Shyam", "command": "echo platinum 2", "taskExecutions": [] }

Execute Task Example

Request: PUT http://localhost:8080/tasks/68f4e3925c39df428267296f/execute

Response: { "id": "68f4e3925c39df428267296f", "name": "platinum-two", "owner": "Shyam", "command": "echo platinum 2", "taskExecutions": [ { "startTime": "2025-10-19T13:30:15.123+00:00", "endTime": "2025-10-19T13:30:15.456+00:00", "output": "platinum 2\n" } ] }

Known Limitations

  • Only echo commands are supported for execution
  • Commands are executed locally on Windows using cmd.exe /c
  • No authentication/authorization implemented (as per task requirements)

Future Enhancements

  • Support for additional safe shell commands
  • Kubernetes pod execution (Task 2 requirement)
  • Input validation and error handling improvements
  • Rate limiting and request throttling

Author Notes

All screenshots in this README include:

  • My name (Shyam Anand) visible in the environment
  • System timestamp visible in the taskbar
  • Complete request/response information

Repository: https://github.com/ShyamAnand2/Kaiburr-Assessment-Task1
Submission Date: October 20, 2025

About

REST API for Task Manager using Spring Boot 3, Java 17, and MongoDB. Provides CRUD operations and command execution with validation. Built for Kaiburr Assessment 2025.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages