All API routes use NextAuth session-based authentication. The route() middleware wrapper handles auth, subscription checks, and rate limiting.
// Example: protected route
export const GET = route({}, async (req, { user }) => {
// user.id, user.role, user.email available
return NextResponse.json({ id: user.id })
})
// Skip subscription check (freemium-safe routes)
export const GET = route({ skipSubscriptionCheck: true }, async (req, { user }) => {
// ...
})
// Role-restricted
export const GET = route({ auth: 'TEACHER' }, async (req, { user }) => {
// ...only TEACHER role can access
})AI endpoints use OpenRouter AI (OpenAIAI class from src/lib/openrouter-ai.ts).
POST /api/ai/generate-content — Rubrics, PowerPoint, Assignments, Exams, ProjectsPOST /api/ai/lesson-plan — Smart lesson plan generationPOST /api/ai/socratic-tutor — Guided Socratic hintsPOST /api/ai/writing-coach — Writing feedbackPOST /api/ai/diagram — Educational diagramsPOST /api/ai/presentation — Auto presentationsKenya CBC curriculum endpoints:
GET /api/curriculum/strands?subject=...&grade=... — Strands for subject+gradeGET /api/curriculum/substrands?strandId=... — Substrands for a strandGET /api/curriculum/auto-populate?subject=...&grade=... — Auto-populate topic suggestionsGET /api/notifications — List notifications (supports unreadOnly, countOnly, limit, offset)POST /api/notifications/send — Broadcast to users by role/schoolPATCH /api/notifications/:id/read — Mark single as readPATCH /api/notifications/mark-all-read — Mark all as readAuto-populated with Kenya term defaults on first access:
Admin pages can fetch via /api/academic-calendar?year=YYYY
Students review content on an automatically-scheduled interval using the SM-2 algorithm:
GET /api/student/review-schedule — Today's review queuePOST /api/student/review-schedule — Submit review (updates ease factor)Multi-provider AI with key rotation. API keys can be added comma-separated for automatic rotation. Admin UI at /super-admin/api-keys.
EduGeniusnAI Documentation — powered by the team