feat: Visual Image System - Schema, Storage, and Component Updates#225
feat: Visual Image System - Schema, Storage, and Component Updates#225
Conversation
Lesson Stage System Image Opportunities (PR #219)After reviewing the Lesson Stage System components, here are additional image enhancement opportunities: Stage Progress Bar (
|
| Stage | Current | Could Add |
|---|---|---|
| Learn | Number/✓ | Lightbulb/book opening illustration |
| Read | Number/✓ | Open book with text illustration |
| Practice | Number/✓ | Dumbbell/exercise illustration |
| Review | Number/✓ | Brain/flashcards illustration |
| Assess | Number/✓ | Trophy/clipboard illustration |
LessonStageViewer.tsx
-
Lesson Context Card (lines 357-376)
- Lesson thumbnail image placeholder
- Language-themed decorative backgrounds
-
Stage Header (lines 378-413)
- Stage-specific decorative illustration in corner
- Language-themed gradient with pattern overlay
Stage Content Components
| Component | Current Icon | Image Opportunity |
|---|---|---|
| LearnStageContent | ProgressRing | Grammar concept illustrations |
| PracticeStageContent | Dumbbell |
"Training ground" hero illustration |
| ReviewStageContent | BookMarked |
Flashcard deck/memory illustration |
| AssessStageContent | CheckCircle/XCircle |
Success celebration / encouragement illustrations |
Database Fields (already in migration)
The lesson_stages table could be extended with:
ALTER TABLE lesson_stages
ADD COLUMN IF NOT EXISTS icon_image_url TEXT,
ADD COLUMN IF NOT EXISTS background_image_url TEXT;These could be added in a follow-up PR after the base image system is in place.
🎨 ComfyUI Prompt TemplatesComplete prompt structures for Flux Schnell and SDXL for all image types. Generation Settings
1. Course Covers (1024x640 → 400x240)Spanish 🇪🇸Flux: SDXL: Latin 🏛️Flux: SDXL: Icelandic 🇮🇸Flux: SDXL: 2. Course Heroes (2048x680 → 1200x400)Spanish 🇪🇸Flux: SDXL: Latin 🏛️Flux: SDXL: Icelandic 🇮🇸Flux: SDXL: 3. Lesson Thumbnails (768x512 → 300x200)Flux (template): SDXL (template): Example - Spanish Greetings Lesson: Flux: SDXL: 4. Flashcard Deck Covers (768x512 → 300x200)Flux: SDXL: Spanish Vocabulary Deck: Latin Grammar Deck: Icelandic Runes Deck: 5. AI Tutor Avatars (512x512 → 200x200)Flux: SDXL: Example - Spanish Tutor "María": Example - Latin Tutor "Marcus": Example - Icelandic Tutor "Sigrid": 6. Word of the Day Illustrations (1024x768 → 400x300)Flux: SDXL: Example - Spanish "Mariposa" (butterfly): Example - Latin "Aqua" (water): 7. Lesson Stage Icons (256x256)For the 5-stage system (Learn → Read → Practice → Review → Assess): Learn StageFlux: SDXL: Read StageFlux: SDXL: Practice StageFlux: SDXL: Review StageFlux: SDXL: Assess StageFlux: SDXL: 8. Stage Content IllustrationsGrammar Concept Cards (512x384)Flux: SDXL: Training Ground (Practice Stage Hero) (1024x512)Flux: Assessment ResultsSuccess Illustration (512x512): Encouragement Illustration (512x512): 🔧 Batch Generation Tips
📁 Output Organization |
…ates - Add database migration for image fields on courses, lessons, flashcard decks, user profiles, library texts, and AI tutors - Create central image_assets table for generation tracking - Add Supabase storage bucket setup script for image hosting - Update CourseCard with cover image support and language-themed gradients - Update CourseHero with hero image background and gradient overlays - Add comprehensive image generation documentation Schema changes: - courses: cover_image_url, hero_image_url, theme_color, language - lessons: thumbnail_image_url, hero_image_url, icon_type - flashcard_decks: cover_image_url, theme_color, language - user_profiles: avatar_url, display_name - library_texts/readings: cover_image_url, thumbnail_image_url - ai_tutors: new table with avatar_url Storage buckets: - course-images, lesson-images, deck-images, profile-images - reading-images, tutor-images, generated-images 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
a10ec65 to
29cd2de
Compare
PR Review: Visual Image SystemOverall AssessmentThis is a well-designed and comprehensive feature that adds visual image support across the Interlinear app. The implementation is thoughtful, with good documentation and fallback strategies. However, there are several important issues that should be addressed before merging. 🔴 Critical Issues1. Missing Database Fields in Query (High Priority)Location: The page queries courses but doesn't fetch the new Fix needed: const { data: courses, error: coursesError } = await supabase
.from('courses')
.select(`
id,
title,
description,
language,
difficulty_level,
cover_image_url, // ADD THIS
// ... rest of fields
`)Impact: Without this, the new image functionality won't work at all on the courses listing page. 2. Next.js Image Configuration Missing placehold.coLocation: The migration and documentation reference Fix needed: images: {
remotePatterns: [
// ... existing patterns
{
protocol: 'https',
hostname: 'placehold.co',
},
],
}Impact: Placeholder images will fail to load during development/testing. 🟡 High Priority Issues3. Unsafe Non-Null Assertion in Storage ScriptLocation: Using the Current code: const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!
const supabaseServiceKey = process.env.SUPABASE_SERVICE_ROLE_KEY!The subsequent check on line 15 helps, but it would be cleaner to handle this more gracefully or move the check before usage. 4. Missing TypeScript Types for Database ChangesThe migration adds new fields to multiple tables, but there's no indication that TypeScript types have been updated. This could lead to type errors when developers try to use the new fields. Recommendation: Generate updated types with: npx supabase gen types typescript --local > lib/supabase/database.types.ts5. Pattern ID Collision PotentialLocation: Using Current code: <pattern id={`pattern-${id}`} ...>Fix: Use a more unique identifier: <pattern id={`pattern-course-${id}`} ...>🟢 Code Quality & Best Practices6. Excellent Fallback StrategyThe language-themed gradient fallbacks are well-designed and provide a great UX when images aren't available. The approach is consistent across both 7. Good Image OptimizationUsing Next.js
8. Documentation QualityThe Minor suggestion: Add a troubleshooting section for common Next.js Image errors (which are notoriously cryptic). 🔵 Security & Performance9. Storage Security - Good RLS DesignThe RLS policies are well-designed:
Note: The storage policy SQL in the script (lines 131-151) needs to be run manually. Consider adding this to the migration or providing a separate SQL file. 10. File Size LimitsThe file size limits are reasonable and appropriate for each bucket type. Good to see 10MB limit for AI-generated images which can be larger. 11. MIME Type RestrictionsGood security practice to restrict allowed MIME types. However, consider adding 🔵 Database Design12.
|
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Parent LessonViewer already renders Navigation, so LessonStageViewer doesn't need its own. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review: Visual Image SystemThis PR introduces a comprehensive image system with database schema changes, storage infrastructure, component updates, and documentation. Well-structured implementation overall. Strengths
Critical Issues1. TypeScript Type Mismatch (HIGH PRIORITY)Location: components/courses/CourseCard.tsx:19-20, CourseHero.tsx:16-17 The Course interface in lib/services/course.ts does not include cover_image_url, hero_image_url, or theme_color fields that the components expect. Fix: Add these optional fields to the Course interface in lib/services/course.ts 2. SVG Pattern ID Collisions (BUG)CourseCard.tsx:102 uses dynamic pattern IDs and CourseHero.tsx:92 uses fixed hero-pattern ID. Multiple component instances will cause SVG conflicts. Fix: Use React useId() hook for unique pattern identifiers. 3. Missing placehold.co in next.config.tsThe migration uses placehold.co for placeholder images but it is not in remotePatterns. Fix: Add placehold.co to next.config.ts images.remotePatterns array. Security Concerns
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentWell-architected PR with excellent documentation. Main blockers are TypeScript type mismatches and SVG ID collisions. Ready to merge after high-priority fixes applied. Status: Approve with changes requested |
PR Review: Visual Image SystemSummaryComprehensive and well-designed feature adding image support across the platform. Excellent documentation and thoughtful architecture. Overall high-quality work with some critical issues to address. Critical Issues1. Missing placehold.co in Next.js ConfigThe migrations get_placeholder_image() uses placehold.co but its not in next.config.ts remotePatterns. Add it to avoid image load failures. 2. Storage RLS Policies Not CreatedCRITICAL SECURITY: Script only prints policies to console, doesnt create them. Buckets will lack security policies. Either programmatically create or add prominent warning. 3. Storage RLS Policy Field ReferencePolicies use auth.uid() = owner but Supabase storage uses owner_id. Verify or fix to: auth.uid()::text = owner_id 4. Migration Function DependencyReferences update_updated_at_column() without existence check. Will fail if function doesnt exist from prior migration. High Priority
Positives
Must Fix Before Merge
Overall: 8.5/10Excellent work! Main concerns are security policy automation and config. Once critical issues addressed, production-ready. Great architecture and implementation! |
Summary
Comprehensive visual image system for the Interlinear app, adding support for AI-generated images across all content types.
What's Included
Database Schema (
20260107_visual_image_system.sql)image_assetstable for generation tracking and metadataai_tutorstable with avatar supportget_placeholder_image()for developmentStorage Infrastructure (
setup-storage-buckets.ts)Component Updates
CourseCard.tsx- Cover image support with language-themed gradient fallbacksCourseHero.tsx- Hero image background with gradient overlays for text readabilityDocumentation (
docs/image-generation-guide.md)Schema Changes
Language Theme Fallbacks
Related Work
Test Plan
npx tsx scripts/setup-storage-buckets.tsto create buckets🤖 Generated with Claude Code