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
- Field Name Inconsistency (High Priority)
Problem: Different components use different field names
| Component | Field Used | Schema Field |
|---|---|---|
| EnhancedAICourseCreator | courseCode | β Not saved |
| CourseEditor | code | β nova_tracks.code |
| AICourseCreator | code | β 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();
- 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
- 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
- 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
- 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
- Character Count Mismatch
| Component | Title Max | Description Max |
|---|---|---|
| EnhancedAICourseCreator | 60 | 300 |
| CourseEditor | 100 | 500 |
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:
| Feature | EnhancedAICourseCreator | AICourseCreator | CourseEditor + ContentManager |
|---|---|---|---|
| Creates nova_tracks | β | β | β |
| Creates sections | β | β | β (manual) |
| Creates lessons | β | β | β (manual) |
| Saves images | β (preview only) | β (Cloudinary) | β (URL input) |
| Slug validation | β | β | β |
| Field coverage | 50% | 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
- No Progress Feedback
- EnhancedAICourseCreator shows generic "Generating..." spinner
- No indication of which step (parsing β generating β saving)
- Compare: AICourseCreator has real-time log stream
- Generated Content Not Previewed
- AI generates course β immediately populates form β user must manually review
- No "Review & Edit" step before committing
- Thumbnail Upload Abandoned
- EnhancedAICourseCreator has drag-drop UI but doesn't save thumbnail to database
- Preview works but data is lost on save
- No Validation Feedback
- Form validation only triggers on save attempt
- No real-time feedback as user types
- AI Configuration Hidden
- Model selection collapsed in AI panel
- Users may not know what model they're using
π Recommendations
Priority 1: Critical Fixes
- Fix field mapping in EnhancedAICourseCreator:
- Change category β Remove (not in schema) or add to schema
- Change course_code β code
- Add pricing_tier, status defaults
- Add slug conflict resolution:
- Copy buildUniqueSlug from AICourseCreator
- Add real-time slug availability check
- Implement error handling:
- Show user-visible error messages
- Handle specific error types (missing API keys, timeouts, RLS blocks)
- Display warnings from Edge Function
- Save thumbnail data:
- Upload to Cloudinary before course insert
- Store URL in thumbnail_url field
Priority 2: User Experience
- Add JSON import feature:
- Add "Import from JSON" button
- Validate JSON structure against schema
- Preview before import
- Unify character limits:
- Use 100/500 everywhere or make configurable
- Add review step:
- Show generated content in preview mode
- Allow edits before final save
- Option to regenerate specific sections
- Add progress indicators:
- Step-by-step progress (Parsing β Researching β Generating β Saving)
- Estimated time remaining
Priority 3: Data Consistency
- Complete field coverage:
- Add all schema fields to EnhancedAICourseCreator
- Make optional fields clearly optional
- 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