A RESTful backend API built with Spring Boot and MySQL for managing todos and categories. This project demonstrates layered architecture, data persistence, soft deletion logic, filtering, sorting, and structured error handling.
The API is designed to serve as the backend for a full-stack Todo application and follows clean separation of concerns between controllers, services, repositories, DTOs, and entities.
- Java
- Spring Boot
- Spring Data JPA
- Hibernate
- MySQL
- Maven
- Jakarta Validation
The application follows a standard layered architecture:
Controller → Service → Repository → Database
- Controllers handle HTTP requests and responses
- Services contain business logic and validation
- Repositories interact with the database via JPA
- DTOs define request/response contracts
- Entities map to database tables
The project also includes:
- Global exception handling
- Custom error response structure
- Timestamp handling via entity listeners
- Soft delete implementation for todos
- Create category
- Update category
- Delete category
- Retrieve all categories
- Unique category name validation Categories are stored in a separate table and linked to todos via @ManyToOne.
- Create todo
- Update todo (partial updates supported)
- Archive todo (soft delete)
- Retrieve all active todos
- Toggle completion
- Filter todos by category
- Sort todos (createdAt, title, completed)
- Excludes archived todos from standard queries
- Automatic createdAt and updatedAt timestamps
- Validation with meaningful error responses
- Clean 400 / 404 error handling
Method Endpoint Description GET /categories Retrieve all categories POST /categories Create new category PUT /categories/{id} Update category DELETE /categories/{id} Delete category
Method Endpoint Description GET /todos Retrieve todos GET /todos?category={id} Filter by category POST /todos Create todo PUT /todos/{id} Update todo POST /api/todos/{id}/duplicate Duplicate todo
-
Create .env file based on .env.example
-
Ensure MySQL is running
-
Start the application:
mvn spring-boot:runAPI base path:
http://localhost:8080/apiThis project was built as part of a structured software development program to deepen understanding of backend architecture and RESTful API design.
Key areas of learning include:
- Designing clean layered architecture in Spring Boot
- Implementing DTO-driven request/response mapping
- Handling relational data with JPA
- Implementing soft delete patterns
- Building robust validation and error handling
- Applying sorting and filtering logic
- Managing environment configuration securely
- Understanding development vs production configuration strategies
The project emphasises maintainable structure, separation of concerns, and production-style coding practices rather than minimal CRUD implementation.