This is the base implementation for the Opptra FDE Intern assignment. Fork this repo, complete the tasks in the assignment brief, and submit your GitHub link + Loom.
npm install
npm run devnpm run buildDeploy the dist/ folder to Vercel, Netlify, or any static host.
The live deployment URL must be in your README before submission.
- Upload
sample-data/rules.csvas the discount rules input - Upload
sample-data/cart.csvas the cart input - Click Calculate Discounts
src/
engine/
discountEngine.js ← pure discount logic (no UI)
csvParser.js ← CSV → typed objects
components/
CsvUploader.jsx ← file upload area
DataTable.jsx ← reusable table
ErrorBanner.jsx ← parse error display
App.jsx ← main UI + state
main.jsx ← entry point
sample-data/
rules.csv ← sample discount rules
cart.csv ← sample cart items
rules.csv
| Column | Type | Example |
|---|---|---|
| rule_id | string | RULE-01 |
| scope | brand | platform | platform |
| applies_to | string | Amazon India |
| type | percentage | flat | percentage |
| value | number | 15 |
| stackable | true | false | false |
cart.csv
| Column | Type | Example |
|---|---|---|
| item_id | string | ITEM-01 |
| product | string | Cushion Cover |
| brand | string | Natura Casa |
| platform | string | Amazon India |
| base_price | number | 1299 |
- When multiple non-stackable rules match an item, the one giving the largest saving in rupees is applied.
- Rules marked
stackable: trueapply on top of the winning non-stackable rule. - If no rules match, the base price is returned with a "No offers available" note.
| Item | Base Price | Final Price | Reasoning |
|---|---|---|---|
| ITEM-01 | Rs.1,299 | Rs.1,104 | Platform offer: 15% off (beats Rs.150) |
| ITEM-02 | Rs.849 | Rs.629 | Brand offer: Rs.150 off + Platform 10% |
| ITEM-03 | Rs.599 | Rs.509 | Platform offer: 15% off |
| ITEM-04 | Rs.2,499 | Rs.2,499 | No offers available |
| ITEM-05 | Rs.449 | Rs.382 | Platform offer: 15% off |
| ITEM-06 | Rs.899 | Rs.809 | Platform offer: 10% off |