MercadoLibre technical challenge — Coupon spending optimizer using MeLi public API.
Given a list of MercadoLibre item_ids and a coupon amount, determine which items the user should buy to spend as much of the coupon as possible without exceeding it.
- Receives item IDs and coupon amount via
POST /coupon - Fetches real item prices from the MercadoLibre public API
- Caches prices in MySQL to avoid redundant API calls
- Calculates which items fit within the coupon budget
- Tracks item popularity — returns top 5 most redeemed items via
GET /stats/top
- Java 11 + Spring Boot 2.7.5
- Spring Data JPA + Hibernate — MySQL 8.0
- Lombok — boilerplate reduction
- Maven — build tool
- Deployed on AWS EC2 (Ubuntu 20.04)
Calculates which items to buy with the coupon.
curl -X POST http://localhost:8100/coupon \
-H "Content-Type: application/json" \
-d '{"item_ids": ["MLA1", "MLA2", "MLA3"], "amount": 500.0}'Response:
{
"item_ids": ["MLA1", "MLA3"],
"total": 490.0
}Returns the 5 most redeemed items across all coupon requests.
curl http://localhost:8100/controller/ — HTTP endpoints (CouponController)
service/ — Business logic (ICouponService + ICouponServiceImp)
repository/ — Data access (CouponRepository)
entities/ — JPA entities (Coupon, ItemMeli, CouponResponse)
- Java 11+
- MySQL 8.0
- Maven
git clone https://github.com/RikardoBonilla/meli-coupon-api.git
cd meli-coupon-api
# Configure MySQL credentials in src/main/resources/application.properties
./mvnw spring-boot:runThe API starts on port 8100.
java -jar out/artifacts/challengemeli_jar/challengemeli.jar- Item prices are fetched once and cached in MySQL — subsequent requests for the same item use the cached price
- The solution integrates with the live MercadoLibre Items API:
GET https://api.mercadolibre.com/items/{id}
Built by Ricardo Andres Bonilla Prada as part of a MercadoLibre technical hiring process.