
Software
Lesson Desk (All of a Sutton)
Turns one sentence from a teacher into a full textbook-grounded lesson: slides, group activity, worksheet and answer key, in about five minutes.
Live sitelesson-desk.atreyusutton.workers.dev
- LLM application
- Claude API
- Structured output
- TypeScript
- Python
- Cloudflare
Teachers spend hours turning a textbook chapter into a lesson. Lesson Desk does it from one sentence. I built it for my dad, who teaches astronomy and physics, and it is used for both courses. The app itself is named All of a Sutton, which is the name in the screenshots.
It reads the request, picks the chapters and writes a lesson plan. Then it writes the slides, a hands-on group activity and a worksheet in parallel from that plan. All of it is grounded in the class's actual textbook, with page citations in the answer key. Slides reuse figures cropped from the book, or diagrams the model draws itself as SVG. It also builds tests in two shuffled versions and makes balanced student groups.
This is LLM application engineering. I did not train or fine-tune a model. The work is what sits around the model: grounding, structured output, validation, cost and long-running jobs.
01
Spec
| Lane | Software |
|---|---|
| Status | Running |
| Role | Solo: design, pipeline, frontend, deployment |
| Built | November 2026 |
| Model | Claude Opus 5.5 through the Anthropic API, with adaptive thinking and per-step effort levels |
| Stack | Next.js, TypeScript, Zod, Anthropic SDK, PyMuPDF, pptxgenjs, docx, resvg (WebAssembly), Tailwind |
| Hosting | Cloudflare Workers, D1 database, Cloudflare Workflows for background jobs, behind a password with a public read-only demo |
02
Problem
One sentence in, a full class out
A 90-minute class needs slides, an activity, a worksheet and an answer key, and they all have to teach the same thing. Building that from a chapter by hand takes hours.
Here the teacher types one sentence, like "make me a lesson on chapter 11". About five minutes later the whole class is ready to open as PowerPoint and Word files.
Each lesson comes out as 5 files: the slides as .pptx, and the lesson plan, group handout, worksheet and answer key as .docx. Each test comes out as 3: version A, version B and the key.
03
Pipeline
How it works
A lesson is 5 model calls. One reads the request, one writes the plan, and three write the slides, the activity and the worksheet at the same time. Nothing the model returns is used until it has passed three checks.
Ahead of time, offline
- Textbook PDFssplit_textbook.pychapter text
- Textbook PDFsextract_figures.py1,119 cropped figures and an index
Teacher request
"make me a lesson on chapter 11"
1Interpret
Low effort. Lesson or test, and which chapters.
Unclear? It asks one clarifying question.
Then, lesson or test, plus chapters:
2Plan
High effort. Writes the shared blueprint.
Fed the chapter text and the figure catalog.
Then, shared blueprint, three calls in parallel:
3Slides
4Activity
5Worksheet and key
Checks
Zod schema check, then figure id check, then SVG safety check.
Saved as JSON
Shown in the browser, downloaded as PowerPoint and Word.
"Redo with changes" re-runs one part only.
04
Grounding
Grounded in the textbook, with a figure catalog
The model never works from memory. A Python script splits each textbook PDF into chapters using its bookmarks. A second script finds every caption, such as "Figure 11.3", grows a crop outward from it to the nearby graphics, and throws away crops that caught body text.
Each request sends the model the chapter text plus a catalog of that chapter's figures: id, page and caption. The model picks figures by id, and it cites printed page numbers in the answer keys.
05
Plan first
Plan first, then fan out
One call writes a lesson plan. Three parallel calls then write the slides, the activity and the worksheet, and each one is given the same plan as a blueprint. That is why the three pieces teach the same objectives instead of drifting apart, and why a lesson takes five minutes rather than fifteen.
A cheap, low-effort call at the front routes the request: lesson or test, and which chapters. When it cannot tell, it asks a clarifying question instead of guessing.
06
Structured output
Structured output, validated twice
Every call returns JSON constrained by a Zod schema, and then I parse it again on my side. The model's answer is data, not prose: slides, questions, answers, points. So the same result renders in the browser and exports to PowerPoint and Word.
const stream = client.beta.messages.stream({
model: modelId(),
max_tokens: request.maxTokens,
betas: ["server-side-fallback-2026-07-01"],
fallbacks: "default",
thinking: { type: "adaptive" },
output_config: { effort: request.effort, format: zodOutputFormat(request.schema) },
system: request.system,
messages: [{ role: "user", content }],
});
message = await stream.finalMessage();
// ...
const parsed = request.schema.safeParse(json);
if (!parsed.success) {
throw new GenerationError(`The AI response did not match the expected format: ${parsed.error.message}`);
}
return parsed.data;07
Validation
Never trust model output
The model can name a figure that does not exist, or write an SVG that is unsafe. Figure ids are checked against the index. SVG diagrams are rejected if they contain scripts, event handlers, external links or foreignObject. A bad visual is dropped from that one slide rather than failing the deck.
Refusals, cut-off responses, rate limits and bad keys each turn into a message a teacher can act on.
/** Drop visuals that cannot be rendered safely rather than failing the whole deck. */
async function sanitizeSlides(courseId: string, slides: Slide[]): Promise<Slide[]> {
const noVisual = { kind: "none" as const, figureId: "", svg: "", caption: "" };
const cleaned: Slide[] = [];
for (const slide of slides) {
const { visual } = slide;
if (visual.kind === "textbook_figure" && !(await findFigure(courseId, visual.figureId))) {
cleaned.push({ ...slide, visual: noVisual });
continue;
}
if (visual.kind === "diagram") {
const svg = visual.svg.trim();
const isUnsafe = /<script|<foreignObject|\son\w+\s*=|href\s*=\s*["'](?!#)/i.test(svg);
if (!svg.startsWith("<svg") || !svg.endsWith("</svg>") || isUnsafe) {
cleaned.push({ ...slide, visual: noVisual });
continue;
}
}
cleaned.push(slide);
}
return cleaned;
}08
Diagrams
The model draws its own diagrams
When no textbook figure fits, the model writes a diagram as SVG: a force diagram, a graph sketch. The app rasterises it to PNG with resvg compiled to WebAssembly, so it can go into a PowerPoint file.
The first pair below is the same slide in the app and in the exported deck. The rest are more diagrams the model drew for the same physics lesson.
09
Long jobs
Long jobs that survive
A lesson takes minutes, which is longer than a web request. Hosted, each lesson is a Cloudflare Workflow with one durable step per part, so a failed part can be retried alone and the teacher watches the steps complete.
The teacher can also revise one part, for example "make the worksheet easier", without regenerating the rest.
10
Right tool
Not everything needs an LLM
Student names are never sent to the model. Grouping is ordinary code: a randomised search of 400 attempts, scored by penalties for keep-apart pairs, repeated past pairings and an uneven ability mix.
Test version B is a seeded shuffle, so it is identical every time it is downloaded.
11
Results
Results
| Pipeline | 5 model calls per lesson: interpret, plan, then slides, activity and worksheet in parallel |
|---|---|
| Real run, Astronomy ch. 11 | 5 min 23 s, about $2, 55,374 output tokens, 18 slides (9 textbook figures, 5 model-drawn diagrams) |
| Real run, Physics ch. 4 | 3 min 19 s, 39,210 output tokens, 18 slides (10 textbook figures, 6 model-drawn diagrams) |
| Textbook corpus | 2 books, 64 chapters, 1,119 figures cropped and indexed automatically (465 astronomy, 654 physics) |
| Outputs | 5 files per lesson, 3 per test |
| Code | About 5,000 lines of TypeScript (Next.js 16, React 19) and Python (PDF processing) |
12
Next
What I learned, and what is next
Every call records input, output and cache tokens against the lesson. That telemetry showed the prompt cache was being written but never read: 0 cache-read tokens across the four calls. The likely cause is that each call sends a different output schema. Fixing it should save about $0.50 of the roughly $2 a lesson costs.
After that: a question bank that reuses questions across tests, and recovering the figures the cropper currently discards.
13
Links
The repo is private. The live app sits behind a password because it holds licensed textbook content and class rosters. The link at the top of this page opens a read-only demo instead: you can browse and download what is in the library, but creating and changing lessons is switched off and no roster is shown.
14
Next