Skip to content

RikardoBonilla/meli-coupon-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meli-coupon-api

MercadoLibre technical challenge — Coupon spending optimizer using MeLi public API.

Java Spring Boot MySQL License

The Problem

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.

How it works

  1. Receives item IDs and coupon amount via POST /coupon
  2. Fetches real item prices from the MercadoLibre public API
  3. Caches prices in MySQL to avoid redundant API calls
  4. Calculates which items fit within the coupon budget
  5. Tracks item popularity — returns top 5 most redeemed items via GET /stats/top

Stack

  • 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)

API Endpoints

POST /coupon

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
}

GET /

Returns the 5 most redeemed items across all coupon requests.

curl http://localhost:8100/

Architecture

controller/   — HTTP endpoints (CouponController)
service/      — Business logic (ICouponService + ICouponServiceImp)
repository/   — Data access (CouponRepository)
entities/     — JPA entities (Coupon, ItemMeli, CouponResponse)

Quick Start

Requirements

  • Java 11+
  • MySQL 8.0
  • Maven

Run locally

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:run

The API starts on port 8100.

Or run the JAR directly

java -jar out/artifacts/challengemeli_jar/challengemeli.jar

Notes

  • 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.

About

MercadoLibre challenge — REST API that optimizes coupon spending across items using MeLi's public API. Spring Boot 3, Java 11, MySQL cache, AWS EC2 deployed.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages