How jsmastery-pro/vertex-learning-platform works
Purpose and Runtime
Vertex is a TypeScript/Next.js learning platform for browsing courses, consuming video lessons, and natural-language video search with timecode-level results. The root Next.js App Router application is the learner-facing runtime; Sanity Studio is a separate CMS runtime. Primary entry points: app/layout.tsx, app/page.tsx, and studio/sanity.config.ts.
Application Routing and Access
App Router pages expose the course catalog, course and lesson detail pages, search, and Clerk-hosted sign-in/up flows. proxy.ts is the request boundary for Clerk route protection/session handling. Key routes are app/courses/page.tsx, app/courses/[slug]/page.tsx, app/lessons/[slug]/page.tsx, app/search/page.tsx, and app/sign-in/[[...sign-in]]/page.tsx.
Content Delivery Layer
Sanity is the source of truth for courses, instructors, lessons, videos, modules, resources, and timecoded video chunks. The application accesses it through a dedicated client/fetch/query layer rather than embedding CMS calls in UI: sanity/lib/client.ts, sanity/lib/fetch.ts, sanity/lib/queries.ts. Generated content types are represented by sanity.types.ts; server-side Sanity reads require SANITY_API_READ_TOKEN.
Learner Experience Composition
Route pages assemble domain components for catalog cards, course presentation/progress, and lesson consumption. The course layer is centered on components/course/course-content.tsx, components/course/course-hero.tsx, and components/cards/course-grid.tsx. The lesson layer combines playback, curriculum navigation, notes/resources, and completion context through components/lesson/lesson-video.tsx, components/lesson/lesson-sidebar.tsx, and components/lesson/lesson-tabs.tsx. Video URL/provider handling is isolated in lib/video.ts.
Intelligent Search Pipeline
The browser search UI posts to app/api/search/route.ts. That server endpoint is the security boundary for OpenAI and Sanity Context MCP credentials, coordinating agent grounding and response generation via lib/search/ground.ts, lib/search/mcp.ts, and lib/search/system-prompt.ts. Search result contracts live in lib/search/types.ts; rendered results distinguish lessons and videos in components/search/search-results.tsx and components/search/video-result-card.tsx. Results link learners to lesson/video locations, including relevant timestamps.
CMS Studio and Content Ingestion
The independently deployable Sanity Studio defines editorial structure and authoring UI in studio/sanity.config.ts and studio/structure.ts. Its core schema establishes the course-to-module-to-lesson/video model in studio/schemaTypes/documents/course.ts, studio/schemaTypes/documents/lesson.ts, and studio/schemaTypes/documents/video.ts. Video ingestion scripts parse provider URLs, chunk material for retrieval, and produce NDJSON: studio/scripts/ingest/ingest-videos.mjs, studio/scripts/ingest/chunk.mjs, and studio/scripts/ingest/providers/youtube.mjs. The checked-in studio/scripts/context/vertex-search.ndjson is retrieval/context data.
Identity and Analytics Boundaries
Clerk provides authentication and protected-route enforcement, with UI entry points under app/sign-in/ and app/sign-up/; secret keys remain server-only. PostHog tracks client and server events: instrumentation-client.ts, lib/posthog-server.ts, and canonical event definitions in lib/analytics/events.ts. Lesson view/watch tracking and search-result context connect learner activity to analytics through components/lesson/lesson-view-tracker.tsx and lib/analytics/search-result-context.ts.
Infrastructure Dependencies
Node.js/npm run two JavaScript/TypeScript applications: the Next.js frontend/API and Sanity Studio. External managed services are Sanity (content, assets, context MCP), OpenAI (search-agent generation), Clerk (identity), PostHog (analytics), and YouTube as an ingestion source. Environment boundaries and required credentials are documented in .env.example.
Main entry points: lesson-video.tsx Lesson experience · layout.tsx App shell & routes · search-results.tsx Search results UI · fetch.ts Sanity delivery layer
Components 20
Next.js Learner App
Learner-facing web runtime and API.
- App shell & routes · Catalog, course, lesson, search, and auth pages.
app/layout.tsx - Access proxy · Protects routes and handles sessions.
proxy.ts - Course experience · Course hero, content, and catalog grid.
components/course/course-content.tsx - Lesson experience · Playback, curriculum, resources, and completion UI.
components/lesson/lesson-video.tsx - Video provider handling
lib/video.ts - Learner analytics · Tracks lesson and search activity.
lib/analytics/events.ts
Content Platform
Sanity delivery and authoring.
- Sanity delivery layer · Dedicated typed server-side content reads.
sanity/lib/fetch.ts - Generated content types
sanity.types.ts - Sanity Studio · Editorial authoring and content structure.
studio/sanity.config.ts - Course/lesson/video schema · Defines the course-to-module-to-lesson/video model.
studio/schemaTypes/documents/course.ts - Video ingestion · Parses providers and creates retrieval chunks.
studio/scripts/ingest/ingest-videos.mjs - Search context data · Checked-in retrieval/context corpus.
studio/scripts/context/vertex-search.ndjson
Search Pipeline
Grounded natural-language video search.
- Search results UI · Renders lesson/video results with timestamps.
components/search/search-results.tsx - Search API · Server credential boundary and search coordinator.
app/api/search/route.ts - Grounded search agent · MCP grounding, prompt, and response contracts.
lib/search/ground.ts
Managed Services
- Clerk
- Sanity
- OpenAI
- PostHog
- YouTube
Connections 23
- App shell & routes → Access proxy: requests pass through
- Access proxy → Clerk: sessions and protection
- App shell & routes → Course experience: renders course views
- App shell & routes → Lesson experience: renders lesson views
- Course experience → Sanity delivery layer: loads course content
- Lesson experience → Sanity delivery layer: loads lesson content
- Lesson experience → Video provider handling: resolves playback URL
- Sanity delivery layer → Generated content types: uses typed content
- Sanity delivery layer → Sanity: queries content
- Sanity Studio → Course/lesson/video schema: registers schemas
- Sanity Studio → Sanity: authors content
- Video ingestion → YouTube: imports provider videos
- Video ingestion → Search context data: produces chunks
- Video ingestion → Sanity: publishes video content
- Search results UI → Search API: posts natural-language query
- App shell & routes → Search results UI: renders search page
- Search API → Grounded search agent: coordinates search
- Grounded search agent → Sanity: grounds via Context MCP
- Grounded search agent → OpenAI: generates response
- Search results UI → Lesson experience: links to timestamped lessons
- Lesson experience → Learner analytics: records view/watch events
- Search results UI → Learner analytics: records result context
- Learner analytics → PostHog: sends events