Skip to main content

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 the generateEnhancedLesson function from enhanced-lesson-service.ts:

Grade-Specific Content

Sunschool automatically adjusts content complexity, vocabulary, and structure based on grade level.

Grade Level Ranges

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
Sentence Length: Maximum 5 words per sentenceReading Level: Very simple vocabulary, short sentences, concrete examples
Word Limits: 200 words total
  • Introduction: 30 words
  • Key concepts: 70 words
  • Examples: 50 words
  • Practice: 35 words
  • Summary: 15 words
Sentence Length: Maximum 8 words per sentenceReading Level: Simple vocabulary with some academic terms introduced
Word Limits: 400 words total
  • Introduction: 60 words
  • Key concepts: 160 words
  • Examples: 100 words
  • Practice: 60 words
  • Summary: 20 words
Sentence Length: Maximum 12 words per sentenceReading Level: More complex vocabulary, longer explanations
Word Limits: 700 words total
  • Introduction: 100 words
  • Key concepts: 280 words
  • Examples: 170 words
  • Practice: 100 words
  • Summary: 50 words
Sentence Length: Maximum 18 words per sentenceReading Level: Academic vocabulary, abstract concepts
Word Limits: 1200 words total
  • Introduction: 150 words
  • Key concepts: 500 words
  • Examples: 300 words
  • Practice: 150 words
  • Summary: 100 words
Sentence Length: Maximum 25 words per sentenceReading Level: Advanced vocabulary, complex reasoning

Adaptive Difficulty

Lessons can be generated at three difficulty levels:
  • 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

All lesson images follow strict rules:
  • NO text, letters, or numbers in images
  • NO mathematical notation or symbols
  • Simple, clean shapes and objects only
  • Bright, friendly colors appropriate for grade level
  • White or light background

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

Next Steps

Take a Quiz

Learn how quizzes test lesson comprehension

Earn Points

Discover how completing lessons earns points