KatInterview

Build a Tenant-Isolated Platform for Selling and Streaming Courses

System DesignModel answer
MediumModel answerSystem Designsystem-designmulti-tenancypayments

Last updated

Design a SaaS learning platform where organizations run separate course catalogs, learners buy access via an external payment provider, and prerequisite rules gate enrollment.

Design a Multi-Organization Learning Marketplace

You are building a hosted learning platform. Many independent organizations (the tenants) each publish their own courses. Learners belong to one organization and can buy access to its courses. Payment is handled by an external gateway, but your system is responsible for recording what happened to every payment and for granting access correctly.

What the platform must do

  1. Tenant separation. Each learner belongs to an organization. Each organization controls its own catalog. A learner must not see another organization's courses unless that access has been explicitly authorized.
  2. Buying. Learners purchase courses. The payment itself happens at a third-party gateway, yet your system must track the status of each transaction.
  3. Instant access. After a successful purchase the learner should be able to open the course materials (videos, quizzes) right away.
  4. Prerequisites. Some courses can only be bought or enrolled in after other courses have been completed.

Quality requirements

  • Scale: Browsing and video playback produce very heavy read traffic. The system should serve millions of users.
  • Consistency: Purchase records must be correct, and enrollment state must match the real outcome of the payment.
  • Security: Content may only be delivered to people who paid for it, and the check must be made in the context of the learner's own tenant.

What to cover in your answer

  • Data model: the schema for tenants, users, courses, orders/purchases and their statuses.
  • API design: the main endpoints for browsing, buying, and checking enrollment.
  • Scale versus isolation: how you keep tenant data separate while still getting fast reads through caching and a CDN.
  • Prerequisite enforcement: where and how the rule is checked in the purchase flow.

State your assumptions about traffic and tenant sizes, and explain the trade-offs behind your main choices.

Hints

Hint 1

Start by estimating load: reads dwarf purchases, and video bandwidth only works through a CDN. Use that to decide where you need strong consistency (orders, entitlements) and where eventual consistency is fine (catalog pages).

Hint 2

Never take the tenant from a request parameter; derive it from the authenticated token or hostname, put it first in every key and primary key, and consider a second layer such as row-level security and tenant-prefixed cache keys and storage paths.

Hint 3

Payment callbacks can be duplicated or arrive late. Think about an idempotency key on order creation, a conditional PENDING-to-PAID update, and writing the order change, the entitlement, and an outbox event in one transaction.

Hint 4

Check prerequisites before creating the order, against the primary database rather than a cache or replica, so nobody pays and is then refused. Ask whether the check ever needs repeating at grant time.