Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Task Manager Backend API

A secure Spring Boot REST API for managing tasks with authentication and role-based access control.

This project demonstrates how to build a secure backend system with:

• Spring Boot
• Spring Security
• PostgreSQL
• Layered Architecture

Think of it as the backend engine of a productivity app where users manage tasks while admins control task operations.


✨ Features

🔐 Secure authentication with Spring Security
👤 User registration with encrypted passwords
📋 Task creation, update, deletion and retrieval
📊 Pagination support for task listing
🔎 Task filtering by status and priority
🛡 Role-based authorization (ADMIN / USER)
⚠ Centralized exception handling
🗄 PostgreSQL database persistence


🛠 Tech Stack

Technology Purpose
☕ Java Programming language
🌱 Spring Boot Backend framework
🔐 Spring Security Authentication & authorization
🗃 Spring Data JPA Database access
🐘 PostgreSQL Database
📦 Maven Dependency management

🏗 System Architecture

The backend follows a layered architecture to maintain separation of concerns.

flowchart LR
    Client --> Controller
    Controller --> Service
    Service --> Validator
    Service --> Repository
    Repository --> Database
Loading

Controller

Handles incoming HTTP requests and returns responses.

Example:
TaskManagerController

Service

Contains the core business logic.

Example:
TaskManagerService

Validator

Handles input validation and business rules.

Example:
TaskManagerValidator

Repository

Handles database operations using Spring Data JPA.

Example:
TaskRepository

Database

Stores users and tasks in PostgreSQL.


📁 Project Structure

task-manager
│
├── controller
│   └── TaskManagerController.java
│
├── service
│   └── TaskManagerService.java
│
├── validator
│   └── TaskManagerValidator.java
│
├── repository
│   ├── TaskRepository.java
│   └── UserRepository.java
│
├── security
│   ├── SecurityConfig.java
│   └── CustomUserDetailsService.java
│
├── exception
│   └── GlobalExceptionHandler.java
│
├── model
│   ├── Task.java
│   ├── User.java
│   └── Status.java
│
└── TaskManagerApplication.java

📊 Task Status

Each task can have one of the following statuses:

RUNNING
SUSPENDED
TERMINATED

🌐 API Endpoints

👤 User APIs

Method Endpoint Description
POST /register Register a new user

📋 Task APIs

Method Endpoint Access Description
POST /tasks ADMIN Create a task
GET /tasks?page=&size= ADMIN, USER View paginated tasks
GET /tasks/{pid} ADMIN, USER View task by PID
PATCH /tasks/{pid} ADMIN Update task
DELETE /tasks/{pid} ADMIN Delete task

🔎 Filter API

Method Endpoint
GET /tasks/filter?status=&priority=

Allows filtering tasks by:

• status
• priority


🛡 Admin Test APIs

Method Endpoint
GET /admin/test
GET /deleteTest

Used to test role-based access control.


📬 API Request Examples

Register User

POST /register
Content-Type: application/json
{
  "username": "cos",
  "password": "12345"
}

Create Task

POST /tasks
Authorization: Basic Auth
Content-Type: application/json
{
  "name": "Complete backend project",
  "priority": 1,
  "status": "RUNNING"
}

Get Paginated Tasks

GET /tasks?page=0&size=5

Filter Tasks

GET /tasks/filter?status=RUNNING

or

GET /tasks/filter?priority=2

⚡ Running the Project

1 Clone the repository

git clone https://github.com/yourusername/task-manager-backend.git

2 Go to project folder

cd task-manager-backend

3 Configure PostgreSQL

Update application.properties

spring.datasource.url=jdbc:postgresql://localhost:5432/taskdb
spring.datasource.username=youruser
spring.datasource.password=yourpassword

4 Run the application

mvn spring-boot:run

Server will start at

http://localhost:8080

🧪 Testing the API

Use Postman or any REST client.

Typical workflow:

1️⃣ Register a user
2️⃣ Login using form authentication
3️⃣ Use APIs to create and manage tasks


🔮 Future Improvements

🚀 JWT authentication
📄 Swagger API documentation
🐳 Docker containerization
📊 Task analytics dashboard
📧 Email notifications


📚 What I Learned

✔ Secure REST API development with Spring Boot
✔ Authentication and authorization with Spring Security
✔ Database design using JPA
✔ Pagination and filtering in REST APIs
✔ Layered backend architecture


⭐ If you like this project, consider giving it a star.

About

Spring Boot REST backend for task management

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages