What it is
Ajrni is a peer-to-peer rental marketplace in Saudi Arabia. The same account can rent something or list its own things for rent, and the app just switches modes. It covers listings, bookings, payments and payouts, identity checks, chat, reviews and an admin back office, in Arabic and English.
I rewrote the backend from the ground up in Laravel, replacing the one the platform launched with, and moved the live platform over to it. I also built ajrni.sa, the website, in Astro on Cloudflare, and helped on the Flutter app, though I'm not a Flutter developer.
The problem
Renting is harder than selling. The same thing can't go out twice on the same night, money has to be held until the rental starts, a deposit has to come back unless something got damaged, and either side can cancel at the worst possible moment. Every one of those rules touches money, so every one of them has to be right.
What I built
- Listings with fields per category; hourly, daily and nightly rates; weekend and holiday prices; discounts; blocked dates; and map search sorted by distance
- Bookings where the renter pays first and the owner accepts before a deadline, then delivery, return, extensions and cancellation windows
- Payments by card and Apple Pay through MyFatoorah, by wallet, or a mix of both, with refunds, invoices and credit notes
- Escrow, deposits, commission and VAT on a double-entry ledger, and payouts to owners' Saudi bank accounts, with every IBAN checked before money moves
- Phone verification, national ID checks through Nafath, realtime chat, reviews from both sides and damage reports
- An admin back office in Vue and Inertia, and close to 4,000 tests
- On the app: the card and Apple Pay checkout, video uploads straight to storage, deep links, and a cleanup that took the analyzer from 99 warnings to none
The interesting parts
Booking without overlaps
Every booking checks three things, cheapest first: the owner's blocked dates, active orders that overlap, and pending extensions that reach into the same range. Back-to-back rentals are allowed, and the same logic draws the availability calendar, so the dates you can pick are the dates you can book. Booking dates are local Saudi time, stored as UTC, and holiday prices follow the Hijri calendar, so Islamic holidays move every year the way they should.
Money that adds up
Money never touches a float. When a payment is confirmed it's split into commission, VAT, escrow and deposit as journal entries that must net to zero, each with an idempotency key, and a nightly reconcile fails loudly if any account drifts. The owner's share is released when the rental starts. A refund takes a different route depending on who cancelled: the renter, the owner, or the clock.
Trusting the payment gateway, but checking
The app and the gateway's webhook go through one idempotent verifier, and calls to the gateway stay outside database locks. If the amount the gateway captured isn't the amount the server asked for, the payment fails and is refunded automatically.
Deals stay on the platform
Chat hides phone numbers, including ones written in Arabic-Indic digits or spelled out in English or Arabic, and accounts that share an ID, a bank account or a device get flagged for a person to look at, never blocked by a guess.
Every integration rehearsed
Each outside service, from payments to ID checks to SMS, has a command that rehearses it against its sandbox, and every outbound call and incoming webhook is logged. When someone else's API misbehaves, the answer is in a log, not a guess.
Result
Ajrni runs on the new backend now, with its data carried over by importers that merged duplicate accounts and posted opening balances as journals. Old app versions get a force-update screen from a Cloudflare Worker I wrote, and the old server has been retired.