Scaling to ₹200 Crore+

Engineering Lessons from Building MarketPe

By Satvik Reddy, CTO

When we started MarketPe, our mission was clear: make payments seamless for India's transport industry. India already has world class payment platform for consumers - UPI. It is fast, simple and has even gained international recognition.

At Marketpe, we wanted to build a world class payment platform for transporters. Today, having processed over ₹200 crore in payouts, we want to share the technical problems we solved to build a reliable system.

The Challenge: There is no second chance

Building a payment platform meant we had zero margin for error. A duplicate payment could cost a company lakhs. A race condition could cause reconciliation nightmares. An untracked action could make audits impossible. Every technical decision had to be bulletproof.

Here's what we did to ensure reliability at scale.

1. Idempotency Keys

"I submitted form once but two got created"

Network glitches happen. Sometimes a user clicks "Pay" once, but their browser sends two requests. Other times, a mobile connection drops mid-request, prompting a retry.

We implemented idempotency keys across all critical endpoints. The concept is simple: every form gets a unique identifier when it is opened. On submit, if the request goes twice or even 10 times, server has a way to detect that it is actually the same operation.

2. Row Locking: Winning the Race Condition Battle

Imagine two people trying to process 2 payments from the same company simultaneously. Without proper locking, both transactions might read the same balance, both might succeed, and the balance might go negative. In financial systems, this is unacceptable.

We use database row-level locking to ensure atomic operations. During critical operations, we lock the relevant rows at the earliest point. This ensures that any other request trying to modify the same rows is forced to wait till previous operation is committed to the database.

3. Audit History: Every Action Leaves a Trace

Transport companies need to know who did what, when. Tax audits demand it. Internal investigations require it. And when something goes wrong, you need a complete trail.

We implemented a comprehensive audit logging system that tracks every single change across all our models. Every create, update, and delete operation gets logged with:

This gives us complete transaction history for compliance, the ability to replay and debug issues, clear accountability for every action, and data for anomaly detection. We've used audit logs to resolve disputes, debug issues, and satisfy auditor requirements.

4. Exhaustive Error Handling

Unhandled errors can leave transactions in inconsistent states. Try-catch blocks are easy to forget. We needed a way to force ourselves to handle every possible error path.

We adopted the principles of neverthrow. Instead of throwing errors, every function returns either a success or an error result. The type system forces you to explicitly handle all cases.

The beauty of this pattern is that it makes our flows predictable and reliable. No silent failures. No forgotten edge cases. Just explicit handling of every possibility.

Building for India's Transport Industry

What makes us proud isn't just the technical infrastructure - it's what it enables. Transport companies that were doing UPI payments by transferring funds to employees, facing daily limits and tax notices, now have a proper solution. They can verify documents from government sources, set up custom rules, segregate branches, integrate with their accounting software and more.


Building payment infrastructure for India's transport industry. Connect with us at usemarketpe.com