LearnEngine

Full-Stack AI Platform

2026

Key Features

AI-Generated Curricula

Type any topic and get a structured lesson plan in seconds with personalized content.

Dynamic Content

Each section receives detailed, AI-written educational content with math support.

Adaptive Quizzes

Questions adjust difficulty based on your performance in real-time.

AI Tutor Chat

Ask questions anytime with full lesson context and persistent history.

Progress Tracking

Track accuracy, time spent, and improvement across all your lessons.

Secure by Design

Multi-layer security with auth, rate limiting, and data isolation.

Overview

This project was a beast. I wanted to build something that actually LEARNS from you, not just throws generic content at your face. Built it on Next.js 16 + React 19, hooked up to multiple AI models through OpenRouter. The cool part? If you're bombing the quizzes, it dials down the difficulty. Crushing it? Questions get harder. It's like having a tutor who pays attention.

The backend was where things got spicy. Supabase for the database and auth, which was honestly great until I spent 3 hours debugging why Row Level Security wasn't working (spoiler: I forgot a semicolon in the policy). The AI stuff goes way beyond just calling an API, I had to build injection protection because apparently people WILL try to break your prompts. Learned that one the hard way.

Security nearly killed me. Had to implement rate limiting after I realized someone could theoretically spam the AI endpoints and rack up my API bill. Added input sanitization, fixed an open redirect bug that was embarrassing, and strengthened the password requirements. Basically paranoia-driven development.

The frontend is probably what I'm most proud of. GSAP animations everywhere, shadcn/ui components that actually look good, and micro-interactions that make it feel alive. The AI chat keeps your conversation history so you can pick up where you left off. Took forever to get the streaming to work right but damn it feels smooth.

How It Started

From notebook to reality

1

The Idea

Dynamically generated learning engine
2

High Level Approach

Avoid rebuilding app depending on OS
Probably organized a backend accessed using API calls
3

Viability Research

Research cost of models for backend
Start with open source models, ideally free
OpenRouter is the window into these models
Test models to find the right fit
4

Build Phase 1

Build Next.js app using Bun
Code with Antigravity
Add Supabase to App
sketchLogin flow
sketch"What to learn" search bar
sketchExisting lessons cards
OpenRouter for AI use
5

Backend & Complexity Testing

Create backend to test complexity of minimal requirements
Learning: storing User Data is hard
Create a frontend to access the backend
Pivot to Next.js build of front and back — still backend centric + faster to launch
Explore saving User Data!!! → Supabase to the Rescue?
6

Deep Dive & Model Selection

Supabase hands-on build
Test AI models for fit (must be free)
DeepSeek R1 T2 → meets criteria ✓
MiMo V2 Flash → same but faster ✓

Architecture

System Architecture

User Interface
🏠Landing Page
📊Dashboard
📖Lesson View
💬Chat Panel
API Layer
🔐Authentication
  • Session handling
  • Route protection
🤖AI Routes
  • Generate Plan
  • Generate Content
  • Grade Answer
🛡️Security
  • Rate limiting
  • Input sanitization
💬Chat
  • Conversation management
  • Message history
External Services
🗄️Supabase
  • PostgreSQL
  • Auth
  • RLS Policies
🧠OpenRouter AI
  • Mimo Flash
  • GPT-120B
  • GLM 4.5 Air

User Journey

User Learning Journey

✏️Enter Topic
🤖AI Generates Plan
📋Review & Customize
📚Learn Content
Practice Quiz
💬AI Tutor Help
🎓Master Topic

Adaptive Algorithm

Adaptive Learning Algorithm

📊User Performance
Analyze
< 50% Accuracy
Easier
50-80% Accuracy
Same
> 80% Accuracy
Harder
🎯Personalized Path

How It Works

< 50%Easier questions with basic definitions
50-80%Same level, mix of recall and application
> 80%Harder questions with critical thinking

Security

Security Architecture

👤User Request
🔐Authentication
⏱️Rate Limiting
🛡️Input Sanitization
Authorization
🗄️Row Level Security
Safe Request

Database Design

Database Schema

User Data
👤profiles
  • id
  • display_name
  • created_at
📈user_progress
  • is_correct
  • user_answer
  • time_spent
Learning Content
📋lesson_plans
  • topic
  • outline
  • status
📄lesson_sections
  • title
  • content
  • difficulty
questions
  • question_text
  • options
  • correct_answer
Chat System
💬chat_conversations
  • title
  • lesson_id
  • model_id
📝chat_messages
  • role
  • content
  • model_id

Work Items

AI-Generated Curricula

ai

Type literally any topic and get a structured lesson plan in seconds. The AI breaks it down into 4-6 sections with time estimates. Getting different AI models to format their output consistently was... an adventure.

  • OpenRouter integration, had to debug each model separately because they all have quirks
  • Mimo Flash, GPT-120B, GLM 4.5 Air support (each returns slightly different JSON, fun times)
  • Prompt injection sanitization after someone tried some creative inputs
  • JSON parsing with fallbacks because AI outputs aren't always clean

Dynamic Content Generation

ai

Each lesson gets detailed, AI-written content in Markdown with math equation support. Getting the difficulty slider to actually change the language complexity took way more prompt iterations than I want to admit.

  • 400-600 words per section (had to tweak prompts to stop AI from writing novels)
  • Difficulty scale 1-10 that actually works (mostly)
  • Markdown rendering with syntax highlighting for code examples
  • KaTeX for math equations, surprisingly smooth to integrate

Adaptive Quiz Engine

feature

Questions get easier if you're struggling (<50% accuracy) or harder if you're crushing it (>80%). The algorithm tracks your last 10 answers. First version was way too aggressive with difficulty swings, had to tune it.

  • Multiple choice, true/false, and short answer question types
  • AI grading for open-ended responses (this took forever to get right)
  • Performance context tracking that actually influences new questions
  • Difficulty adjustment in -2 to +2 range, aggressive enough to feel adaptive, not so much it's jarring

AI Tutor Chat

ai

Built-in AI tutor that knows what lesson you're on. Ask questions anytime and get contextual help. The first version lost chat history on page refresh, that was a fun bug to explain to testers.

  • Persistent chat history that actually persists (took a few attempts)
  • Model picker so you can choose your AI
  • Lesson context injection so the AI knows what you're learning
  • Message streaming for that ChatGPT-like typing feel

Progress Tracking System

feature

Tracks accuracy, time spent, and improvement over time. Everything persists across sessions. The database schema for this went through like 3 revisions before it made sense.

  • Per-question answer tracking (yes, I store every answer)
  • Time spent per section and per question
  • Accuracy calculations that update in real-time
  • Visual progress bars that actually feel motivating

Security Architecture

security

Multi-layer security because I'm paranoid. Rate limiting, input sanitization, RLS policies, the works. Found an open redirect vulnerability during my own testing which was embarrassing but better than finding it in prod.

  • Supabase Auth with proper session handling
  • Rate limiting at 10 AI calls/minute (my wallet said so)
  • Prompt injection pattern filtering, people will try to break things
  • Open redirect prevention after I found a vulnerability in my own code
  • RLS policies that actually work (after the semicolon incident)

Database Architecture

architecture

PostgreSQL with 7 interconnected tables. Users, lessons, sections, questions, progress, chat history, the whole thing. Took a while to get the relationships right but now it's actually pretty clean.

  • Profiles, lesson_plans, lesson_sections tables (basic but solid)
  • Questions with difficulty levels and type metadata
  • User progress tracking per section and per question
  • Chat conversation and message storage with proper foreign keys
  • RLS policies on everything, nobody sees anyone else's data

Key Highlights

  • 01

    Built full AI curriculum generation with support for Mimo Flash, GPT-120B, GLM 4.5 Air, DeepSeek R1T2 (had to debug each one individually, they all return slightly different formats)

  • 02

    Adaptive difficulty that actually works, tracks your last 10 answers and adjusts on the fly

  • 03

    7-table PostgreSQL schema with RLS policies (after spending a day debugging why users could see each other's data)

  • 04

    AI grading for short answers, this was HARD, getting consistent grading took like 50 prompt iterations

  • 05

    Chat history that persists properly (first version was losing messages, that was fun)

  • 06

    Rate limiting, injection filtering, redirect prevention, basically every security thing I could think of

Technologies

Frontend

Next.js 16React 19TypeScriptTailwind CSSshadcn/uiGSAP

Backend

API RoutesSupabase AuthPostgreSQLRow Level Security

AI & Data

OpenRouter APIMimo FlashGPT-120BGLM 4.5 AirDeepSeek R1T2