BACK TO PORTFOLIOCASE STUDY 01 / 03
ESCROW & TRANSACTION SAFETY•NEXT.JS APP ROUTER•NEON POSTGRESQL

TRUSTLANCE

A full-stack freelance marketplace featuring integrated application-level escrow protection, transaction-safe milestone releases, and an administrative dispute board.

THE ENGINEERING PROBLEM

Vulnerability in Milestone Approvals & Payment Disputes

Traditional freelance boards suffer from asymmetrical financial risk: freelancers risk delivering unpaid work when clients withhold payments, while clients risk paying for substandard or missing deliverables without mediation. Ad-hoc payment integrations frequently leave contracts in inconsistent states during network failures or unilateral cancellations.

THE ARCHITECTURAL SOLUTION

Explicit Escrow State Machine & Immutable Audit Trails

Engineered a deterministic escrow state machine. Funds deposited by clients are locked into milestone contracts within Neon PostgreSQL via Prisma transactions. Disbursements occur only when explicit cryptographic approval criteria are satisfied, backed by an administrative dispute adjudication board and permanent audit logs.

01 / TRANSACTION WORKFLOW

Escrow Lifecycle & State Machine

Every contract transitions through strictly guarded phases, preventing invalid withdrawals or bypassed reviews:

PHASE 01

CREATED

Client and Freelancer agree on terms. Milestone value is defined.

PHASE 02

FUNDED

Milestone funds committed by client. Balance locked via Neon PostgreSQL transaction.

PHASE 03

IN_PROGRESS

Freelancer executes deliverables with structured milestone proof and status logging.

PHASE 04

SUBMITTED

Client reviews deliverables for formal verification.

TERMINAL SETTLEMENT BRANCHES:
APPROVED → RELEASEDHAPPY PATH

Client formally signs off. Funds are instantly unlocked and credited to the freelancer account with mutual review generation.

DISPUTED → ADJUDICATEDDISPUTE BOARD

If terms are contested, contract escalates to Admin. Administrator reviews deliverables and resolves via: Full Release, Full Refund, or Partial Split.

02 / SECURITY ARCHITECTURE

Role-Based Access Control (RBAC)

Permissions are enforced at the API route and database query layer to prevent privilege escalation:

CLIENT
  • • Create projects & deposit escrow milestones
  • • Review submitted freelancer proposals
  • • Access private workspaces for messaging
  • • Request modifications or release funds
  • • Escalate contested work to system admins
FREELANCER
  • • Browse open project marketplace
  • • Submit proposals with counter-offer rates
  • • Submit milestone deliverables and status logs
  • • Raise disputes if client withholds approval
  • • Bidirectional reputation rating and reviews
ADMINISTRATOR
  • • Adjudicate active disputes (Release / Refund / Split)
  • • Monitor platform TVL (Total Value Locked)
  • • Inspect account violation & abuse flags
  • • Audit immutable system action logs
  • • System-wide user moderation
03 / TECHNICAL SPECIFICATIONS

Architectural Stack & Decisions

LAYERTECHNOLOGYTECHNICAL RATIONALE
FrameworkNext.js 16 (App Router)Server Component rendering, API route security, streaming SSR.
Database & ORMNeon PostgreSQL + Prisma ORMServerless branchable Postgres with ACID transactions for escrow states.
AuthenticationNextAuth.jsSession verification, credentials support, and protected route handlers.
SMS VerificationTwilio Service APITwo-factor identity verification and milestone transaction security.
Validation & SecurityZod Schema + Bcrypt HashingStrict runtime contract payload validation and secure salted credential storage.
Design SystemTailwind CSSPerformant utility-first responsive styling with strict monochrome theme.
NEXT CASE STUDY: QUEUELESSVIEW ON GITHUB