Spring Boot + MySQL REST API for Customer Feedback Collection
This project is a fully functional backend application built with Java 21 and Spring Boot 3.5.x, designed to collect, store, and manage customer feedback for a shopping platform. It includes RESTful API endpoints, form validation, database persistence via JPA, and an optional HTML form for quick feedback submission.
β REST API for feedback submission & retrieval β MySQL persistence via Spring Data JPA β Request validation using Jakarta Validation β Docker Compose setup for MySQL β Optional Thymeleaf form for direct user input β Maven-based build for easy setup and deployment
| Component | Technology |
|---|---|
| Language | Java 21 |
| Framework | Spring Boot 3.5.x |
| Database | MySQL 8 |
| ORM | Spring Data JPA (Hibernate) |
| Validation | Jakarta Validation |
| Build Tool | Maven |
| Containerization | Docker & Docker Compose |
| Optional UI | Thymeleaf Template Engine |
shopping-feedback/ β βββ src/ β βββ main/java/com/example/shoppingfeedback/ β β βββ controller/ # REST API endpoints β β βββ dto/ # Request DTOs & validation β β βββ model/ # JPA entity definitions β β βββ repository/ # Data access layer β β βββ service/ # Business logic layer β β βββ ShoppingFeedbackApplication.java β βββ resources/ β βββ application.properties β βββ templates/ # Optional Thymeleaf HTML form β βββ pom.xml βββ docker-compose.yml Edit the database credentials in src/main/resources/application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/shopping_feedback?useSSL=false&serverTimezone=UTC spring.datasource.username=root spring.datasource.password=changeme spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=trueRun MySQL locally using Docker Compose:
docker compose up -dMySQL will start with:
- Database:
shopping_feedback - User:
appuser - Password:
apppassword
Then update your application.properties:
spring.datasource.username=appuser spring.datasource.password=apppasswordBase URL: http://localhost:8080/api/feedback
curl -X POST http://localhost:8080/api/feedback \ -H "Content-Type: application/json" \ -d '{ "name": "Jane Doe", "contact": "+2348012345678", "rating": 4, "itemsNotFound": "Olive oil, Wheat flour", "priceToReduce": "Tomatoes are expensive", "improvementSuggestion": "Open more checkout counters" }'curl http://localhost:8080/api/feedbackcurl http://localhost:8080/api/feedback/11οΈβ£ Start MySQL (either locally or via Docker). 2οΈβ£ Update your credentials in application.properties. 3οΈβ£ Build and run the app:
mvn clean package java -jar target/shopping-feedback-0.0.1-SNAPSHOT.jarOr run directly from your IDE:
ShoppingFeedbackApplication.java Access the API at:
http://localhost:8080/api/feedback If you enabled Thymeleaf, open: src/main/resources/templates/feedback-form.html
You can serve this from a simple controller to collect feedback via a browser form.
- Add authentication for feedback admins
- Integrate Swagger/OpenAPI documentation
- Add email notifications for new feedback
- Introduce pagination and filtering
- Deploy with Docker + Spring Boot container
This project is licensed under the MIT License β feel free to use and modify for your learning or production needs.
Designed as a learning-friendly yet production-ready Spring Boot starter demonstrating:
βHow to build a REST API with MySQL integration and validation β from code to container.β