Skip to content

adarsh-jha-dev/online-learning-platform

Repository files navigation

πŸŽ“ LearnAI - AI-Powered Online Learning Platform

Next.js

Democratizing Education Through AI - Create comprehensive courses in minutes, not weeks.

LearnAI is an innovative e-learning platform that leverages Google's Gemini 2.0 Flash AI to automate course creation, content generation, and resource curation. Built as a final year project (7th & 8th Semester) for the Department of Computer Science and Engineering.

🌐 Live Demo: https://online-learning-platform-snowy.vercel.app


πŸ“‹ Table of Contents


✨ Features

🎯 For Course Creators

  • AI-Powered Course Generation: Generate complete course structures with chapters, topics, and durations in seconds
  • Automated Content Creation: AI generates detailed, HTML-formatted content for each chapter
  • Intelligent Video Integration: Automatically discovers and embeds relevant YouTube videos
  • Custom Banner Generation: AI-generated course banner images
  • Course Management: Edit, publish, and manage multiple courses from a unified dashboard

πŸ“š For Learners

  • Course Discovery: Browse and search through available courses by category and difficulty level
  • One-Click Enrollment: Instant enrollment without payment barriers
  • Progress Tracking: Real-time progress calculation with visual indicators
  • Chapter Completion: Mark chapters as complete and track learning journey
  • Integrated Video Learning: Watch curated YouTube videos within the platform
  • Responsive Design: Seamless experience across desktop, tablet, and mobile devices

πŸ” Platform Features

  • Secure Authentication: Email/password and OAuth (Google, GitHub) via Clerk
  • User Profiles: Personalized dashboards with enrolled courses
  • Search & Filter: Find courses by name, category, or difficulty level
  • Dark Theme UI: Modern, accessible interface built with Shadcn/ui
  • Serverless Architecture: Auto-scaling, cost-effective deployment

πŸ›  Tech Stack

Frontend

  • Framework: Next.js 15 (App Router)
  • UI Library: React 18
  • Styling: Tailwind CSS 3.4
  • Component Library: Shadcn/ui
  • Icons: Lucide React
  • Notifications: Sonner
  • Video Player: React YouTube

Backend

  • Runtime: Node.js (Next.js API Routes)
  • Database: Neon PostgreSQL (Serverless)
  • ORM: Drizzle ORM
  • Authentication: Clerk

AI & Integrations

  • AI Model: Google Gemini 2.0 Flash
  • Video API: YouTube Data API v3
  • Image Generation: AI Guru Lab API key
  • HTTP Client: Axios

DevOps

  • Deployment: Vercel
  • Version Control: Git & GitHub
  • Package Manager: npm
  • Language: TypeScript

πŸ— System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Frontend Layer                        β”‚
β”‚       Next.js 15 + React 18 + Tailwind CSS              β”‚
β”‚              Clerk Authentication                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   API Layer                              β”‚
β”‚         Next.js API Routes (Serverless)                 β”‚
β”‚           Server Actions & Components                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚            β”‚            β”‚            β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   AI Layer   β”‚ β”‚Database β”‚ β”‚YouTube  β”‚ β”‚   Image   β”‚
β”‚  Gemini 2.0  β”‚ β”‚Neon DB  β”‚ β”‚API v3   β”‚ β”‚    Gen    β”‚
β”‚    Flash     β”‚ β”‚Drizzle  β”‚ β”‚         β”‚ β”‚           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow

Course Creation Flow:

User Input β†’ AI Prompt β†’ Gemini API β†’ Parse JSON β†’
Generate Banner β†’ Store in DB β†’ Display Preview β†’
Generate Content β†’ Fetch Videos β†’ Publish Course

Learning Flow:

Browse Courses β†’ View Details β†’ Enroll β†’ Access Content β†’
Watch Videos β†’ Complete Chapters β†’ Track Progress β†’ Course Completion

πŸš€ Getting Started

Prerequisites

  • Node.js 18.x or higher
  • npm or yarn
  • PostgreSQL database (or Neon account)
  • API Keys for:
    • Google Gemini AI
    • YouTube Data API v3
    • Clerk Authentication
    • AI Guru Lab API key (for image generation)

Installation

  1. Clone the repository
git clone https://github.com/adarsh-jha-dev/online-learning-platform.git
cd online-learning-platform
  1. Install dependencies
npm install
# or
yarn install
  1. Set up environment variables
cp .env.example .env

Edit .env with your API keys (see Environment Variables)

  1. Set up the database
# Generate database schema
npm run db:generate

