Commodity Murabaha, Explained for Engineers
Before the story of scaling from ten orders to five thousand, here is what we actually run: what a commodity Murabaha is, why every step is legally load-bearing, and why stock has to exist as individually coded units.
- commodity murabaha
- murabaha process
- islamic finance
- sharia compliant financing
- murabaha platform
- islamic banking technology
- tawarruq
- SPV
- time deposit
- special purpose entity
- fintech saudi arabia
- system design
What LYNK is, and what we do
LYNK is a Saudi fintech platform that provides the infrastructure for commodity Murabaha financing. When a bank or finance company wants to extend Sharia-compliant financing to a customer โ a personal loan, an SME facility, a credit card settlement โ the funds cannot simply be lent at interest. Instead, the financing must be structured as a real trade: the institution buys a genuine commodity, sells it to the customer at cost plus an agreed profit (the Murabaha), and the customer sells it on for liquidity. LYNK is the marketplace and execution engine that makes that entire trade real, digital, and fast.
In practice, we operate three things:
- A commodity marketplace. LYNK runs a local commodity market where approved suppliers list real inventory โ steel, gasoline, and other qualifying goods โ tracked down to the individual unit, with live availability and pricing. For institutions that prefer international commodities, LYNK also integrates directly with Bursa Malaysia's Suq Al-Sila' (BSAS) commodity trading platform.
- An execution engine. Financial institutions create Murabaha orders through the LYNK portal or entirely through our API from their own loan-origination systems. Orders can run in manual mode, where an officer confirms each step, or in AUTO mode, where the whole cycle โ purchase, ownership transfer, sale, completion โ executes without human intervention.
- The record of the trade. Every step produces its legal evidence: purchase confirmations, wakala (agency) agreements, ownership certificates, and sell confirmations, plus wallets, settlement, and SADAD invoicing around the money side.
One machine, many financial products
The same Murabaha machinery serves very different financial products. What changes between them is who the parties are and what the financing is for โ never the legal sequence of the trade itself:
| Product | Lender | Borrower | What it serves |
|---|---|---|---|
| Normal lending | The financial institution | The institution's customer | Classic Murabaha: personal finance, SME facilities, credit-card settlement |
| SPV (Special Purpose Vehicle) | An SPV โ a separate legal entity the institution creates to isolate financial risk | The financial institution itself | Structured finance: large or specialized Murabaha deals, ring-fenced from the institution |
| Time deposit | A client placing funds with the institution for a fixed term | The financial institution itself | A Murabaha-based investment: the deposit earns profit through Murabaha โ the Sharia-compliant alternative to an interest-bearing term deposit |
| SPE (Special Purpose Entity) | An external third party | An external customer | Murabaha execution as a service: the institution manages the entire transaction between two independent parties without being either party to the contract |
Note what the table implies for the machinery. In normal lending the institution is the lender; in SPV and time-deposit orders the same Murabaha flow runs in reverse โ the institution becomes the borrower, commodity ownership starts under the external lender's name, and every certificate is issued accordingly. SPE then combines both: an external lender and an external customer, with the institution purely as transaction manager. Yet all four products run through the same pipeline, the same coded commodity units, and the same ownership ledger โ the ownership flow simply supports the institution being lender, borrower, or neither. One performance investment serves every product at once.
The products are also part of the scaling story. Before SPV and time deposit became first-class products, each such deal was executed through a workaround: manually registering a new company to represent the SPV or deposit client, order by order. That workaround at volume pushed the platform past 32,000 registered entities โ exactly the kind of scale event the rest of this series is about โ and turning these flows into proper financial products with a reversed ownership flow removed it.
Our clients are the financial institutions; their customers are the borrowers and depositors; the suppliers and traders provide the commodity side of the market; and LYNK administrators oversee the whole exchange. The platform's job is to let an institution turn "approve this financing" into a completed, fully documented, Sharia-valid trade โ in seconds.
The Murabaha process โ and why every step must happen
A commodity Murabaha on LYNK is a sequence of real transactions, each with a distinct legal meaning. Nothing in this sequence is ceremonial; each step transfers actual ownership of actual commodity units, and each must complete before the next may begin.
- Order created & approved The institution submits the financing order โ amount, customer, market, commodity preferences. Depending on its roles setup, a supervisor approves it. A trade request is born.
- Purchasing Commodity The platform finds eligible commodity units on the market that cover the financing amount, places them on hold, and executes the purchase. The institution now genuinely owns specific, identified units of a real commodity. Sharia requires this ownership to be real โ you cannot sell what you do not own.
- Borrower Ownership The institution sells the commodity to the customer at cost plus the agreed profit, payable in instalments โ this sale is the Murabaha. Ownership of the units transfers to the customer, evidenced by certificate.
- Sale to market The customer โ typically through a wakala appointing the institution or platform as agent โ sells the commodity back to the open market for cash. This provides the liquidity the customer needed. The commodity must move to a genuinely different buyer, which is why trade-rotation rules and, in newer flows, a Specialized Entity govern who may buy it.
- Murabaha Completed & settlement Funds flow to the customer, certificates are finalized, the order completes, and the commodity units settle back into the market's books, ready to serve a future order.
Stock is code โ and every code must be traceable to its owner
The deepest consequence of the legal structure sits in how stock exists at all. On LYNK, a supplier's registered stock is not a quantity in a column โ it is minted into individual units, each represented by its own unique code. Sharia requires the sale of identified, specified goods, not an abstract balance: when an institution buys "500 units of steel," it must be knowable which 500 units, and when the customer takes ownership, those exact coded units must now belong to that customer.
So every unit lives as its own record carrying its code, its status (free or reserved), which order is holding it, who owns it now, and who owned it before. And every time ownership changes hands, the database itself โ via a trigger, so no code path can forget โ appends a row to an append-only ownership ledger. Pick any unit code, at any time, and the platform can replay its full legal history: supplier โ institution โ customer โ market, order by order.
This design is what makes the platform legally sound โ and it is also one of our hardest engineering challenges. A single financing order holds hundreds or thousands of units; five thousand concurrent orders means millions of unit rows being held, transferred, and settled at once, where two orders must never hold the same unit โ not even for a millisecond โ and where losing a single ledger entry would break a chain of ownership that has to stand up to audit. Much of the scaling story in Part 2 โ the lock contention, the index engineering, the race-condition hunts โ is really the story of keeping this per-unit, per-user tracking intact under industrial load.
The goals: what "a better platform" means for LYNK
Institutions do not create Murabaha orders one at a time. A consumer-finance company disburses hundreds of loans in a morning; a bank settles credit-card Murabaha in bursts; campaign days multiply everything. Our definition of a better platform therefore comes down to two primary goals, in tension with each other:
Goal 1 โ Maximize the number of transactions we can handle at one time
Every concurrent order competes for the same commodity inventory, the same database rows, and the same workers. Capacity is not one number but a system of targets we test against continuously:
| Target | Measure | Where we've proven it |
|---|---|---|
| Concurrent volume | 5,000+ orders per run | Routine daily pre-production stress tests; 5,200 end-to-end |
| Per-order speed | sub-second steps | Purchase averages 0.26s, P99 within 1s โ see Section 04 |
| Reliability | โฅ 99.9% completion | 99.92โ100% across 2,500โ5,200-order campaigns |
| API responsiveness | ~1.2s create-order | Measured while 5,000 orders flowed through the pipeline |
| Autonomy | zero-touch runs | Full AUTO cycle incl. Auto Complete Sell, unattended |
Goal 2 โ Every transaction must be Islamically legal
The second goal bounds the first. Whatever the load, each of those thousands of orders must individually satisfy the full legal sequence: real units found, genuinely held, actually purchased, ownership truly transferred, sold onward to a legitimately distinct buyer, and every link evidenced by certificate. This has concrete engineering consequences:
- Strict per-order sequencing. Each order's pipeline is a state machine whose steps cannot be skipped or reordered โ parallelism must come from running many orders side by side, never from cutting corners inside one.
- Real inventory, really held. Units are locked and tracked individually; two orders may never "own" the same unit, even for a millisecond, which is why hold/lock logic and race-condition work dominate our database engineering.
- Evidence as a deliverable. Certificates and ownership records are legal artifacts. We may move their generation off the critical path (produce the PDF at download time), but never remove them.
- Rules even in the fast path. Trade-rotation limits and the Specialized Entity flow exist so the onward sale is genuinely valid. When we tested relaxing rotation from 2 to 1, the change was justified to the business on Sharia-structure grounds โ and only adopted after tests proved performance was unaffected either way.
How we test our performance
Claims like "seconds per step" mean nothing without a way to prove them โ so performance testing is a standing routine, not an occasional event. Thousands of orders are created through the API in controlled pre-production runs (today's standard is 5,000 orders per run, daily), every order records how long each Murabaha step took, and each run is distilled into the same set of statistics per step. Every change to the platform is judged against that history: if the numbers move the wrong way, the change is caught within days.
How to read the numbers
The fairest way to describe thousands of order timings is to imagine lining every order up, fastest to slowest, and reading values off that line:
- Min / Max โ the single fastest and single slowest order in the run. Max shows the worst thing that happened to anyone.
- Avg (average) โ total time divided by number of orders. Useful, but it hides outliers: a thousand fast orders can bury ten terrible ones.
- P25, P50, P75, P90, P95, P99 (percentiles) โ "P" followed by a number reads as: that percentage of orders finished within this time. P25 = the fastest quarter of orders; P50 is the median โ the typical order, half faster and half slower; P99 means 99 of every 100 orders were at least this fast โ only 1 in 100 was slower. P90/P95/P99 describe the unluckiest customers' experience, which is exactly what averages hide โ so those are the numbers we hold ourselves to.
Here is what those statistics look like from a real run today, for the three fully automated steps (values in whole seconds โ a "0" means the step completed in under a second):
None of this came easy
Everything described above โ five legal steps in seconds, millions of tracked units, four products on one pipeline โ is where the platform ended up. It is not where it started. In January 2025, a test of just ten automated orders left four of them stuck. Between that day and today's routine 5,000-order runs stand fifteen hard-won battles โ the first ten fought in the code and the database, the last five in the infrastructure underneath it:
Part 3 ยท Scaling Queue Workers: From 3 Containers to 122 Processes โ the infrastructure half: how three worker containers became 122 processes across 22 queues, why every one of those numbers changed, what it cost when they changed by accident, and how three machines later became two.