HomeCase studiesB2B Multi-Vendor Marketplace with Contract Pricing, Split...

Case study · Madrid, Spain

B2B Multi-Vendor Marketplace with Contract Pricing, Split Fulfillment, and Escrow Payouts

B2B Multi-Vendor Commerce

Industrial and commercial buyers procuring across dozens of regional distributors struggle when each supplier enforces separate portals, custom price tiers, and manual quote emails. We engineered a B2B multi-vendor marketplace using Next.js, NestJS, TypeScript, PostgreSQL, and Elasticsearch to unify faceted catalog discovery, organization-specific contract pricing, split-vendor cart checkout, and automated payout settlement. Modular NestJS services isolate supplier inventory feeds and RFQ negotiations while Next.js delivers fast SSR storefronts and buyer approval dashboards.

Industry
B2B Multi-Vendor Commerce
Solution
A B2B multi-vendor procurement marketplace, vendor portal, and split-settlement backend built with Next.js, NestJS, TypeScript, PostgreSQL, Elasticsearch, Redis, and Stripe Connect.
Platforms
Web & API
Stack
Next.js · NestJS · TypeScript · PostgreSQL · Redis · Elasticsearch
Location
Madrid, Spain · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Madrid, Spain. Names withheld by agreement.

Project Overview

Industry: B2B Multi-Vendor Commerce

Solution scope: A B2B multi-vendor procurement marketplace, quote negotiation hub, and split-settlement backend engineered with Next.js, NestJS, TypeScript, PostgreSQL, Elasticsearch, Redis, and Stripe Connect.

Context: Commercial buyers sourcing packaging, MRO supplies, electronics, and hospitality goods across fragmented wholesale distributors face severe procurement friction: separate supplier logins, inconsistent minimum order quantities (MOQs), emailed Excel price sheets, and manual invoice reconciliation across every vendor. Meanwhile, marketplace operators need tight control over vendor onboarding, commission rules, split shipping logic, and escrow-style payouts. We built a unified B2B commerce platform pairing a fast Next.js App Router storefront with a modular NestJS and PostgreSQL core capable of routing a single buyer requisition across multiple independent suppliers seamlessly.

B2B Marketplace Bottlenecks

Public B2C cart patterns failed under commercial buying rules. Standard single-price catalogs could not express buyer-specific contract discounts, pallet volume breaks, or minimum order thresholds per vendor.

Cross-vendor checkouts created fulfillment deadlocks. Coupling multiple suppliers into one monolithic order state meant a delay or partial stockout at one warehouse stalled invoicing and payout tracking for every other vendor on the cart.

Unstructured supplier feeds corrupted catalog search. Vendors uploading inconsistent CSV spreadsheets introduced duplicate SKUs, broken category mappings, and stale stock counts that eroded buyer trust.

Manual commission splits slowed marketplace finance. Reconciling platform fees, shipping subsidies, and partial refunds across dozens of vendor bank transfers required error-prone end-of-month spreadsheets.

Architectural Strategy

Separate parent buyer orders from vendor sub-orders. Buyers experience one consolidated cart, approval flow, and order summary, while NestJS decomposes checkout into independent child VendorOrder lifecycles that ship, invoice, and settle autonomously.

Keep search indexing decoupled from dynamic contract pricing. Elasticsearch handles full-text queries, technical attribute faceting, and catalog sorting across tens of thousands of SKUs, while NestJS overlays personalized organization price books via Redis and PostgreSQL at read time.

Enforce strict TypeScript contracts end to end. Sharing clean schema definitions across Next.js server components and NestJS controllers eliminates payload drift across complex RFQ forms, multi-tier price tables, and sub-order transitions.

Track commissions and payouts through an internal double-entry ledger. Rather than relying solely on payment-gateway metadata, PostgreSQL records every gross charge, platform fee, refund adjustment, and Stripe Connect transfer as auditable ledger entries.

Core Capabilities

  • Faceted B2B catalog & SKU matrix: Parametric search across technical specs, supplier ratings, lead times, MOQs, and tiered volume pricing tables.
  • Contract pricing & buyer organizations: Multi-user corporate buyer accounts supporting role-based spend limits, internal cart approval queues, and negotiated catalog overrides.
  • Structured RFQ & quote-to-cart flow: Buyers request custom pricing on bulk quantities directly from vendors, negotiate counter-offers inside tracked threads, and convert accepted quotes into locked orders.
  • Split-vendor cart & shipping engine: Calculates per-supplier freight rules, pallet thresholds, and delivery windows inside a unified checkout view.
  • Self-serve vendor portal: Dedicated Next.js workspace for suppliers to upload catalog feeds, manage stock buffers, confirm sub-orders, print packing slips, and track payout statements.
  • Escrow-aware commission settlement: Automated fee calculation, holdback periods for delivery confirmation, and partial-refund reversals via Stripe Connect.

Technical Architecture

Next.js App Router storefront & portals. Next.js renders public and authenticated catalog pages on the server for fast initial paint and clean search engine indexing, while client components handle interactive cart splits, bulk SKU quick-order uploads, and live RFQ chat panels.

NestJS modular API core. Built in TypeScript, NestJS separates Catalog Ingestion, Pricing Resolution, Cart & Checkout, RFQ Workflow, Sub-Order Fulfillment, and Ledger Settlement into isolated modules communicating through typed domain services and background queues.

Elasticsearch & Redis acceleration. Elasticsearch indexes canonical products and vendor offers with synonym rules for part numbers and technical units. Redis caches resolved (buyer_org_id, offer_id) contract prices and guards inventory reservations during active checkouts.

PostgreSQL ledger & Stripe Connect. PostgreSQL anchors relational integrity across buyer hierarchies, sub-order state transitions, and commission ledgers. Stripe Connect executes split payment captures and controlled transfers to verified vendor connected accounts.

Flow: Buyer (Next.js SSR / Cart) → NestJS API & pricing resolver → Elasticsearch catalog + Redis cache → PostgreSQL parent/sub-order ledger → Vendor portal & Stripe Connect payouts

Technology Stack

Category Technology
Storefront & portals Next.js (App Router) and TypeScript rendering SEO-friendly SSR catalogs, buyer carts, and vendor dashboards
Backend API platform NestJS modular architecture governing auth, RFQ negotiations, split-order state machines, and payout ledgers
Primary database PostgreSQL storing multi-tenant buyer organizations, vendor profiles, contract price books, and order ledgers
Search & faceting Elasticsearch indexing multi-attribute SKU catalogs, supplier stock flags, and compatibility filters
Cache & rate control Redis caching buyer contract-price lookups, active cart locks, and vendor feed ingestion queues
Marketplace payouts Stripe Connect orchestrating split charges, platform commission holds, and post-delivery vendor transfers
Bulk catalog ingestion Async CSV/XML feed workers validating supplier SKU updates, volume breaks, and minimum order quantities
Document generation Automated multi-vendor consolidated buyer proformas and per-supplier VAT settlement statements
Observability OpenTelemetry request tracing across Next.js SSR, NestJS modules, and Elasticsearch query latency

Engineering Trade-offs & Solutions

Challenge Solution
Indexing buyer-specific contract prices inside Elasticsearch would cause massive index fan-out Kept Elasticsearch buyer-agnostic on base catalog data and resolved negotiated contract discounts in NestJS via batched Redis lookups.
One delayed vendor shipment risked blocking payouts or status updates for other suppliers in the same checkout Modeled a ParentOrder → VendorSubOrder hierarchy in PostgreSQL so each supplier fulfills, invoices, and triggers settlement independently.
Large vendor CSV price updates occasionally stalled storefront APIs Routed bulk feed parsing into asynchronous validation workers that verify SKUs and volume tiers in staging tables before atomic Elasticsearch bulk swaps.
Mid-checkout price changes or stockouts across multiple vendors confused corporate buyers Added short-lived checkout price snapshots and atomic stock validation per sub-order before Stripe payment capture executes.
Partial cancellations by one supplier distorted flat platform commission math Computed commissions per sub-order line item inside an append-only ledger so partial refunds automatically recalculate proportional fee reversals.
Corporate buyers needed internal manager sign-off without losing negotiated quote locks Built a PENDING_APPROVAL cart state that preserves accepted RFQ pricing and stock reservations while notifying designated organization approvers.

