Skip to content

Jithin-b-p/task-java-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task 1 — Java Backend and REST API

This project implements a backend service in Java using Spring Boot that manages "Task" objects and their executions. The application exposes RESTful endpoints for creating, retrieving, deleting, and executing tasks.


Tech Stack used

  • Java 17+

  • Spring Boot

  • MongoDB (docker container)

  • Maven

  • REST API (JSON)

  • Postman


Domain Model

Task

  • id: String — Unique task ID

  • name: String — Task name

  • owner: String — Task owner

  • command: String — Shell command to execute

  • taskExecutions: List of TaskExecution

TaskExecution

  • startTime: Date — Execution start time

  • endTime: Date — Execution end time

  • output: String — Command output


API Endpoints

| Method | Endpoint | Description |

|--------|-----------------------------|------------------------------------------|

| GET | /tasks | Get all tasks |

| GET | /tasks?id={id} | Get task by ID |

| PUT | /tasks | Create or update a task |

| DELETE | /tasks?id={id} | Delete task by ID |

| GET | /tasks/search?name={name} | Search tasks by name |

| PUT | /tasks/{id}/execute | Execute task command and store output |


Command Validation

Only safe shell commands are allowed. The following are permitted:


echo, ls, pwd, whoami, date, uptime, cat, touch, mkdir, sleep, head, tail, df, du

How to Run the Application

Prerequisites

Before running the app, ensure the following are installed:

  • Java 17+

  • Maven

  • MongoDB via Docker


Step 1: Clone the Repository

git clone https://github.com/Jithin-b-p/task-java-backend

cd task-java-backend

Step 2: Start mongodb in docker

docker run -d -p 27017:27017 --name task-mongo mongo

Step 3: Build the project

mvn clean install

Step 4: Run the application

mvn spring-boot:run

Step 5: Test the API enpoints (use Postman/curl)

screenshots

Postman requests

get all tasks create task get task by id get task by name delete task

Database content

mongodb running mongodb content

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages