HomeCase studiesMulti-Tenant Creator Course Marketplace with Split-Payout Ledgers...

Case study · Austin, United States

Multi-Tenant Creator Course Marketplace with Split-Payout Ledgers and Cohort Delivery

Creator Academies & Cohort Learning

Independent instructors and cohort-based academies often outgrow off-the-shelf course builders when they need custom storefronts, staged cohort releases, and transparent revenue splits with guest mentors. We engineered a multi-tenant course marketplace using Next.js, NestJS, and PostgreSQL backed by Redis caching and Stripe Connect. The platform separates public SEO-optimized creator catalogs from authenticated learner workspaces, enforces double-entry payout accounting, and delivers tokenized HLS video lessons without exposing raw media assets.

Industry
Creator Academies & Cohort Learning
Solution
A multi-tenant web and API course marketplace built with Next.js, NestJS, and PostgreSQL, combining custom creator storefronts, cohort-paced curriculum delivery, and automated split-payout accounting.
Platforms
Web & API
Stack
Next.js · TypeScript · NestJS · PostgreSQL · Prisma · Redis
Location
Austin, United States · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Austin, United States. Names withheld by agreement.

Project Overview

Creator-led technical academies occupy an awkward middle ground between consumer video portals and rigid corporate learning management systems. Instructors selling cohort workshops, multi-week bootcamps, and self-paced reference libraries need fast, search-indexable landing pages alongside gated classrooms, drip-scheduled modules, and automated revenue sharing with teaching assistants or guest speakers. Generic SaaS templates flatten brand differentiation and break down once pricing mixes installment plans, team seat bundles, and split instructor payouts.

To support independent academies under one extensible infrastructure, we architected and shipped a multi-tenant online course marketplace on Next.js, NestJS, and PostgreSQL. The platform unifies storefront discovery, Stripe Connect split-payout accounting, cohort seat gating, and protected HLS video delivery behind clean TypeScript service boundaries.

Business Bottleneck

Before introducing a unified architecture, creator operations fragmented across disconnected checkout plugins, external video hosts, and manual spreadsheets:

  • Reconciliation drift on split payouts: Multi-instructor courses required manual payout adjustments whenever discount coupons, partial refunds, or currency conversions occurred after settlement.
  • Seat-cap race conditions: Popular live workshops occasionally oversold limited mentoring cohorts when concurrent shoppers completed external checkouts faster than inventory synced back.
  • Slow catalog pages hurting organic acquisition: Client-rendered course portals struggled with metadata previews, regional pricing display, and search-engine crawlability across custom creator domains.
  • Leaky media links: Static download URLs and shared embeds circulated outside paying cohorts because playback tokens were neither session-bound nor short-lived.

Architectural Strategy

We structured the system around strict separation between public catalog rendering, transactional entitlement state, and asynchronous media/payment side effects. Next.js App Router handles public course discovery via Incremental Static Regeneration (ISR) so creator storefronts load quickly and expose clean structured metadata, while authenticated classroom routes verify enrollment state dynamically against NestJS.

Inside NestJS, domain boundaries follow modular isolation—Catalog, Enrollment, Cohort Scheduling, Ledger, and Media Entitlement—backed by a single PostgreSQL database accessed through Prisma. Putting core commercial invariants inside one ACID-compliant relational store let us enforce cohort capacity locks and double-entry financial records in single database transactions, while BullMQ workers on Redis absorb slow tasks such as video packaging, certificate PDF rendering, and webhook retries.

Core Capabilities

  • Multi-Tenant Storefronts & Domain Routing: Instructors launch branded academy portals on subdomains or custom CNAMEs with localized tax/currency presentation and syllabus previews.
  • Hybrid Self-Paced & Cohort Drip Engines: Curriculum authors configure unlock rules based on enrollment timestamp, calendar cohort start dates, or prerequisite quiz completion.
  • Double-Entry Split-Payout Ledger: Checkout events automatically allocate platform commissions, primary creator earnings, and co-mentor percentages with auditable settlement states.
  • Encrypted HLS Classroom Player: Learners resume playback across devices with chapter markers, downloadable code artifacts, and session-scoped media authorization.
  • Team Seat & Voucher Provisioning: Enterprise buyers purchase bulk seat blocks and distribute redeemable invite links through an isolated organization portal.

Technical Architecture

Every storefront request enters Next.js middleware, which maps the incoming hostname to a tenant identifier cached in Redis. Public syllabus pages render from ISR snapshots invalidated selectively via on-demand revalidation webhooks whenever an author publishes curriculum edits. Authenticated classroom actions call NestJS REST endpoints guarded by JWT verification and tenant-scoped RBAC decorators.

Flow: Browser (Next.js App Router) → Tenant Middleware (Redis Cache) → NestJS API Gateway (Auth & Entitlement Guard) → PostgreSQL / Prisma (ACID Enrollments & Ledger) → Redis / BullMQ Workers (Stripe Webhooks & HLS Packaging) → AWS S3 / CloudFront Signed Delivery

Payment confirmation relies exclusively on signed Stripe Connect webhooks rather than browser redirect callbacks. Incoming webhook payloads pass signature verification, acquire an idempotency key in PostgreSQL, finalize the pending seat reservation into an active enrollment, and post balanced journal lines into the payout ledger before dispatching welcome emails asynchronously.

Technology Stack

Category Technology detail
Frontend Storefront & Player Next.js (App Router, TypeScript, hybrid SSR/ISR creator pages)
Backend API & Domain Core NestJS modular monolith with TypeScript and strict DTO validation
Primary Relational Store PostgreSQL handling tenants, enrollments, progress, and financial ledgers
ORM & Schema Migrations Prisma Client with advisory-locked migrations and typed query builders
Caching & Queue Broker Redis + BullMQ for webhook retries, transcoding jobs, and session caching
Marketplace Payments Stripe Connect Express with destination charges and idempotent webhook sync
Media Storage & Delivery AWS S3 origin with HLS segmentation and CloudFront signed URLs
Observability & Tracing OpenTelemetry structured logs and trace propagation across Next.js and NestJS

Engineering Trade-offs & Solutions

Engineering Challenge Solution & Trade-off
Preventing cohort overselling during simultaneous checkouts Used pessimistic row locks (SELECT ... FOR UPDATE) on cohort seat counters inside PostgreSQL with timed reservation expiry; slightly serializes peak checkout writes for a single cohort while eliminating overbooking.
Balancing storefront SEO speed with dynamic seat availability Cached syllabus content via Next.js ISR while hydrating live seat counts and user entitlement badges via lightweight client/edge fetches, avoiding stale purchase buttons.
Handling complex refunds across multi-instructor revenue splits Implemented an append-only double-entry ledger in PostgreSQL instead of mutating order rows; increases schema verbosity but guarantees auditability during tax reporting and disputes.
Protecting video assets without forcing heavy native DRM Transcoded lessons to AES-encrypted HLS behind short-lived CloudFront signed cookies; blocks casual hotlinking across browsers while keeping mobile web playback frictionless.

Security & Reliability

Multi-tenant data isolation is enforced at the persistence boundary as well as the controller layer. NestJS request-scoped guards bind tenantId and actorId from verified tokens, and repository helpers reject queries lacking explicit tenant predicates so creators cannot inspect rival academies' student rosters or payout balances.

Payment reliability depends on idempotent state machines. Every Stripe Connect event ID is recorded in a unique-indexed PostgreSQL webhook table prior to ledger mutation, preventing duplicate delivery retries from double-crediting instructor balances. Media uploads land directly in quarantined AWS S3 staging prefixes via presigned POST policies with strict MIME and byte-size bounds before transcoding workers touch them.

Performance & Scale

Separating read-heavy discovery traffic from transactional classroom writes keeps database load predictable during product launches. Public course catalogs, instructor bios, and hostname maps resolve from Redis and Next.js edge caches, leaving PostgreSQL connection pools focused on checkout transactions, lesson-progress heartbeats, and discussion queries.

Video ingestion and thumbnail extraction execute out-of-band in BullMQ worker containers so large 4K instructor uploads never tie up NestJS HTTP workers. Lesson completion heartbeats batch client-side progress updates every few seconds, cutting redundant PostgreSQL write churn during long video sessions.

Operational Outcomes

Consolidating storefront rendering, cohort gating, and payout accounting into a cohesive Next.js, NestJS, and PostgreSQL foundation removed operational bottlenecks for both creators and platform operators:

  • Reliable cohort launches: Pessimistic seat locking and idempotent webhook processing eliminated oversold mentorship seats and manual enrollment fixes during high-traffic launch windows.
  • Auditable creator payouts: Co-instructors and academy owners inspect real-time ledger breakdowns per enrollment, refund, and fee without waiting on end-of-month spreadsheet reconciliations.
  • Faster creator onboarding: Standardized NestJS curriculum schemas and ISR storefront templates let new academies publish custom-domain catalogs without bespoke engineering work.
  • Controlled media distribution: Tokenized HLS delivery and tenant-scoped entitlements curbed unauthorized link sharing while maintaining smooth cross-browser playback.

01 — Questions

asked about this kind of project

How does the platform prevent overselling seats in capped live cohorts?

Enrollment reservations run inside a serializable PostgreSQL transaction that acquires a row-level lock on the cohort capacity record before creating a pending checkout session. Unpaid reservations expire via a scheduled BullMQ sweep so abandoned checkouts release seats promptly.

Why pair a NestJS modular monolith with Next.js instead of splitting into microservices?

Catalog discovery, enrollment entitlements, and revenue-split ledgers share tight transactional boundaries in PostgreSQL. Keeping those modules inside a single NestJS deployment avoided distributed sagas while still allowing media transcoding workers to scale independently via Redis queues.

How are revenue shares calculated accurately when refunds or chargebacks occur?

Every checkout, platform fee, instructor share, and co-mentor split writes immutable debit and credit rows into a double-entry PostgreSQL ledger. Refund webhooks post reversing journal entries against the creator's pending balance rather than mutating historical payment rows.

How do you protect paid video lessons from unauthorized sharing or direct URL scraping?

Uploaded source files are transcoded into encrypted HLS segments stored in a private AWS S3 bucket. The NestJS entitlement service mints short-lived CloudFront signed cookies scoped to the authenticated learner session and lesson path.

How does Next.js serve custom creator domains while keeping catalog pages fast?

Next.js middleware resolves custom hostnames and tenant slugs against a Redis-backed routing table, serving Incremental Static Regeneration pages for public course syllabi and revalidating selectively whenever an instructor edits pricing or curriculum modules.

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.