Security & Governance

Tenant-scoped authorization guards. NestJS guards enforce strict isolation between competing vendor portals and separate corporate buyer organizations so no supplier can inspect rival pricing or another buyer's contract terms.

KYC verification & payout holdbacks. Vendors complete Stripe Connect identity onboarding before listings go live, and marketplace payout releases enforce configurable delivery confirmation and dispute windows to protect buyers against non-delivery.

Audited quote & order mutations. Every RFQ counter-offer, contract price edit, manager cart approval, and commission override writes an immutable audit trail recording actor, timestamp, and payload diff.

Performance & Scale

Fast SSR catalog browsing. Combining Next.js server rendering with Elasticsearch aggregations and short-TTL Redis pricing caches keeps category browsing and technical attribute filtering snappy even across deep multi-vendor catalogs.

Independent scaling of ingestion and checkout. Isolating supplier feed workers from NestJS checkout nodes ensures heavy overnight catalog refreshes never contend with live buyer orders.

Operational Outcomes

  • Consolidated multi-supplier procurement: Corporate buyers search, compare, approve, and check out across dozens of vetted vendors inside one unified portal.
  • Autonomous vendor fulfillment: Suppliers manage their own stock feeds, sub-order dispatches, and shipping SLAs without manual marketplace operator mediation.
  • Transparent, automated commission accounting: Double-entry PostgreSQL ledgers and Stripe Connect settlement rules remove manual month-end payout reconciliation.
  • Higher quote conversion on bulk orders: Structured RFQ threads and instant quote-to-cart handoffs replace slow email spreadsheets for high-value wholesale deals.

01 — Questions

asked about this kind of project

How does Elasticsearch support fast catalog filtering when every B2B buyer organization sees different negotiated contract prices?

Elasticsearch indexes canonical SKU attributes, vendor offers, and public base tiers for sub-second faceted search and pagination. Once search returns matching offer IDs, NestJS resolves the authenticated buyer's contract overrides and volume price breaks in a single batched Redis and PostgreSQL lookup before Next.js renders final pricing.

How does a single buyer checkout split cleanly across multiple independent vendors with different shipping rules?

Checkouts create one parent Purchase Order for buyer tracking and approval, linked to independent child Vendor Sub-Orders in PostgreSQL. Each sub-order carries its own shipping carrier calculation, tax breakdown, fulfillment state machine, and settlement status so one vendor's partial backorder never stalls another vendor's shipment.

Why pair Next.js with a separate NestJS backend instead of placing all business logic inside Next.js route handlers?

B2B marketplaces run heavy background workflows—CSV catalog imports, RFQ expiration timers, split payout ledgers, and webhook reconciliation—that belong in a structured, testable API tier. NestJS provides clean dependency injection, strict DTO validation, and independent scaling while Next.js focuses on fast server-rendered storefronts and portal UX.

How are vendor payouts protected against buyer disputes, partial cancellations, or returns?

Marketplace funds settle through Stripe Connect using delayed transfer triggers rather than instant pass-through splits. Commission calculations and vendor net payables record into a PostgreSQL ledger, releasing transfers only after confirmed delivery milestones or dispute windows clear.

How do corporate buyers handle internal spending limits and Request-for-Quote (RFQ) negotiations?

Buyer organizations configure per-user spending thresholds in PostgreSQL; carts exceeding a buyer's limit transition into a pending-approval state for department managers. For bulk orders, buyers submit structured multi-line RFQs directly to selected vendors, converting accepted quotes into locked checkout carts.

How do you prevent noisy supplier CSV feeds from degrading live storefront search?

Supplier feed uploads execute asynchronously in background queues that validate schema, minimum order quantities, and unit conversions into staging tables first. Validated deltas batch-index into Elasticsearch using bulk APIs with version numbers, keeping live buyer searches fast.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.