A complete Todo List application built with Spring Boot, PostgreSQL, and Docker.
- ✅ Create, read, update, and delete todos
- ✅ Mark todos as complete/incomplete
- ✅ Filter todos by status (all, completed, incomplete)
- ✅ Search todos by title
- ✅ Persistent storage with PostgreSQL
- ✅ RESTful API
- ✅ Simple web frontend
- ✅ Docker containerization
- Java 21
- Maven (included via wrapper)
- Docker Desktop (must be running)
- Ensure Docker Desktop is running on your machine
- Start the PostgreSQL database container using Docker Compose
- Run the Spring Boot application using the Maven wrapper
- Access the application:
- Web Frontend:
http://localhost:8080 - API:
http://localhost:8080/api/todos
- Web Frontend:
- Launch Docker Desktop and wait for it to be fully running
- Start the PostgreSQL container from the docker-compose configuration
- Start the Spring Boot application using Maven
- Stop the Spring Boot application (interrupt the process)
- Stop the PostgreSQL container using Docker Compose
- Open
http://localhost:8080in your browser - Add new todos using the form
- Mark todos as complete/incomplete by clicking the toggle button
- Delete todos using the delete button
- Filter todos using the buttons (All, Incomplete, Completed)
You can test the API endpoints using:
- Web browser for GET requests
- Postman or similar API testing tools
- Browser developer tools
- Any HTTP client application
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/todos |
Get all todos |
| GET | /api/todos/{id} |
Get todo by ID |
| POST | /api/todos |
Create a new todo |
| PUT | /api/todos/{id} |
Update a todo |
| PATCH | /api/todos/{id}/toggle |
Toggle completion status |
| DELETE | /api/todos/{id} |
Delete a todo |
| GET | /api/todos/incomplete |
Get incomplete todos |
| GET | /api/todos/completed |
Get completed todos |
| GET | /api/todos/search?title={title} |
Search todos by title |
- Create a Todo: Send POST request to
/api/todoswith JSON body containing title and description - Get All Todos: Send GET request to
/api/todos - Toggle Completion: Send PATCH request to
/api/todos/{id}/toggle - Delete a Todo: Send DELETE request to
/api/todos/{id}
The todos table has the following structure:
CREATE TABLE todos (
id BIGSERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
description VARCHAR(500),
completed BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMP,
updated_at TIMESTAMP
);- Run unit tests using Maven wrapper test command
- Tests are located in
src/test/java
- Build the application using Maven wrapper clean package command
- Generated JAR file will be in
target/directory
- Stop the PostgreSQL container using Docker Compose down command
- To reset all data, stop containers and remove volumes
- Backend: Spring Boot 3.5.6
- Database: PostgreSQL 15
- ORM: Spring Data JPA / Hibernate
- Build Tool: Maven
- Containerization: Docker & Docker Compose
- Frontend: HTML, CSS, JavaScript
src/
├── main/
│ ├── java/com/springapi/spring_api/
│ │ ├── controller/
│ │ │ └── TodoController.java
│ │ ├── entity/
│ │ │ └── Todo.java
│ │ ├── repository/
│ │ │ └── TodoRepository.java
│ │ ├── service/
│ │ │ └── TodoService.java
│ │ ├── ServletInitializer.java
│ │ └── SpringApiApplication.java
│ └── resources/
│ ├── static/
│ │ └── index.html
│ └── application.properties
└── test/
└── java/com/springapi/spring_api/
└── SpringApiApplicationTests.java
- Database Connection Issues: Ensure PostgreSQL container is running via Docker Compose
- Port Already in Use: Check if port 8080 or 5432 is already in use by another application
- Docker Issues: Ensure Docker Desktop is running and you have sufficient permissions
- Application Startup: Verify Java 21 is properly installed and configured
- Browser Access: Clear browser cache if web interface doesn't load properly
- Add user authentication
- Implement todo categories/tags
- Add due dates for todos
- Create a more sophisticated frontend (React, Angular, etc.)
- Add pagination for large todo lists
- Implement todo sharing between users