A comprehensive guide to the architecture, features, and innovations of our AI-powered educational platform.
Create comprehensive courses tailored to specific topics using advanced AI models.
Role-based access control with NextAuth v5 integration for secure user management.
Clean, responsive interface built with React 19, Next.js 15, and Tailwind CSS 4.
Organize and structure educational materials with intuitive interfaces.
Support for various document formats (PDF, DOCX) with automatic content extraction.
Seamless connections with AI services like Groq and LangChain for content generation.
Server-side API endpoints for handling data operations and business logic.
Type-safe database access with automated migrations and schema management.
Relational database with vector extension for AI embeddings and similarity search.
In-memory data store for caching and real-time operations.
Object storage for course materials and user uploads.
Latest React version with modern features and improved performance.
React framework with server components, app router, and optimized rendering.
Utility-first CSS framework for rapid UI development.
Animation library for creating smooth, interactive UI elements.
React renderer for Three.js, enabling 3D visuals like the interactive globe.
The platform leverages multiple AI technologies to deliver intelligent content generation and learning experiences.
AI-powered creation of comprehensive course structures based on topic, level, and desired outcomes.
Automated creation of detailed educational content in multiple formats (text, quizzes, MD).
Intelligent creation of assessment questions and answers based on course content.
Extraction and embedding of knowledge from uploaded documents for course integration.
Automatic summarization of educational materials for quick review.
Semantic similarity search for finding relevant course materials and knowledge.
A sophisticated event orchestration system for managing complex workflows, like course creation, with parallel processing and dependency management.
Intelligent parsing and semantic understanding of uploaded documents, extracting structured knowledge and embedding it for retrieval.
A beautiful Three.js-powered interactive globe component for visualizing global course distribution and user engagement.
AI-generated quizzes that adapt to course content and learning objectives, with intelligent question and distractor creation.
Tools for real-time collaboration, discussions, and peer learning within course modules.
User accounts with authentication, profile details, and role-based access.
Educational courses with metadata, settings, and relationship to modules.
Course modules of various types (VIDEO, TEXT, QUIZ, MD, CHART).
Assessment components with questions, options, and correct answers.
Relationship between users and courses, tracking progress and permissions.
NextAuth v5 integration
Password hashing with bcrypt
JWT-based session management
OAuth providers support
Email verification workflow
Role-based access control
Course-level permissions
Protected API routes
Middleware security checks
Session validation
The platform features a sophisticated Retrieval-Augmented Generation (RAG) pipeline that processes uploaded documents, extracts knowledge, and uses it to enhance AI-generated content.
Extracts text content from PDF files using PDFLoader from LangChain.
Processes DOCX/DOC files using Mammoth for content extraction.
Extracts content from PowerPoint (PPTX/PPT) files.
Parses CSV files with PapaParse for structured data extraction.
Direct processing of TXT and MD files for content integration.
Documents are summarized using AI to extract key concepts and knowledge.
Summaries are embedded into high-dimensional vectors for semantic retrieval.
Embeddings stored in Postgres with vector extension for efficient similarity search.
Multiple documents processed simultaneously for efficient course creation.
Robust retry mechanisms ensure reliable processing of all documents.
Course creators upload documents (PDF, DOCX, etc.) that contain relevant educational content.
The system extracts raw text from documents using format-specific loaders.
AI generates comprehensive summaries capturing key concepts and knowledge from each document.
Summaries are transformed into vector embeddings using AI embedding models.
Embeddings and summaries are stored in PostgreSQL with vector extension for retrieval.
AI-generated course content is enhanced with knowledge from these documents via similarity search.
Module generation, quiz creation, and content suggestions leverage document knowledge.
Course modules pull relevant context from document embeddings
Quiz questions are generated based on most similar document sections
Video recommendations match most relevant document content
AI completions for students are contextually enhanced
Parallel processing with Promise.all for multiple documents
PostgreSQL vector similarity using cosine distance (<=> operator)
AI-optimized summary generation with retry mechanisms
Automatic cleanup of temporary files after processing
A custom-built asynchronous workflow engine that manages complex operations with dependencies. The system orchestrates parallel and sequential tasks during course creation and other workflows.
Uses in-degree tracking to process events in dependency order. Tasks with no dependencies execute first, followed by tasks whose dependencies have completed.
Tasks at the same dependency level are executed concurrently using Promise.all(), optimizing performance during resource-intensive operations.
Error handling ensures the system continues execution even when individual tasks fail, tracking error states for later inspection and recovery.
Each event maintains its own result state, allowing downstream tasks to access outputs from previously executed dependencies.
Sample Event Orchestration Graph
// Define the event graph for course creation workflow adjList.set(authEvent, [validateDataEvent]); adjList.set(validateDataEvent, [createDbCourseEvent]); adjList.set(createDbCourseEvent, [ createUserCourseEvent, // Executes in parallel uploadNotesEvent, // Executes in parallel createAiModulesEvent // Executes in parallel ]); adjList.set(createAiModulesEvent, [uploadModulesToDBEvent]); adjList.set(uploadModulesToDBEvent, [sendNotificationEvent]);
The platform leverages the PostgreSQL vector extension to store and query high-dimensional embeddings for semantic search capabilities without requiring a dedicated vector database.
Uses 768-dimensional vectors from Google's text-embedding-004 model, optimized for semantic similarity search in educational content.
Stored as a custom PostgreSQL vector type in the CourseAttachment model, enabling direct database-level vector operations.
Implements cosine similarity using the PostgreSQL <=> operator for efficient semantic matching between queries and stored embeddings.
Automatically installs and configures the vector extension during application setup, simplifying deployment and database management.
Vector Similarity Query Example
// Find documents most similar to a query embedding const result = await prisma.$queryRaw` SELECT "name", "url", "summary", 1 - ("summaryEmbedding" <=> ${embedding}::vector) AS CosineSimilarity FROM "CourseAttachment" ORDER BY CosineSimilarity DESC LIMIT 10 ` as { name: string, url: string, summary: string, CosineSimilarity: number }[];
The platform integrates multiple large language models and AI services through a unified API abstraction, enabling specialized models for different content generation tasks.
Real-time content streaming provides immediate feedback to users during generation of long-form educational content.
// Streaming text generation example const stream = streamText({ model: groq("llama3-70b-8192"), system: `You are an expert educational content creator.`, prompt: `Create notes for: ${module.name}`, temperature: 0.7, maxTokens: 6000, }); // Returns a streaming response return stream.toDataStreamResponse();
Uses JSON schema validation to ensure AI outputs match expected data structures for quizzes, course modules, and other structured content.
// Structured object generation with validation const { object: quizData } = await generateObject({ model: groq("llama3-70b-8192"), schema: QuizSchema, // Zod schema for validation system: `Create a comprehensive quiz`, prompt: `Create quiz for: ${module.name}`, temperature: 0.2, maxTokens: 4000, });
The platform implements robust error handling and recovery mechanisms to ensure reliability during complex operations involving external AI services and file processing.
AI service calls implement exponential backoff with configurable retry limits to handle transient failures and rate limiting from external APIs.
// Retry with exponential backoff while (attempts < maxAttempts) { try { return await aiServiceCall(); } catch (error) { attempts++; if (attempts < maxAttempts) { const delayMs = Math.pow(2, attempts) * 1000; await new Promise(resolve => setTimeout(resolve, delayMs) ); } } }
Temporary file handling with guaranteed cleanup through finally blocks and delete hooks, preventing resource leaks during document processing.
// Resource cleanup pattern const deleteFile = async () => { try { await rm(filePath); console.log(`Deleted ${filePath}`); } catch (error) { console.error(`Error deleting ${filePath}`); } }; try { // Process file... } finally { // Always execute cleanup await deleteFile(); }
Graceful degradation when AI services are unavailable or return unexpected results
Parameter validation using Zod schemas before expensive operations
Content length truncation to prevent token limit errors in AI models
Transactional database operations to maintain data consistency
The platform employs multiple strategies to ensure optimal performance and user experience.
Leverages Next.js server components for improved initial load performance.
Content delivery network integration for global low-latency access.
Batched and parallel API requests for efficient data fetching.
Automatic image resizing, format conversion, and lazy loading.
Dynamic imports and component lazy loading to reduce bundle size.
AI content is streamed to improve perceived performance.
Built with ♥ using Next.js, React, and Tailwind CSS