A RESTful API for managing todos built with Spring Boot, PostgreSQL, and Docker.
- ✅ Create, Read, Update, Delete (CRUD) operations for todos
- ✅ Toggle todo completion status
- ✅ Filter todos by completion status
- ✅ PostgreSQL database
- ✅ Docker and Docker Compose support
- ✅ Validation with Bean Validation
- ✅ Lombok for cleaner code
- Java 17
- Spring Boot 3.2.3
- Spring Data JPA
- PostgreSQL 16
- Lombok
- Maven
- Docker & Docker Compose
- Docker and Docker Compose installed
- Clone the repository and navigate to the project directory:
cd todo-java- Build and start the containers:
docker-compose up --buildThe application will be available at http://localhost:8080
- To stop the containers:
docker-compose downGET /api/todosGET /api/todos?completed=true
GET /api/todos?completed=falseGET /api/todos/{id}POST /api/todos
Content-Type: application/json
{
"title": "My Todo",
"description": "Description here",
"completed": false
}PUT /api/todos/{id}
Content-Type: application/json
{
"title": "Updated Todo",
"description": "Updated description",
"completed": true
}PATCH /api/todos/{id}/toggleDELETE /api/todos/{id}curl -X POST http://localhost:8080/api/todos \
-H "Content-Type: application/json" \
-d '{"title": "Learn Spring Boot", "description": "Complete the tutorial"}'curl http://localhost:8080/api/todoscurl -X PATCH http://localhost:8080/api/todos/1/toggleThe application uses PostgreSQL with the following default configuration:
- Database:
tododb - User:
todouser - Password:
todopass - Port:
5432
todo-java/
├── src/
│ └── main/
│ ├── java/
│ │ └── com/
│ │ └── example/
│ │ └── todo/
│ │ ├── TodoApplication.java
│ │ ├── controller/
│ │ │ └── TodoController.java
│ │ ├── service/
│ │ │ └── TodoService.java
│ │ ├── repository/
│ │ │ └── TodoRepository.java
│ │ ├── model/
│ │ │ └── Todo.java
│ │ └── dto/
│ │ ├── TodoRequest.java
│ │ └── TodoResponse.java
│ └── resources/
│ └── application.properties
├── Dockerfile
├── docker-compose.yml
└── pom.xml
To run the application locally without Docker, you need:
- Java 17 or higher
- Maven 3.6+
- PostgreSQL running locally
Update application.properties with your local database configuration and run:
mvn spring-boot:run