aidenteaidenteBlog
Shipments
EducationAI PipelineSaaS

Octave

Educational content creation is expensive and slow — a single rich module takes a specialist days to produce. At EdTech scale, that ceiling kills iteration speed. The question was whether AI could compress that timeline to minutes without sacrificing depth.

The Need

The platform needed six distinct content types: quizzes, branching theater scenarios, podcast scripts, TTS audio, illustrated story books, and standalone images. Each has different latency (30 seconds to 5 minutes), different cost profiles, and different output shapes.

The challenge wasn't generating the content — it was building a system where educators never feel the wait, operations teams can monitor and retry jobs, and adding a new content type in the future doesn't require touching the UI or the API contract.

The Key Insight

One interface, any content type, any latency.

Every module — whether it takes 30 seconds or 5 minutes — uses the same fire-and-forget contract: POST returns a taskId immediately, GET polls until done. The caller never knows or cares what's happening inside. Adding a new content type means writing a new worker, not changing the API or the frontend.

DB write before queue push

Task row is created first, inside a transaction. If the BullMQ push fails, the row rolls back — no orphaned "queued" tasks that will never run.

Structured Outputs end-to-end

Quiz and theater modules use Zod schemas with zodResponseFormat. The model is constrained to emit valid JSON at the token level — no regex parsing, no retry loops on malformed output.

How It Works

01
Admin API
POST /api/aigc/:module

Validates the request body against the module schema. Writes a task row (status: queued) and pushes a BullMQ job — atomically inside a DB transaction. Returns taskId immediately.

02
BullMQ Worker
Picks up job

Worker sets status → processing. Calls the module handler (OpenAI API). On completion writes output JSON + token usage to the task row and sets status → completed.

03
Admin API
GET /api/aigc/tasks/:id

Caller polls this endpoint. Returns the current status (queued | processing | completed | failed) and, when done, the full output payload from the JSONB column.

04
Consumer
Reads output

On completed, the consumer reads the structured output (quiz JSON, audio URL, image URLs, etc.) and delivers it to the end user in the product UI.

Content Modules

Quiz Generator

Generates structured multiple-choice quizzes from a lesson topic and difficulty level. Uses OpenAI Structured Outputs (Zod schema) to guarantee parseable JSON without post-processing.

Interactive Theater

Produces branching dialogue scenarios with named characters. Students navigate choices; each path is pre-generated so the experience is instant at runtime with no further AI calls.

Podcast Script + Audio

Two-stage pipeline: GPT-4o writes the host/guest script, then TTS-1 converts each speaker turn to audio. Chunks are concatenated and uploaded to S3; the task resolves with a playback URL.

Picture Book

Generates story text and one DALL·E 3 HD image per page in parallel. The most expensive module — cost is primarily DALL·E image tokens. Results stored as structured JSON with S3 image URLs.

Lesson Summary

Condenses a lesson into key points and a short paragraph. Fastest and cheapest module. Used as a prerequisite input for other modules (quiz, theater) via the config JSONB.

DALL·E Image Set

Generates a themed set of HD illustrations for a lesson. Prompts are constructed from the lesson topic and art-style config. All images uploaded to S3; URLs stored in task output.

Status
Production
Category
AI Content Engine · EdTech SaaS
Built with
aidente