Skip to main content

AI_COURSE_TODO

Based on my analysis of your codebase, here's a comprehensive assessment of the AI Course Generation system:

βœ… What's Working Correctly

Edge Function (supabase/functions/generate-course/index.ts:1-412)

  • Multiple action support: parse_prompt, generate_course, generate_content, update_content, generate_image, search_videos, generate_script, generate_slides
  • Multi-provider LLM support: OpenAI, Claude, Gemini, Grok with model version flexibility
  • Crawler integration: Firecrawl and Tavily for context gathering
  • Image generation: DALL-E, Stability AI, Gemini image generation
  • Warning system: Returns warnings array for non-blocking issues

AICourseCreator (Legacy Full Auto-Create)

  • Complete structure generation: Creates course + sections + lessons in one flow
  • Robust slug generation: buildUniqueSlug with conflict resolution and fallbacks
  • Image upload: Cloudinary integration for AI-generated images
  • Progress logging: Real-time feedback during generation and save
  • Error recovery: Handles duplicate slugs with automatic fallback

Database Schema

  • Proper relationships: Foreign keys with CASCADE delete
  • RLS policies: Admin permissions for course management
  • Indexing: Appropriate indexes for performance
  • Constraints: YouTube ID validation, position uniqueness

⚠️ Critical Issues Requiring Attention

  1. Field Name Inconsistency (High Priority)

Problem: Different components use different field names

ComponentField UsedSchema Field
EnhancedAICourseCreatorcourseCode❌ Not saved
CourseEditorcodeβœ… nova_tracks.code
AICourseCreatorcodeβœ… nova_tracks.code

Impact: EnhancedAICourseCreator:336 saves course_code which doesn't exist in schema

Fix Needed: // EnhancedAICourseCreator.jsx:323-330

const { data: track, error } = await supabase.from('nova_tracks').insert([{
title: formData.title,
description: formData.description,
category: formData.category, // ❌ This field doesn't exist in schema!
slug: formData.slug,
course_code: formData.courseCode, // ❌ Should be 'code'
status: 'draft'
}]).select().single();
  1. Missing Slug Conflict Handling (High Priority)

EnhancedAICourseCreator.jsx:318-342 has NO slug conflict resolution

Problem: // No unique slug validation before insert

await supabase.from('nova_tracks').insert([{ slug: formData.slug }])

// If slug exists, insert fails with no recovery

Comparison: AICourseCreator:168-206 has robust 4-attempt unique slug generation

Fix Needed: Copy buildUniqueSlug logic from AICourseCreator

  1. No JSON Import Feature (User Requirement)

Missing: Ability to paste course structure JSON

Current Flow: User can only use AI generation or manual entry Requested: Allow pasting complete course JSON structure

Implementation Gap:

  • No JSON schema validation
  • No parser for course structure JSON
  • No UI for JSON input mode
  1. Error Handling Gaps

EnhancedAICourseCreator.jsx:275-314

Issues:

try {
const { data: parseData } = await supabase.functions.invoke('generate-course', {
body: { action: 'parse_prompt', ... }
});
// ❌ No check if parseData has error field
// ❌ No handling of network failures
// ❌ No retry logic

const { data: courseData } = await supabase.functions.invoke('generate-course', {
body: { action: 'generate_course', ... }
});
// ❌ No validation that courseData.course exists
// ❌ Warnings are silently ignored
} catch (err) {
// ❌ Generic alert only, no detailed reporting
}
} catch (error) {
console.error('AI generation error:', error);
// ❌ No user-visible error message
// ❌ No specific error handling (API key missing, timeout, etc.)
}

Comparison: AICourseCreator:104-142 has:

  • Detailed error logging
  • User-visible error states
  • Warning display
  • getFunctionsErrorMessage utility
  1. Missing Schema Fields in EnhancedAICourseCreator

Not captured but exist in schema:

  • instructor_name
  • thumbnail_url (has upload UI but not saved)
  • trailer_youtube_id
  • estimated_hours
  • pricing_tier
  • total_lessons

Impact: Courses created via EnhancedAICourseCreator have incomplete metadata

  1. Character Count Mismatch
ComponentTitle MaxDescription Max
EnhancedAICourseCreator60300
CourseEditor100500

Problem: User creates course in EnhancedAICourseCreator (60 char limit), then can't edit in CourseEditor without confusion


πŸ”§ Compatibility Issues Between Flows

Manual vs AI Course Creation

Workflow Comparison:

