The Big Idea
Why v2 exists and what it does differently
What This Tool Does
Why have the AI regenerate the same CSS and JavaScript every time? The styling never changes — only the content does. v2 separates them: the AI writes structured JSON, and a build script assembles the final HTML from pre-built templates. Result: 75% fewer tokens.
You do NOT generate HTML, CSS, or JavaScript.
You generate JSON that conforms to the course content schema.
The build script assembles the final course from your JSON + static templates.
The AI's job is content only — no visual code
Write structured data following the blueprint
A separate program handles all the visual assembly
v1 vs v2: The Key Difference
AI generates:
- Course content
- All HTML structure
- All CSS (1400 lines)
- All JavaScript (700 lines)
- Glossary tooltips
Total: ~25,000 tokens
AI generates:
- Course content as JSON
Build script handles:
- HTML (from template)
- CSS (from template)
- JavaScript (from template)
- Glossary injection
AI output: ~6,000 tokens
The Assembly Line
What is the main difference between v1 and v2?
Meet the Players
The components that make v2 work
The Cast of Characters
The instruction manual for the AI — tells it how to analyze a codebase and generate content.
Blueprints defining the exact shape of the AI's output — like a form with required fields.
Pre-built HTML, CSS, and JavaScript — the look, feel, and interactivity. Never change.
The build script — takes JSON + templates and assembles the final course HTML.
function assembleSingleFile(courseData) {
const baseHtml = loadTemplate('base.html');
const css = loadTemplate('styles.css');
const js = loadTemplate('scripts.js');
html = html.replace('{{modules_content}}', modulesHtml);
The main assembly function — takes course data and produces one HTML file
Load the page skeleton template
Load all the visual styling
Load all the interactive behavior
Plug the rendered course modules into the page skeleton
File Structure
How They Talk
You want to change the font used in all courses.
Which file would you edit?
The Build Pipeline
How compile.js turns JSON into a beautiful course
The Assembly Process
Read course-content.json and parse it into a JavaScript object.
Check every required field — title, actors, modules, quizzes. Report errors.
For each module, render each element using type-specific renderers.
Scan HTML for technical terms and wrap them in tooltip spans.
Load base template, inject CSS, JS, nav, sidebar, and all modules. Write final file.
The Renderer Pattern
{"type": "chat"}, it calls the chat renderer which knows how to turn that data into HTML.const Renderers = {
prose(el) {
return `<div class="prose-block">${el.content}</div>`;
A collection of functions, one per element type
When the element type is 'prose'...
Wrap the content in a styled div
prose, translation, chat, flow, callout, step_cards, pattern_cards, icon_rows, file_tree, architecture, badge_list, layer_toggle, spot_the_bug, diff_view, and custom_html.
Glossary Injection
const terms = Object.keys(glossary).sort((a, b) => b.length - a.length);
const regex = new RegExp(`(?<![<\\w])\\b(${escapedTerm})\\b`, 'i');
html = html.replace(regex, replacement);
Sort terms longest-first so 'JavaScript' matches before 'Java'
Find the term as a whole word, NOT inside HTML tags
Replace only the FIRST occurrence per module
Why does the glossary sort terms longest-first?
Content Design Philosophy
Rules that make courses actually teach
Who This Is For
Steer AI Better
Know which components exist to direct AI precisely
Detect AI Mistakes
Spot hallucinations before they ship
Debug When Stuck
Escape AI bug loops by understanding what's happening
Talk to Engineers
Learn vocabulary to describe requirements precisely
The Content Rules
Fourth sentence? Convert to a visual element.
Every screen must be at least half visual.
Need more space? Add another screen.
Each concept gets its own metaphor. Never reuse.
Never modify snippets. Show real code as-is.
Module Curriculum Arc
| 1 | What the app does + trace a user action
| 2 | Meet the actors (components)
| 3 | How the pieces communicate
| 5 | Clever patterns
| 6 | When things break
Start concrete — what happens when someone uses it
Introduce the cast — which pieces exist
Data flow — debug 'not showing up' problems
Teach patterns learners can request from AI
Build debugging intuition
You've written 5 sentences explaining API authentication in Module 3.