← All work03 / 03
ProtectPay
A platform for private car sales in Israel: a seller lists a vehicle, buyers send structured offers, and the chosen pair close the deal together in a shared realtime Trade Room.
- Type
- Car sale trust platform
- Role
- Development: architecture, API, data model, realtime delivery and the web client.
- Status
- In development · phases 0–15 built
- Stack
- NestJS · Fastify · Prisma · PostgreSQL · Socket.IO · React · Zod
Problem
Selling a used car between strangers runs on phone calls, screenshots and trust. Offers arrive in different shapes, vehicle facts are hard to check, and once two people agree there is no shared record of what they agreed to. ProtectPay gives the process a structure without claiming more than it can verify.
Architecture
A pnpm monorepo: a NestJS API on Fastify, a React web client, and a shared contracts package holding the Zod schemas, types and state machines both sides use. PostgreSQL through Prisma is the single source of truth. Every state change writes its domain event and an outbox row in the same transaction; a relay polls the outbox with retries and back-off and delivers to the Trade Room over Socket.IO and to in-app and push notifications, only after the commit. Vehicle facts come from the Israeli government open-data registry and are kept as snapshots that offers reference. Participants verify a phone number with a one-time code instead of creating an account.
16 of 17 phases complete · select a phase
Phase 15 · Complete
Pilot measurement
Product events, the pilot dashboard, decision data.
Key decisions
- 01
Commit first, notify after
State, domain event and outbox row are written in one transaction. Realtime notices and notifications leave only from the outbox, so nobody is told about a change that did not commit.
- 02
Offers are immutable
A database trigger refuses to rewrite an offer's commercial content. A counteroffer is a new row with lineage, and a material change in the vehicle facts makes the buyer acknowledge it before a deal can exist.
- 03
One selection at a time
A unique index allows a single selection lock per sale, and selecting an offer does not create a trade yet: the buyer reconfirms the exact offer first.
- 04
Facts, not scores
A trust signal states what was observed ("phone ending 4821 verified"), never a rating of a person. The platform makes no identity or ownership claim, and a lint rule rejects the word "escrow" until a regulated layer exists.
Stack
- Interface
- React · Vite · React Router · TanStack Query · react-hook-form
- Services
- NestJS · Fastify · Socket.IO
- Contracts
- TypeScript · Zod · Shared state machines
- Async
- Transactional outbox · Relay with retries and back-off
- Data
- PostgreSQL 17 · Prisma · data.gov.il vehicle registry
- Quality
- Vitest · ESLint · Acceptance walks on a real database · GitHub Actions CI
Tradeoffs
- Polling the outbox adds up to a second of latency and a table to sweep, in exchange for notices that can never describe an uncommitted change. Under load one batch per tick was too slow, so a full batch now keeps claiming more.
- Verifying a phone instead of an identity keeps joining down to a one-time code, at the cost of a weaker identity signal; the product states exactly what was verified and claims nothing more.
Outcome
Phases 0–15 of the roadmap are built: vehicle lookup, offers and negotiation, the Trade Room, inspection, agreements and closing, dealer tools, attribution and pilot measurement. Phases are checked by scripted acceptance walks against a running API and a real PostgreSQL database.