# Push schema to database
npm run db:push
  1. Run the development server
npm run dev
  1. Open your browser
Navigate to http://localhost:3000

πŸ”‘ Environment Variables

Create a .env file in the root directory:

# Database
DATABASE_URL="postgresql://username:password@host/database?sslmode=require"

# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_..."
CLERK_SECRET_KEY="sk_test_..."
NEXT_PUBLIC_CLERK_SIGN_IN_URL="/sign-in"
NEXT_PUBLIC_CLERK_SIGN_UP_URL="/sign-up"

# Google Gemini AI
NEXT_PUBLIC_GEMINI_API_KEY="AIza..."

# YouTube Data API
NEXT_PUBLIC_YOUTUBE_API_KEY="AIza..."

# Image Generation API Key
AI_GURU_LAB_API="ask..."

# App URL
NEXT_PUBLIC_APP_URL="http://localhost:3000"

Getting API Keys

  1. Neon Database

    • Sign up at neon.tech
    • Create a new project
    • Copy the connection string
  2. Clerk Authentication

    • Sign up at clerk.com
    • Create a new application
    • Copy publishable and secret keys
  3. Google Gemini AI

  4. YouTube Data API

    • Go to Google Cloud Console
    • Create a new project
    • Enable YouTube Data API v3
    • Create credentials (API Key)
  5. AI Guru Lab API

    • Go to AI Guru Lab Dashboard
    • Create an account if you don't have one
    • Copy the API key from sidebar
    • You'll get free 20 credits (1 Credit = 1 Image)

πŸ“ Project Structure

online-learning-platform/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ (auth)/
β”‚   β”‚   β”œβ”€β”€ sign-in/[[...sign-in]]/page.jsx
β”‚   β”‚   └── sign-up/[[...sign-up]]/page.jsx
β”‚   β”œβ”€β”€ (routes)/
β”‚   β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”‚   β”œβ”€β”€ _components/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ CourseCard.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ SideNav.jsx
β”‚   β”‚   β”‚   β”‚   └── WelcomeBanner.jsx
β”‚   β”‚   β”‚   └── page.jsx
β”‚   β”‚   β”œβ”€β”€ create-course/
β”‚   β”‚   β”‚   β”œβ”€β”€ [courseId]/
β”‚   β”‚   β”‚   β”‚   └── page.jsx
β”‚   β”‚   β”‚   └── page.jsx
β”‚   β”‚   β”œβ”€β”€ course/
β”‚   β”‚   β”‚   └── [courseId]/
β”‚   β”‚   β”‚       β”œβ”€β”€ [chapterId]/
β”‚   β”‚   β”‚       β”‚   └── page.jsx
β”‚   β”‚   β”‚       └── page.jsx
β”‚   β”‚   └── explore/
β”‚   β”‚       └── page.jsx
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── generate-course/
β”‚   β”‚       └── route.js
β”‚   β”œβ”€β”€ globals.css
β”‚   β”œβ”€β”€ layout.jsx
β”‚   └── page.jsx
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ ui/
β”‚   β”‚   β”œβ”€β”€ button.jsx
β”‚   β”‚   β”œβ”€β”€ card.jsx
β”‚   β”‚   β”œβ”€β”€ input.jsx
β”‚   β”‚   β”œβ”€β”€ progress.jsx
β”‚   β”‚   └── ...
β”‚   └── custom/
β”‚       β”œβ”€β”€ Header.jsx
β”‚       └── LoadingSpinner.jsx
β”œβ”€β”€ configs/
β”‚   β”œβ”€β”€ AiModel.jsx          # Gemini AI configuration
β”‚   β”œβ”€β”€ db.jsx                # Database connection
β”‚   β”œβ”€β”€ schema.jsx            # Database schema
β”‚   └── service.jsx           # External API services
β”œβ”€β”€ lib/
β”‚   └── utils.js              # Utility functions
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ logo.svg
β”‚   └── ...
β”œβ”€β”€ drizzle/
β”‚   └── migrations/           # Database migrations
β”œβ”€β”€ .env.local                # Environment variables (not in repo)
β”œβ”€β”€ .gitignore
β”œβ”€β”€ next.config.js
β”œβ”€β”€ package.json
β”œβ”€β”€ tailwind.config.js
β”œβ”€β”€ tsconfig.json
└── README.md

πŸ“– Usage Guide

