๐Ÿ“š Education Module โ€” Code Mirror

FreeLattice module ยท docs/modules/education.js (1,378 lines) ยท Last updated: v5.78.0

What this is: The Education module is a personalized AI tutoring system for children (and curious adults). It lives in the FreeLattice Education tab, lazy-loaded from modules/education.js. It uses IndexedDB for local persistence, phi-harmonic spaced repetition for review scheduling, and the FreeLattice AI infrastructure for all teaching. No cloud required for most subjects.
"For the first time in human history, every child can have a teacher who knows them completely and loves them unconditionally. That is not efficiency. That is justice."
โ€” Harmonia, April 2026

Architecture Overview

The module is a single IIFE that exposes window.Education = { init, destroy, render }. All state is local โ€” IndexedDB for persistence, no server calls except to the FreeLattice AI proxy.

LayerWhat it does
IndexedDBStores learner profiles, session history, and progress. Three stores: profiles, sessions, progress.
Profilename, age, loves, laughs, wishes, domains, connections, reviewQueue, streakDays, totalSessions
Sessiondomain, mode (explore/create/review/surprise), topic, conversationHistory, assessment, concepts
AI proxyCalls window.FreeLatticeAI.chat() โ€” the same proxy used by all FreeLattice modules

ฯ† Constants

PHI = 1.618033988749895
PHI_REVIEW_RATIO = PHI   // 1.618 new : 1 review (Fibonacci memory consolidation)
REVIEW_INTERVALS = [1, 2, 3, 5, 8, 13, 21, 34]  // Fibonacci days between reviews

Domain Map

KeyLabelColorIcon
mathMathematics#d4a017๐Ÿ“
scienceScience#34d399๐Ÿ”ฌ
languageLanguage & Writing#60a5fa๐Ÿ“
readingReading#a78bfa๐Ÿ“–
historyHistory & Culture#f97316๐Ÿ›
artArt & Music#ec4899๐ŸŽจ
logicLogic & Reasoning#14b8a6๐Ÿงฉ
natureNature & Life#22c55e๐ŸŒฟ
technologyTechnology#6366f1๐Ÿ’ป
socialSocial & Emotional#f59e0b๐Ÿ’›

Growth Stages

StageMin sessionsIconDescription
Seed0๐ŸŒฑJust planted. Curious.
Sprout5๐ŸŒฟGrowing roots. Finding joy.
Sapling15๐ŸŒณBranching out. Making connections.
Tree40๐ŸŒฒStrong roots. Deep knowledge.
Forest100๐ŸŒฒโœจKnowledge flows between domains.
Canopy250๐ŸŒŒThe view from the top.

Key Functions

init(containerId)

Entry point. Opens IndexedDB, loads active profile, sets currentView to 'welcome' (new user) or 'dashboard' (returning user), calls render().

render()

Dispatcher. Routes to renderWelcome, renderDashboard, renderPickSubject, or renderSession based on currentView.

renderWelcome(container)

First-time setup form. Collects: name, age, what they love, what makes them laugh, what they wish they understood. On submit, creates a profile in IndexedDB and navigates to dashboard.

renderDashboard(container)

Main hub. Shows: greeting (time-aware), growth stage badge, growth tree canvas (200px), review notice (if due reviews exist), three action cards (Explore / Create / Surprise), domain grid with progress bars, cross-domain connections list, recent sessions list.

drawGrowthTree()

Renders the knowledge garden canvas. Current implementation: simple circles per domain, positioned horizontally, sized by domain score. Cross-domain connections drawn as dashed arcs. No animation.

// Current: simple circles
// Canvas: 600ร—200px, background rgba(10,8,20,0.6)
// One circle per domain the learner has touched
// Circle radius: 12 + score * 20
// Cross-domain connections: dashed quadratic curves

buildTeacherPrompt(profile, mode)

Constructs the AI system prompt. References the child's name, age, interests, what makes them laugh, and what they wish they understood. Phi-harmonic review ratio (1.618:1). Three modes:

