Upload a PDF and instantly generate a small interactive course with modules, lessons, quizzes, and flow-ordering questions. Powered by Together AI.
PDF to Interactive Lesson Generator extracts text from your uploaded PDF, sends the source content to Together AI-hosted models, and builds a structured 3-module course. Each module includes grounded lesson content plus interactive checks like short-answer, true-false, multiple-choice, and process-ordering questions.
- Upload a PDF from the browser
- Extract — the app reads the document text locally with MuPDF
- Generate — Together AI models create the course structure, lessons, quizzes, and flow questions
- Repair — duplicate or weak questions are detected and regenerated or hidden
- Learn & Share — courses are saved so you can revisit progress or share a public course link
- Framework: Next.js App Router
- AI: Together AI — course planning, lesson generation, quiz generation, and flow-question generation (GPT OSS 120B)
- PDF extraction: MuPDF
- Database: Neon Postgres with Drizzle ORM
- Storage: Vercel Blob
- Queueing and rate limiting: Upstash Redis
- Styling: Tailwind CSS
- UI: Radix UI, lucide-react, and custom interactive lesson components
The generation pipeline is designed to be fast enough for a live demo while keeping the generated course grounded in the source PDF.
- OCR and extraction: MuPDF pulls text from the uploaded PDF before generation starts
- Course planning: one AI call creates the module structure
- Flow assignment: one AI call finds distinct source-backed processes for flow-ordering questions
- Parallel lesson generation: modules are generated concurrently to reduce wait time
- Dedup repair: similar questions are detected with Jaccard similarity, then regenerated or removed from the visible course
- Persistence: generated courses are stored in Postgres and PDF uploads are handled through Vercel Blob
For a deeper breakdown of the speed and quality work, see docs/course-generation-speedup.md.
git clone https://github.com/Nutlope/pdf-to-interactive-lesson.git
cd pdf-to-interactive-lessonTogether AI (required — powers course generation):
- Go to Together AI to create an account
- Copy your API key
Neon (required — stores generated courses):
- Create a Postgres database with Neon
- Copy your database connection string
Vercel Blob (required for the web app — stores uploaded PDFs):
- Create or connect a Vercel Blob store
- Copy your read/write token
Upstash Redis (required for queueing and rate limiting):
- Create an Upstash Redis database
- Copy the REST URL and REST token
Create a .env.local file in the root directory and add your keys:
TOGETHER_API_KEY=your_together_api_key_here
DATABASE_URL=your_neon_database_url_here
BLOB_READ_WRITE_TOKEN=your_vercel_blob_token_here
UPSTASH_REDIS_REST_URL=your_upstash_redis_rest_url_here
UPSTASH_REDIS_REST_TOKEN=your_upstash_redis_rest_token_here
NEXT_PUBLIC_APP_URL=http://localhost:3000You can also enter a Together AI key directly in the app by clicking the key icon in the top-right corner.
pnpm installpnpm db:pushpnpm devThe app will be available at http://localhost:3000.
This repo also includes a small CLI for local generation, debugging, and benchmarking.
pnpm course generate data/document.pdf
pnpm course modules data/document.pdf
pnpm course benchmark data/document.md --runs 5Useful flags:
--model <name>--output <path>--save-text-auto--no-validate--no-retry--max-retries <n>--verbose
