How Lessons Are Generated
Every lesson in Sunschool is dynamically generated using AI to match the learner’s grade level, subject preferences, and learning history.Lesson Generation Flow
Lesson generation includes automatic retry with exponential backoff to ensure reliable content delivery.
Enhanced Lesson Service
Lessons are generated using thegenerateEnhancedLesson function from enhanced-lesson-service.ts:
Grade-Specific Content
Sunschool automatically adjusts content complexity, vocabulary, and structure based on grade level.Grade Level Ranges
K-2 (Early Elementary)
K-2 (Early Elementary)
Word Limits: 75 words total
- Introduction: 15 words max
- Key concepts: 20 words max
- Examples: 20 words max
- Practice: 15 words max
- Summary: 5 words max
3-4 (Middle Elementary)
3-4 (Middle Elementary)
Word Limits: 200 words total
- Introduction: 30 words
- Key concepts: 70 words
- Examples: 50 words
- Practice: 35 words
- Summary: 15 words
5-6 (Upper Elementary)
5-6 (Upper Elementary)
Word Limits: 400 words total
- Introduction: 60 words
- Key concepts: 160 words
- Examples: 100 words
- Practice: 60 words
- Summary: 20 words
7-8 (Middle School)
7-8 (Middle School)
Word Limits: 700 words total
- Introduction: 100 words
- Key concepts: 280 words
- Examples: 170 words
- Practice: 100 words
- Summary: 50 words
9+ (High School)
9+ (High School)
Word Limits: 1200 words total
- Introduction: 150 words
- Key concepts: 500 words
- Examples: 300 words
- Practice: 150 words
- Summary: 100 words
Adaptive Difficulty
Lessons can be generated at three difficulty levels:- Beginner
- Intermediate
- Advanced
- Foundational concepts
- Step-by-step explanations
- Heavy use of concrete examples
- Visual metaphors (e.g., pizza slices for fractions)
Lesson Structure
Every enhanced lesson follows a consistent 5-section structure:1. Introduction
- Purpose: Hook learners and connect to prior knowledge
- Content: Engaging opener, relatable scenario
- Visual: Featured image related to topic
2. Key Concepts
- Purpose: Core teaching content
- Content: Definitions, explanations, vocabulary
- Formatting: Bold for new terms, bullet points for lists
3. Examples
- Purpose: Demonstrate concepts in action
- Content: Worked examples, step-by-step solutions
- Visual Metaphor: Consistent throughout (e.g., all fraction examples use pizza)
4. Practice
- Purpose: Learner engagement and application
- Content: Activities, prompts, thought exercises
- Interactive: Encourages active learning
5. Summary
- Purpose: Reinforce key takeaways
- Content: Brief recap of ONLY what was covered
- Scope Discipline: Never promises content not delivered in lesson
SVG Illustrations
Lessons include custom educational SVG illustrations generated specifically for the content.Image Generation
Image Requirements
Viewing a Lesson
When learners tap their active lesson:Lesson Display Features
- Scrollable content with all 5 sections
- Rendered markdown with proper formatting
- Embedded images inline with text
- Quiz prompt at the bottom
- “Let’s Go!” button to start the quiz
Lesson Validation
Before lessons are shown to learners, they go through validation:Quality Guarantees:
- Minimum 2 questions per lesson
- Proper section structure
- Grade-appropriate vocabulary
- Consistent visual metaphors