APIs needed for a Udemy-like application

Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2024-03-30

Problem Statement

Design the backend APIs for an online learning platform like Udemy, supporting courses, instructors, students, enrollments, content delivery, and payments. Focus on API structure, authentication, and high-level interactions rather than implementation details.


Functional Requirements (FR)


User & Authentication


•Users can register/login using email, social login, or SSO.
•Maintain profile information: name, email, profile picture, role (student/instructor/admin).
•Role-based access control: Students, Instructors, Admins.


Course Management


•Instructors can create, update, and delete courses.
•Courses include: title, description, category, language, price, content (videos, PDFs, quizzes).
•Manage course visibility (published/unpublished).


Enrollment & Access


•Students can browse courses and enroll (free or paid).
•Provide access control to course content based on enrollment status.
•Support course progress tracking (completed lessons, quizzes).


Content Delivery


•Streaming videos securely with CDN support.
•Downloadable resources (PDFs, slides).


Payments


•Support multiple payment methods (card, wallets, UPI).
•Handle payment confirmations, refunds, and invoices.


Reviews & Ratings


•Students can review courses and rate them.
•Aggregate course ratings and display publicly.


Search & Recommendation


•Search courses by keywords, categories, instructors.
•Recommend popular/trending courses.


Notifications


•Notify students about course updates, new courses, or promotions.


Non-Functional Requirements (NFR)


•Scalability: Handle millions of users, courses, and concurrent video streams.
•Low Latency: Fast API responses for search and content delivery.
•Availability: High uptime, especially for content delivery.
•Security: Secure authentication, authorization, and content access.
•Extensibility: Easy to add new features like live sessions, certifications, or subscriptions.


Core API Endpoints


User APIs


•POST /users/register → Register a new user.
•POST /users/login → Authenticate user.
•GET /users/{id} → Get user profile.
•PUT /users/{id} → Update user profile.


Course APIs


•POST /courses → Create a new course (Instructor only).
•PUT /courses/{id} → Update course details.
•DELETE /courses/{id} → Delete course.
•GET /courses → List courses (with filters & pagination).
•GET /courses/{id} → Get course details.


Enrollment APIs


•POST /courses/{id}/enroll → Enroll student in course.
•GET /users/{id}/enrollments → Get courses a student is enrolled in.


Content APIs


•GET /courses/{id}/content → List lessons/resources for a course.
•GET /courses/{id}/content/{lessonId} → Access specific lesson/resource.


Payment APIs


•POST /payments/initiate → Start payment for a course.
•POST /payments/confirm → Confirm payment success/failure.
•POST /payments/refund → Request a refund.


Review & Rating APIs


•POST /courses/{id}/review → Submit review.
•GET /courses/{id}/reviews → Get reviews and average rating.


Search & Recommendation APIs


•GET /search?query=... → Search courses.
•GET /courses/recommended?userId=... → Get recommended courses for a user.


Notification APIs


•GET /notifications/{userId} → Fetch notifications.
•POST /notifications → Send notifications (Admin only).


Design Considerations


Authentication & Authorization


•JWT or OAuth2 for secure APIs.
•Role-based access: student, instructor, admin.


Caching & CDN


•Cache popular courses, search results.
•Use CDN for video streaming to reduce latency.


Database Design


•Users, Courses, Lessons, Enrollments, Reviews, Payments.
•Use relational DB for transactional data; NoSQL or object storage for content.


Scalability


•Microservices for course management, enrollment, payment, search, content delivery.
•Load balancers, horizontal scaling for high traffic.


Extensibility


•Add live sessions, certifications, subscription models, and quizzes easily.


✅ This HLD problem tests:


•Designing API structure and interactions for a complex platform.
•Considerations for scalability, security, and modularity.
•Integration of payments, content delivery, and user engagement features.


Solution

Comments