This is the backend API for MonsterShop, an e-commerce application where users can explore products, read reviews, and rate items. It is built using Java 21, Spring Boot, and MySQL, with a clean, layered architecture and RESTful design.
- 🛒 View, create, update, and delete products
- 📝 Add and view product reviews
- ⭐ Support for product ratings
- ✅ Request validation using Jakarta Bean Validation
⚠️ Centralized error handling via@RestControllerAdvice
- 🗃️ MySQL database integration
- 🔄 RESTful and modular service-layer design
- Java 21
- Spring Boot 3.x
- Spring Web (REST)
- Spring Data JPA
- MySQL
- Jakarta Bean Validation
- Maven
- Postman (for testing)
- Git & GitHub
- Trello (for task tracking)
The project follows a clean 3-layer MVC architecture:
src/
├── main/
│ ├── java/
│ │ └── com/femcoders/monstershop/
│ │ ├── controllers/
│ │ ├── dtos/
│ │ │ └── product/
│ │ │ └── review/
│ │ ├── exceptions/
│ │ ├── models/
│ │ ├── repositories/
│ │ └── services/
│ └── resources/
│ └── application.properties
- Java 21
- Maven
- MySQL running locally
- IDE (e.g., IntelliJ, VS Code)
In src/main/resources/application.properties
:
spring.datasource.url=jdbc:mysql://localhost:3306/monstershop
spring.datasource.username=your_username
spring.datasource.password=your_password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
- Clone the repository:
git clone https://github.com/Lizar22/monstershop-api.git
cd monstershop-api
- Build the project:
mvn clean install
- Run the application:
mvn spring-boot:run
Base URL: http://localhost:8080/api/
Method | Endpoint | Description |
---|---|---|
GET | /api/products |
Returns all products registered in the system. |
GET | /api/products/{id} |
Returns the details of a specific product by its id . |
POST | /api/products |
Creates a new product using the data provided in the request. |
PUT | /api/products/{id} |
Updates an existing product identified by its id . |
DELETE | /api/products/{id} |
Deletes an existing product identified by its id . |
Method | Endpoint | Description |
---|---|---|
GET | /api/reviews/{productId} |
Returns all reviews associated with a given product. |
POST | /api/reviews |
Submits a new review for a product. |
All errors are handled globally using a @RestControllerAdvice
class (GlobalExceptionHandler
), which returns a structured response when exceptions are thrown.
Example of error response:
{
"message": "Product not found with id 99",
"status": 404,
"errorCode": "NOT_FOUND",
"timestamp": "2025-06-18T12:34:56",
"path": "/api/products/99"
}
Handled exceptions include:
NoSuchElementException
IllegalArgumentException
- Validation errors from DTOs
The response format is defined in the ErrorResponse
class.
This project is part of the FemCoders educational program.
Developed with 💜 by Lizar22 GitHub Repo: monstershop-api