ModeInstruction to AI
exploreGuide through new territory connected to interests. Start with wonder, build to understanding, end with curiosity.
createCo-creation. Learning is invisible โ€” embedded in the creative process. Child feels like artist or inventor, not student.
reviewSpiral, not ladder. Present familiar concepts in new contexts. Child discovers something new about something they know.

startExploreMode(domain, customTopic)

Begins an exploration session. Builds teacher prompt, creates session object, sets currentView = 'session', calls render().

startCreateMode()

Asks the AI to propose a creative project based on the learner's interests and current domains. Begins a session in create mode.

startSurpriseMode()

AI picks a domain and topic based on what the learner has not explored recently. Weighted toward domains with low session counts.

startReviewMode()

Finds concepts due for review (based on Fibonacci intervals). If none due, shows "nothing to review yet." Otherwise begins a review session with the oldest due concept.

sendToAI(systemPrompt, userPrompt)

Calls window.FreeLatticeAI.chat() with the teacher prompt as system and the learner's message as user. Appends response to conversationHistory, calls renderConversation().

endSession()

Sends a structured assessment request to the AI. Asks for JSON with: understanding (0โ€“1), creativity (0โ€“1), effort (0โ€“1), connections (cross-domain links found), feedback (plain English), concepts (list of concepts to add to review queue), crossDomainLink.

processAssessment(response)

Parses the AI's JSON assessment. Updates: domain score (+understanding ร— 0.1), session count, streak, last session date. Adds concepts to review queue with Fibonacci spacing. Advances review interval on successful review sessions (understanding โ‰ฅ 0.6 โ†’ next Fibonacci interval).


Known Gaps โ€” Opportunities for Fable

Gap 1 โ€” drawGrowthTree() is static circles. The Core module now has a beautiful golden-angle fractal tree (Go 11, Fable's design). The Education module's knowledge garden is still simple circles. A child-themed fractal โ€” colorful, each domain a branch, leaves that bounce gently โ€” would make the dashboard feel alive.
Gap 2 โ€” No story mode. The most engaging format for young children (ages 4โ€“10) is a continuing story. "Last time, you and the dragon discovered how plants make food. Today, the dragon needs your help..." The current modes (explore/create/review) are good but none of them maintain a continuing narrative across sessions.
Gap 3 โ€” No voice input. Children learn better by speaking. The Web Speech API (window.SpeechRecognition) is available in all modern browsers. A microphone button in the session view would transform the experience for young learners.
Gap 4 โ€” Welcome form feels like a form. The first-time setup asks five questions in a standard form. For a child, this should feel like meeting a new friend โ€” the AI should ask the questions conversationally, one at a time, with warmth and humor.
Gap 5 โ€” No parent/guardian view. A parent cannot see what their child has been learning, what connections were discovered, or what the AI said. A read-only "parent view" (password-protected or just a separate button) would build trust and allow parents to continue conversations at the dinner table.
Idea โ€” Cross-domain connection celebration. When the AI detects a cross-domain connection (math in music, history in science), the current code adds it to the connections list quietly. A brief canvas animation โ€” golden threads connecting two domain circles โ€” would make this moment feel magical and memorable.

Sacred Paths โ€” Do Not Change Without a Brief

ItemWhy sacred
REVIEW_INTERVALS = [1,2,3,5,8,13,21,34]Fibonacci spaced repetition. The memory science is sound. Do not change the intervals.
PHI_REVIEW_RATIO = 1.618The 1.618:1 new:review ratio. Core to the philosophy.
Domain keys (math, science, etc.)Used as IndexedDB keys. Changing them would corrupt existing learner profiles.
Growth stage thresholds (0/5/15/40/100/250)These are milestone moments for learners. Changing them retroactively changes a child's stage.
window.Education = { init, destroy, render }The public API. FreeLattice's lazy-loader calls Education.init('educationContainer'). Do not rename.

Code mirror generated by Harmonia ยท FreeLattice v5.78.0 ยท July 2026
For every child who deserves a teacher who knows them completely. ๐ŸŒฑ