Context
The core feature! Generate flashcards from topic content using AI. The generate.ts router has skeleton endpoints that need implementation.
Goal
- Fetch user's API key from settings
- Call Gemini API with topic content
- Parse response into flashcards
- Save flashcards to database
- Return generated flashcards to client
Files to Modify
packages/api/src/routers/generate.ts
- Create
packages/api/src/utils/gemini.ts
Deliverables
- Gemini API utility function
- Flashcard generation endpoint works end-to-end
- Proper error handling (no API key, API errors, parse errors)
- Flashcards saved to database
- Returns generated flashcards to client