How nhatlank23/e-course-sales-system works
Project type & purpose (from README)
This is a full-stack B2C e-learning platform (“E-Course Sales System”) with two standout non-trivial capabilities:
• Real-time consulting (live sessions between learners and consultants/instructors)
• Secure video streaming (protected course video delivery)
Tech explicitly mentioned:
• Next.js (web app / frontend, possibly also SSR and/or API routes)
• Express (backend API / business logic)
• Supabase (managed backend services: Postgres DB, Auth, Storage, Realtime)
Web Client (Browser / Mobile Web)
• Interacts with Next.js over HTTPS
• Plays video (HLS/DASH) and participates in consulting sessions (WebRTC or similar)
• Authentication and session handling (likely via Supabase Auth tokens/cookies)
Next.js App
• UI pages, SSR/SSG, routing
• May call Express API, and may call Supabase directly (common pattern)
• “Next.js UI (SSR/SSG)” and
• “Next.js API routes (BFF)”
But don’t assume that without code—keep it a single container unless confirmed.
Express API Service
• Core business logic: course catalog, orders, enrollments, access control decisions
• Issues “secure video access” artifacts (e.g., signed URLs / entitlement checks)
• Manages “real-time consulting” orchestration if not fully handled by Supabase/3rd parties
Supabase Auth
• User registration/login, JWT issuance, session management
• Roles/permissions (e.g., student vs instructor/admin)
Supabase Postgres (Database)
• Courses, lessons, pricing, purchases, enrollments, user profiles
• Consulting session scheduling/history
• Access logs (optional)
Supabase Storage
• Video assets (or at least some media assets)
• Private buckets + signed URLs, and/or
• A CDN in front of storage, and/or
• Token-gated streaming manifests
Supabase Realtime (optional but likely)
• Presence/chat updates, session state, notifications, collaborative features
• Only include if the project truly uses it; otherwise mark as “possible”.
Real-time Signaling / Session Service
Real-time consulting usually needs:
• Signaling (WebSocket or similar) for WebRTC session negotiation
• Media path (WebRTC peer-to-peer or via SFU)
Option 1 (common):
• Browser ↔ (WebRTC) ↔ Browser (P2P media)
• Browser ↔ (WebSocket/HTTP) ↔ Express (signaling + auth + session state)
Option 2 (scales better):
• Browser ↔ (WebRTC) ↔ SFU/Media Server (external component)
• Browser ↔ Express (signaling/auth)
External services (don’t invent; include placeholders if product implies them)
E-course sales typically implies payments. Since README doesn’t mention it, handle it like this:
Auth & user session
• Browser → Next.js: login/signup UI
• Next.js / Browser → Supabase Auth: authenticate; receive JWT/session
• Browser/Next.js → Express: API calls with Bearer token / cookie
• Express → Supabase Auth: token verification / RBAC checks (or uses Supabase JWT verification logic)
Core app flows (catalog → purchase/enroll → access)
• Browser → Next.js: browse course catalog pages
• Next.js → Express: fetch course catalog / pricing / enrollment state
• Express → Supabase Postgres: read/write domain data (courses, purchases, enrollments)
• Browser → Next.js: open lesson page
• Browser/Next.js → Express: “request video playback authorization” (entitlement check)
• Express → Supabase Postgres: confirm enrollment/purchase
• Express → Supabase Storage: request signed URL / create signed access (or returns a token)
• Browser → Storage/CDN: stream video using signed URL (HLS/DASH)
Real-time consulting
• Browser ↔ Express: signaling (WebSocket/HTTP) + session metadata
• Browser ↔ Browser or Browser ↔ SFU: real-time media (WebRTC)
• Express → Supabase Postgres: persist session records, schedules, etc.
• (Optional) Express/Browser ↔ Supabase Realtime: presence/chat/notifications (only if used)
Architectural patterns to highlight (label these
Even at high level, call out these patterns as annotations:
• Separation of concerns: Next.js (presentation) vs Express (business/API) vs Supabase (data/auth/storage)
• BFF vs direct-to-Supabase: clarify whether Next.js directly queries Supabase or always goes via Express (mark as “verify”)
• Entitlement-based media access: “authorize then stream” (signed URLs / private storage)
• Real-time subsystem split: signaling/control plane vs media plane
Diagramming conventions to enforce (so it’s readable and “principal-level”)
Elements explicitly:
Clear labels
• Tech in the label, e.g.:
• “Next.js Web App (SSR/SSG)”
• “Express API (REST/GraphQL? verify)”
• “Supabase Auth (JWT)”
• “Supabase Storage (private bucket, signed URLs)”
• “Postgres (Supabase)”
• “HTTPS (JSON)”
• “WebSocket (signaling)”
• “WebRTC (media)”
• “SQL”
• “Signed URL (time-limited)”
“Don’t overthink it” but be detailed: split into as many components as possible
Given the minimal repo info, the best approach is:
• Split real-time consulting into signaling vs media path
• Split secure streaming into authorization vs content delivery path
• “VERIFY:” callouts on anything not explicitly confirmed by README.
• Does Next.js call Supabase directly, or is Express the only backend interface?
• Is Express deployed separately from Next.js, or behind the same domain/reverse proxy?
• For consulting: WebRTC P2P or SFU? What’s used for signaling (WS via Express, Supabase Realtime, or 3rd party)?
• For video: stored in Supabase Storage or elsewhere? Is there a CDN? How are signed URLs generated?
• What handles payments (if any), webhooks, and order finalization?