Design a multi-tenant course purchase and delivery system
MathWorksSoftware Engineer · Online AssessmentLast updated
This question tests the ability to design a scalable multi-tenant architecture that manages course content, user entitlements, and purchase workflows across different organizational silos.
System Design: Multi-Tenant Course Delivery Platform
Design a multi-tenant platform where various educational organizations (tenants) can host their own courses, and individual users can purchase access to these courses. The system must ensure strict data isolation between tenants while allowing the platform to scale to millions of users.
Requirements
Functional Requirements:
- Multi-tenancy: Users belong to an organization. Organizations manage their own course catalogs. A user should not see courses from other organizations unless explicitly authorized.
- Purchasing: Users can purchase access to courses. Payments are handled via a third-party gateway, but the system must track transaction status.
- Entitlements: Once purchased, users should have immediate access to course materials (videos, quizzes).
- Prerequisites: Some courses require the completion of other courses before purchase/enrollment is allowed.
Non-Functional Requirements:
- Scalability: The system must handle high read traffic for course browsing and video streaming.
- Consistency: Purchase records must be consistent. Enrollment state should reflect purchase completion accurately.
- Security: Users must only access content they have paid for, verified against their specific tenant context.
Expectations
Provide a high-level design that addresses the following:
- Data Model: How would you schema the databases to handle tenants, users, courses, and purchase status?
- API Design: Define the core API endpoints for browsing, purchasing, and checking enrollment.
- Scalability Trade-offs: Discuss how you would balance data isolation (multi-tenant architecture) with the need for high-performance reads (caching/CDN).
- Access Control: Explain the enforcement mechanism for prerequisites during the purchase flow.
Hints
Hint 1
Consider whether to use a separate database per tenant, a shared database with a 'tenant_id' column, or a hybrid approach based on the scale of your customers.
Hint 2
For prerequisite enforcement, decide if the check should happen at the API layer, the database layer (via transactions), or via a background asynchronous validation service.
Hint 3
Use a caching strategy like Redis to store entitlement metadata, reducing the number of database queries needed during every content access request.
Follow-up questions
- How would you handle a global migration where a course is moved from one organization to another?
- If an organization wants to run a 'bundle' promotion for three courses at a discounted price, how would you modify the transaction and entitlement logic?
- How would you ensure that a user's progress in a course is kept isolated if the user happens to have accounts in multiple organizations under the same email address?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.