PromoQuoter is a Spring Boot application designed to manage promotions, carts, and orders. It provides RESTful APIs for handling various operations related to promotions and cart management.
-
Cart Management:
- Add items to the cart.
- Apply promotions to the cart.
- Confirm orders.
-
Promotion Management:
- Create and manage different types of promotions.
- Apply promotions to cart items.
-
Order Management:
- Create and manage orders with idempotency support.
- CartController: Handles HTTP requests related to cart operations.
- PromotionController: Manages promotion-related HTTP requests.
- OrderService: Provides services for order creation and management.
- cart: Contains classes related to cart operations, including
CartController,CartService, andCartServiceImpl. - promotion: Manages promotion logic with classes like
PromotionService,PromotionServiceImpl, and various promotion types. - order: Handles order-related operations with
OrderServiceandOrderServiceImpl. - common: Includes shared utilities and configurations.
- cart: Contains unit tests for cart-related classes, such as
CartControllerUnitTestandCartServiceUnitTest. - promotion: Includes tests for promotion logic, like
PromotionServiceUnitTest. - order: Tests for order management.
-
Plugins:
- Java
- Spring Boot
- Dependency Management
- JaCoCo for test coverage
-
Dependencies:
- Spring Boot Starters for Web, Data JPA, and Validation.
- H2 Database for runtime.
- Lombok for reducing boilerplate code.
- JUnit and Mockito for testing.
- Lombok is used to reduce boilerplate code with annotations like
@Data,@Builder,@NoArgsConstructor, etc. - Ensure Lombok is correctly set up in your IDE for optimal development experience.
To run tests separately, use the following Gradle commands:
./gradlew test --tests "com.kifiya.PromoQuoter.cart.CartControllerUnitTest"
./gradlew test --tests "com.kifiya.PromoQuoter.cart.CartServiceUnitTest"
./gradlew test --tests "com.kifiya.PromoQuoter.promotion.PromotionServiceUnitTest"- URL:
/cart/quote - Method:
POST - Request Body:
{ "items": [ { "productId": "123e4567-e89b-12d3-a456-426614174000", "quantity": 2 } ] }
- URL:
/cart/confirm - Method:
POST - Headers:
Idempotency-Key:123e4567-e89b-12d3-a456-426614174000
- Request Body:
{ "items": [ { "productId": "123e4567-e89b-12d3-a456-426614174000", "quantity": 2 } ] }
- URL:
/promotions - Method:
GET
- URL:
/promotions - Method:
POST
- Request Body:
{ "name": "Summer Sale", "discountPercentage": 15, "promotionType": "PERCENT_OFF_CATEGORY", "category": "ELECTRONICS" }
- Request Body:
{ "name": "Buy 2 Get 1 Free", "promotionType": "BUY_X_GET_Y", "productId": "123e4567-e89b-12d3-a456-426614174000", "buyQuantity": 2, "getQuantityFree": 1 }
-
Clone the repository:
git clone <repository-url>
-
Build the project:
./gradlew build
-
Run the application:
./gradlew bootRun
-
Access the application:
- The application runs on
http://localhost:8080.
- The application runs on
To build the project, use the following command:
./gradlew buildTo run the application, use the following command:
./gradlew bootRunTo run tests separately, use the following Gradle commands:
./gradlew test --tests "com.kifiya.PromoQuoter.cart.CartControllerUnitTest"
./gradlew test --tests "com.kifiya.PromoQuoter.cart.CartServiceUnitTest"
./gradlew test --tests "com.kifiya.PromoQuoter.promotion.PromotionServiceUnitTest"Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License.