A simple Todo application built using Spring Boot (for backend), MySQL (for database), and React with Vite (for frontend).
- Technologies Used
- Features
- Prerequisites
- Setting Up Backend (Spring Boot)
- Setting Up Frontend (React + Vite)
- Running the Application
- Java 17
- Spring Boot
- MySQL
- Maven
- React 18
- Vite
- Axios
- TailwindCSS
- Add new tasks
- Mark tasks as completed
- Delete tasks
- Undo and redo operations
Before running the project, make sure you have the following installed on your machine:
- Java 17 or above
- Maven
- MySQL
- Node.js (with npm)
git clone https://github.com/yourusername/todoapp.git
cd todoappCreate a MySQL database named todo. You can use the following SQL command:
CREATE DATABASE todo;Update the src/main/resources/application.properties file with your MySQL credentials:
spring.datasource.url=jdbc:mysql://localhost:3306/todo?useSSL=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=1234
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=trueMake sure you are in the root directory of the backend (todoapp).
mvn clean install
mvn spring-boot:runThe backend will be running on http://localhost:8080.
cd frontendInstall the dependencies using npm:
npm installStart the development server:
npm run devThe React app will be running on http://localhost:5173.
- Backend API:
http://localhost:8080/tasks - Frontend:
http://localhost:5173
The backend exposes the following REST API endpoints:
GET /tasks: Fetch all tasksPOST /tasks/add: Add a new taskPOST /tasks/complete/{id}: Mark a task as completedPOST /tasks/delete/{id}: Delete a taskPOST /tasks/undo: Undo the last operationPOST /tasks/redo: Redo the last operation
CORS is enabled for the frontend to communicate with the backend. It allows requests from http://localhost:5173.
For production deployment, you can:
- Package the Spring Boot backend as a JAR and deploy it to a server (e.g., Azure App Service).
- Build the React frontend using
npm run buildand serve the static files using Azure Storage or any static site hosting service.
### Key Points:
- The backend is a Spring Boot application running on port `8080`.
- The frontend is a React app (Vite) running on port `5173`.
- The MySQL database should be set up before running the backend.
- CORS has been configured to allow communication between the frontend and backend.