All work

Case study

Peer-to-Peer Rental Marketplace

The entire backend for a marketplace where people rent items from each other: authorize-then-capture payments, an owner wallet with reviewed withdrawals, and a rental lifecycle from request to return.

ClientUS rental marketplace (iOS & Android)
EmployerFreelance
PeriodNov 2025 – Dec 2025
RoleSole backend developer
31tables in a Prisma/PostgreSQL schema
8rental states, each with its payment action
0charges for requests an owner never accepts
AES-256GCM encryption for addresses and payout details

The problem

In a peer-to-peer rental, the renter pays before the owner has agreed, and the owner gets paid only once the item comes back. Charging a card for a request the owner may never accept means refunds and disputes; paying the owner before the return means chasing money when something goes wrong. The backend has to hold money in the right place at every step, and be trusted with addresses and bank details while it does.

Architecture

A NestJS 11 API over PostgreSQL with Prisma: 31 tables covering listings, carts, rentals, condition reports, return and extension requests, wallets, chat, reviews, notifications and admin audit logs. I built the backend alone; the iOS and Android apps were built by a separate frontend developer against API guides I wrote for each module. Side effects such as push notifications, chat delivery and view tracking go through an in-process event bus, so the request path only writes the data and emits an event. It runs on AWS: EC2, RDS over verified TLS, S3 for media and SES for email, with Firebase for push and Twilio Verify for phone OTPs.

Authorize-then-capture rentals and the owner walletCheckout authorizes the renter's card through Stripe without charging it. The owner then approves or rejects the request: approval captures the payment, while rejection, cancellation or the hourly expiry job releases the hold so nothing is charged. When the rental completes, the subtotal is credited to the owner's wallet in a database transaction, and withdrawals to bank or PayPal go through admin review, with rejected withdrawals refunded to the wallet.Renter Checkoutcart → orderStripe Holdcapture_method: manualOwner Decisionapprove / rejectCapturecard chargedReleasereject · cancel · expiryRental Completereturn acceptedOwner Walletsubtotal creditedWithdrawalbank / PayPalAdmin Reviewpaid, or refunded to walletauthorizewebhookapproverejectcredit (tx)requestreview

The rental lifecycle

A rental moves through eight states (pending approval, approved, delivered, return requested, return rejected, completed, rejected, cancelled), and each transition has an owner, a notification and, where money is involved, a payment action.

  • Return requests carry a condition report (excellent to damaged) with photos; the owner accepts the return, or rejects it with a reason and the renter resubmits.
  • Extensions are their own request with their own Stripe authorization: the extra days are priced, held on the card, and captured only if the owner accepts.
  • An hourly job expires requests whose start date passed without an answer and releases their holds, so a renter's money is never left stuck on an order nobody will approve.
  • Order transitions that touch a request (return, rejection, extension) update both rows in one database transaction, so an order never moves forward without its request record.

Security work

A marketplace holds home addresses and payout details for people who are strangers to each other, so a review of what the API exposed became its own piece of work.

  • Addresses and withdrawal payment details are encrypted at rest with AES-256-GCM using a versioned format, and existing rows were backfilled by a migration script.
  • API responses were audited and stopped returning password hashes and reviewers' email addresses.
  • OTP, email and SMS sends are rate-limited, attempts are counted per code, and the fixed test OTP is parsed strictly and refused in production.
  • Stripe webhooks are signature-verified against the raw request body before any order changes state.

Decisions

Authorize at checkout, capture on approval

Payment intents use manual capture. Checkout only holds the amount; the owner's approval captures it, and rejection, cancellation or expiry release the hold: no charge, no refund to process. Only a cancellation after capture becomes a refund. A failed capture (for example an expired hold) cancels the order automatically instead of leaving it approved but unpaid.

Webhooks drive payment state, not the client

The app never tells the server that a payment worked. The owner is notified only when Stripe reports the hold through a webhook, so an abandoned or failed 3-D Secure check never reaches an owner as a real request.

A wallet with an audit trail, not a balance field

When a rental completes, the owner is credited the subtotal (the platform's service charge stays out) in the same transaction that writes a ledger entry with the balance after it. Withdrawals debit the balance immediately; an admin rejection refunds it in another transaction. Available, pending, earned and withdrawn totals can always be reconciled against the entries.

Guides as part of the API

With the app built by someone else, each module shipped with a frontend guide (orders, wallet, chat, notifications, reviews, admin), so the contract was written down rather than discovered in review.

Stack

Service
NestJS 11TypeScriptPostgreSQLPrisma
Payments
Stripe manual captureSigned webhooksOwner wallet + ledgerBank / PayPal withdrawals
Auth
JWT + refresh sessionsGoogle / Apple sign-inTwilio Verify OTPCASLRate limiting
Messaging
ChatFirebase pushAWS SESEvent-driven notifications
Data
Distance-sorted searchField-level encryptionAudit logsScheduled jobs
Cloud
AWS EC2RDSS3SES