MDR Sathi: A Guardrailed AI Assistant for UPI Merchant Clarity
How we combined deterministic financial rules, multilingual AI explanations, Next.js and AWS serverless architecture to build a merchant-focused decision assistant.
Building MDR Sathi: Making UPI's MDR Rules Make Sense
If you run a small shop in India and accept UPI payments, you've probably never had to think about MDR — the Merchant Discount Rate. But the rules around it aren't exactly intuitive. Does it apply to you? Which of your transactions are affected? How much would you actually be charged? Those questions get murky fast once thresholds and per-transaction conditions start interacting with each other.
We wanted merchants to get a straight answer in seconds instead of squinting at policy PDFs. That's what turned into MDR Sathi — our UPI Merchant Impact & Trust Assistant.
So what does it actually do?
You give it two things: your monthly UPI receipts, and your individual transaction amounts. It runs those against the current MDR rules and hands back a clear, no-nonsense breakdown.
The rules we built in for the prototype:
- Monthly receipts under ₹1,00,000 → you're exempt, full stop
- Any single transaction under ₹2,000 → no MDR
- Anything above ₹2,000 → 0.4%, capped at ₹300
And crucially, none of that math is done by an AI model — it's handled by a plain deterministic Python engine. So if a merchant pulls in ₹1,50,000 a month and has transactions of ₹500, ₹2,500, ₹3,000, ₹1,000, and ₹5,000, the system flags three of those as affected and lands on a total MDR of ₹42.00 — every time, the same way, no guessing involved.
The decision we're proudest of
Early on we made a call that shaped everything else: don't let the AI touch the calculation.
The rules engine does the arithmetic. The AI's only job is to talk about the arithmetic.
Concretely, the AI never sees raw numbers to crunch — it gets values in json format and turns that into plain language a merchant can actually use. We felt strongly that a model shouldn't be independently doing financial math or policy checks when a deterministic engine can do it reliably and verifiably instead. The AI consumes the output; it doesn't compute it.
How the engine actually works
The logic itself is simple, almost boringly so — which is the point:
- Are monthly receipts ≤ ₹1,00,000? If yes, exempt, done.
- If no, go transaction by transaction.
- Is this transaction ≤ ₹2,000? No MDR.
- If it's over ₹2,000, charge 0.4%, capped at ₹300.
The engine spits out everything downstream needs: overall status, the receipts figure, the exemption threshold, how many transactions were affected, the total MDR, and the per-transaction breakdown. Clean input for both the frontend and the AI layer to work with.
Getting the explanation to actually land — in three languages
A correct number means nothing if the merchant reading it doesn't fully follow what it means. So MDR Sathi speaks English, Hindi, and Kannada. We built a centralized translation system with a global language context, and the chosen language sticks around via local storage so it persists across pages instead of resetting every time.
The point wasn't to build three separate apps — it's the same verified result, just explained in whichever language the merchant is comfortable with, without duplicating any of the underlying logic.
What it's built on
- Frontend: Next.js, React, TypeScript, Tailwind CSS
- Backend/logic: Python, the deterministic MDR engine, a REST API, and the guardrailed AI explanation layer
- AI: Strands Agents SDK, working strictly off structured rules-engine output
- AWS: Amplify, SAM, Lambda, API Gateway, plus whatever else the SAM template pulled in
Frontend, backend, and the AI piece are all decoupled, so each can be built and shipped on its own timeline.
Taking it to AWS
Part of the goal here was learning how to take something built locally and actually move it toward a real cloud setup. We used AWS Amplify for the Next.js frontend — our repo is a monorepo with the frontend tucked into its own directory. For the backend, AWS SAM let us define the serverless infrastructure as code through a
template.yaml , with Lambda functions doing the heavy lifting behind an API layer. Having the infrastructure as code meant we could deploy it the same way every time instead of clicking through consoles.Making sure it actually works
We didn't just test the happy path. Two cases mattered most:
Case 1 — MDR applies: ₹1,50,000 in monthly receipts, transactions of ₹500, ₹2,500, ₹3,000, ₹1,000, ₹5,000 → 3 transactions affected, ₹42.00 total MDR (₹10 + ₹12 + ₹20).
Case 2 — Exempt: ₹90,000 in monthly receipts, transactions of ₹2,500 and ₹3,000 → completely exempt, ₹0.00, even though both individual transactions cross ₹2,000. This one mattered because it proves the monthly exemption always wins out over per-transaction thresholds — that's the kind of edge case that's easy to get wrong if you're not careful.
What we actually took away from this
Honestly, the biggest lesson wasn't a framework or an AWS service. It was rethinking how to split responsibility between deterministic code and AI.
The obvious, lazy version of an AI app looks like: input → AI → answer. We deliberately broke that pattern: Input → Verified Rules → Structured Result → AI Explanation → Human-Friendly Answer
That extra structure makes the whole thing far easier to test, debug, and actually trust. The rules engine owns the numbers. The AI owns the words. Nobody's job overlaps.
Hackathon reality check
Working under hackathon time pressure taught us to stop trying to make every piece impressive and just nail the core loop:
Enter merchant data → calculate MDR → see which transactions are affected → get it explained → switch language if needed.
That's it. That's the whole product, and it's enough.
Where we'd take this next
- Tighter automated test coverage
- More languages
- Better accessibility
- Real authentication and API hardening
- Deeper transaction analysis
- A smoother onboarding flow for merchants
- More production-grade AWS setup
- Visual ways of explaining the rules, not just text
The short version
We started with one question: can a confusing financial rule be made understandable in seconds? Our answer was to keep the math boring and reliable, and let AI do only what it's actually good at explaining, not deciding.
MDR Sathi doesn't try to be the AI that gives you the answer. It's the AI that explains an answer you can already trust.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article