Creating Your First Course

  1. Sign Up/Login

    • Click "Get Started" on the homepage
    • Sign up with email or OAuth (Google/GitHub)
  2. Navigate to Dashboard

    • Click "Create New Course" button
  3. Fill Course Details

    - Course Topic: e.g., "Introduction to Machine Learning"
    - Description: Brief overview of the course
    - Category: Select from dropdown (Programming, Data Science, etc.)
    - Difficulty Level: Beginner / Intermediate / Advanced
    - Number of Chapters: 5-15 recommended
    - Include Videos: Yes/No
    
  4. Generate Course Layout

    • Click "Generate" button
    • AI will create chapter structure in ~5 seconds
    • Review the generated chapters and topics
  5. Generate Content

    • Click "Generate Content" for each chapter
    • AI creates detailed content with examples
    • YouTube videos are automatically fetched
    • Takes ~3-5 seconds per chapter
  6. Publish Course

    • Review all content
    • Click "Publish Course"
    • Course is now available for enrollment

Enrolling and Learning

  1. Browse Courses

    • Go to "Explore" section
    • Filter by category or difficulty
    • Use search bar for specific topics
  2. View Course Details

    • Click on any course card
    • See chapters, topics, and duration
    • Watch course preview
  3. Enroll in Course

    • Click "Enroll Now" button
    • Course added to "My Learning"
  4. Start Learning

    • Go to "My Learning" section
    • Click on enrolled course
    • Select chapter to study
    • Watch videos and read content
    • Mark chapters as complete
  5. Track Progress

    • View progress percentage on course card
    • See completion status for each chapter
    • Celebrate when you reach 100%!

πŸ”Œ API Documentation

Course Generation

Endpoint: POST /api/generate-course

Request Body:

{
  "topic": "Introduction to Python",
  "description": "Learn Python basics",
  "level": "Beginner",
  "noOfChapters": 10,
  "category": "Programming",
  "includeVideo": true
}

Response:

{
  "success": true,
  "course": {
    "courseName": "Introduction to Python Programming",
    "description": "Complete guide for beginners",
    "chapters": [
      {
        "chapterName": "Getting Started with Python",
        "about": "Introduction to Python syntax",
        "duration": "45 minutes",
        "topics": ["Variables", "Data Types", "Operators"]
      }
    ]
  }
}

Chapter Content Generation

Endpoint: POST /api/generate-content

Request Body:

{
  "chapterName": "Getting Started with Python",
  "topics": ["Variables", "Data Types", "Operators"]
}

Response:

{
  "success": true,
  "content": "<h1>Getting Started with Python</h1><p>...</p>",
  "videos": [
    {
      "videoId": "xyz123",
      "title": "Python Variables Explained",
      "thumbnail": "https://..."
    }
  ]
}

πŸ—„ Database Schema

Users Table

CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  email VARCHAR(255) UNIQUE NOT NULL,
  name VARCHAR(255) NOT NULL,
  image_url TEXT,
  created_at TIMESTAMP DEFAULT NOW()
);

Courses Table

CREATE TABLE courses (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name VARCHAR(255) NOT NULL,
  description TEXT,
  category VARCHAR(100),
  level VARCHAR(50) NOT NULL,
  course_json JSONB NOT NULL,
  created_by VARCHAR(255) NOT NULL,
  banner TEXT,
  publish BOOLEAN DEFAULT false,
  created_at TIMESTAMP DEFAULT NOW()
);

course_json structure:

{
  "courseName": "string",
  "description": "string",
  "chapters": [
    {
      "chapterName": "string",
      "about": "string",
      "duration": "string",
      "topics": ["string"],
      "content": "string (HTML)",
      "videoId": "string"
    }
  ]
}

Enrollments Table

CREATE TABLE enrollments (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID REFERENCES users(id) ON DELETE CASCADE,
  course_id UUID REFERENCES courses(id) ON DELETE CASCADE,
  completed_chapters INTEGER[] DEFAULT '{}',
  enrolled_at TIMESTAMP DEFAULT NOW(),
  UNIQUE(user_id, course_id)
);

Relationships:

  • One user can create many courses (1:N)
  • One user can enroll in many courses (N:M via enrollments)
  • One course can have many enrollments (1:N)

🚧 Roadmap

Version 1.0

  • Complete authentication system with Clerk
  • AI course generation pipeline
  • Content creation and video integration
  • Database schema and ORM setup
  • Enrollment and progress tracking
  • Responsive UI with dark theme
  • Search and exploration features

Future Enhancements

  • Admin Dashboard
  • Quiz generation for knowledge assessment
  • Discussion forums for peer interaction
  • Advanced analytics dashboard for instructors
  • Certificate generation upon course completion

About

This is the codebase for our final year project - An AI powered online learning platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •