Documentation

EduGeniusnAI Platform API & Developer Guide

Getting Started

Authentication

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 Generation

AI endpoints use OpenRouter AI (OpenAIAI class from src/lib/openrouter-ai.ts).

  • POST /api/ai/generate-content — Rubrics, PowerPoint, Assignments, Exams, Projects
  • POST /api/ai/lesson-plan — Smart lesson plan generation
  • POST /api/ai/socratic-tutor — Guided Socratic hints
  • POST /api/ai/writing-coach — Writing feedback
  • POST /api/ai/diagram — Educational diagrams
  • POST /api/ai/presentation — Auto presentations

Curriculum API

Kenya CBC curriculum endpoints:

  • GET /api/curriculum/strands?subject=...&grade=... — Strands for subject+grade
  • GET /api/curriculum/substrands?strandId=... — Substrands for a strand
  • GET /api/curriculum/auto-populate?subject=...&grade=... — Auto-populate topic suggestions

Notifications & Messages

  • GET /api/notifications — List notifications (supports unreadOnly, countOnly, limit, offset)
  • POST /api/notifications/send — Broadcast to users by role/school
  • PATCH /api/notifications/:id/read — Mark single as read
  • PATCH /api/notifications/mark-all-read — Mark all as read

Academic Calendar

Auto-populated with Kenya term defaults on first access:

  • Term 1: Jan 5 — Apr 4 (13 weeks, half-term Feb 23-27)
  • Term 2: Apr 28 — Jul 25 (13 weeks, half-term Jun 2-6)
  • Term 3: Sep 2 — Nov 1 (11 weeks, half-term Oct 13-17)

Admin pages can fetch via /api/academic-calendar?year=YYYY

Spaced Repetition (SM-2)

Students review content on an automatically-scheduled interval using the SM-2 algorithm:

  • GET /api/student/review-schedule — Today's review queue
  • POST /api/student/review-schedule — Submit review (updates ease factor)

OpenRouter AI Provider

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