FeatureEnhancedAICourseCreatorAICourseCreatorCourseEditor + ContentManager
Creates nova_tracksβœ…βœ…βœ…
Creates sectionsβŒβœ…βœ… (manual)
Creates lessonsβŒβœ…βœ… (manual)
Saves images❌ (preview only)βœ… (Cloudinary)βœ… (URL input)
Slug validationβŒβœ…βœ…
Field coverage50%80%100%

Breaking Incompatibility: // EnhancedAICourseCreator creates:

{ title, description, category, slug, course_code, status: 'draft' }

// Schema expects:

{ title, description, slug, code, status, instructor_name, thumbnail_url,
trailer_youtube_id, estimated_hours, pricing_tier, image_url }

// CourseEditor expects:

{ title, description, slug, code, instructor_name, thumbnail_url, ... }

🎯 User Experience Issues

  1. No Progress Feedback
  • EnhancedAICourseCreator shows generic "Generating..." spinner
  • No indication of which step (parsing β†’ generating β†’ saving)
  • Compare: AICourseCreator has real-time log stream
  1. Generated Content Not Previewed
  • AI generates course β†’ immediately populates form β†’ user must manually review
  • No "Review & Edit" step before committing
  1. Thumbnail Upload Abandoned
  • EnhancedAICourseCreator has drag-drop UI but doesn't save thumbnail to database
  • Preview works but data is lost on save
  1. No Validation Feedback
  • Form validation only triggers on save attempt
  • No real-time feedback as user types
  1. AI Configuration Hidden
  • Model selection collapsed in AI panel
  • Users may not know what model they're using

πŸ“‹ Recommendations

Priority 1: Critical Fixes

  1. Fix field mapping in EnhancedAICourseCreator:
  • Change category β†’ Remove (not in schema) or add to schema
  • Change course_code β†’ code
  • Add pricing_tier, status defaults
  1. Add slug conflict resolution:
  • Copy buildUniqueSlug from AICourseCreator
  • Add real-time slug availability check
  1. Implement error handling:
  • Show user-visible error messages
  • Handle specific error types (missing API keys, timeouts, RLS blocks)
  • Display warnings from Edge Function
  1. Save thumbnail data:
  • Upload to Cloudinary before course insert
  • Store URL in thumbnail_url field

Priority 2: User Experience

  1. Add JSON import feature:
  • Add "Import from JSON" button
  • Validate JSON structure against schema
  • Preview before import
  1. Unify character limits:
  • Use 100/500 everywhere or make configurable
  1. Add review step:
  • Show generated content in preview mode
  • Allow edits before final save
  • Option to regenerate specific sections
  1. Add progress indicators:
  • Step-by-step progress (Parsing β†’ Researching β†’ Generating β†’ Saving)
  • Estimated time remaining

Priority 3: Data Consistency

  1. Complete field coverage:
  • Add all schema fields to EnhancedAICourseCreator
  • Make optional fields clearly optional
  1. Standardize status workflow:
  • Define: draft β†’ coming-soon β†’ published
  • Explain differences to users

Would you like me to implement any of these fixes? I can start with the critical issues (slug conflict resolution, field mapping, error handling) or work on the JSON import feature you mentioned.

write this in a TODO and we shall pick up later .

⏺ Perfect! I've created a comprehensive TODO list with 12 items organized by priority:

Priority 1 - Critical Fixes (4 items):

  • Field mapping corrections (category/course_code issues)
  • Slug conflict resolution
  • Comprehensive error handling
  • Thumbnail upload fix

Priority 2 - User Experience (4 items):

  • JSON import feature
  • Unified character limits
  • Review step before saving
  • Progress indicators

Priority 3 - Data Consistency (4 items):

  • Missing schema fields
  • Status workflow standardization
  • Real-time validation
  • Warning display ⎿

TODOs

☐ Fix field mapping in EnhancedAICourseCreator (categoryβ†’remove, course_codeβ†’code) ☐ Add slug conflict resolution with buildUniqueSlug to EnhancedAICourseCreator ☐ Implement comprehensive error handling in EnhancedAICourseCreator (user-visible messages, API key errors, timeouts) ☐ Fix thumbnail upload to save to Cloudinary and store in thumbnail_url field ☐ Add JSON import feature with validation and preview ☐ Unify character limits across components (60β†’100 for title, 300β†’500 for description) ☐ Add review step before saving AI-generated courses ☐ Add step-by-step progress indicators to AI generation flow ☐ Add missing schema fields to EnhancedAICourseCreator (instructor_name, estimated_hours, pricing_tier, etc.) ☐ Standardize status workflow and document transitions (draftβ†’coming-soonβ†’published) ☐ Add real-time validation feedback as user types in forms ☐ Display AI generation warnings to users in EnhancedAICourseCreator