KatInterview

Design a Structured Learning Content Service

System DesignModel answer
EasyModel answerSystem Designsystem-designcachingdatabase-design

Last updated

Design a data model, API, reordering mechanism, and publishing/caching strategy for a fixed 3-tier learning content management system.

Problem Context

You are tasked with designing the core backend service for an enterprise learning platform. Content is organized in a fixed 3-level hierarchy:

  1. Course Track (e.g., "Senior Sales Executive Training")
  2. Learning Module (e.g., "Negotiation Strategies")
  3. Lesson (e.g., "Handling Price Resistance")

Learners consume published content frequently through web and mobile clients, while curriculum managers continuously create, edit, reorder, move, and publish updates.

Core Requirements

Functional Requirements

  • Hierarchy Read Capabilities: Clients must be able to load a complete course track with all child modules and lessons in a single call, or retrieve individual items with parent context (breadcrumbs).
  • Content Operations: Support creating, updating, archiving, and reordering items (e.g., repositioning a lesson within its module or moving a lesson to another module entirely).
  • Deterministic Ordering: Items within a parent container must maintain consistent, explicit ordering despite simultaneous edits.
  • Publishing & Caching Workflow: Content creators work on draft states. Publishing must be atomic—learners should only see fully published releases, and updates must invalidate caches instantly.

Non-Functional Requirements

  • Low Read Latency: Read requests for published track structures must return within p95 < 30 ms.
  • Data Integrity: Operations like item moves and structural reordering must be transactional—no item can be lost, duplicated, or orphaned mid-operation.
  • Fixed Depth: The hierarchy is strictly 3 tiers deep. General tree traversal routines for arbitrary depths are unnecessary.

Scale & Traffic Profile

  • Volume: 1,000 active tracks, 10,000 modules, 100,000 lessons.
  • Learner Traffic: 50,000 daily active users, producing 500 read requests/sec at peak.
  • Authoring Activity: ~50 content managers performing ~1,000 draft modifications/day (99.9% read-heavy workload).

System Design Deliverables

  1. Data Schema: A relational data model showing tables, primary/foreign keys, indexing, and position ordering fields.
  2. REST API Specifications: Resource endpoints for structure retrieval, content mutation, and item repositioning.
  3. Ordering & Concurrency Strategy: A scalable method for dynamic reordering without expensive index shifts or race conditions.
  4. Publishing & Cache Lifecycle: A snapshot and cache invalidation architecture ensuring zero partial reads for end users.

Hints

Hint 1

Exploit the fixed 3-tier depth—you do not need graph algorithms, closure tables, or arbitrary tree recursion.

Hint 2

For item reordering, consider fractional indexing (lexicographical string keys) to avoid shifting all sibling positions on every edit.

Hint 3

Decouple authoring (drafts) from reader traffic (published state) via snapshot-based versioning to guarantee zero partial-state reads.