Upload a syllabus β get a day-wise roadmap. Take AI-generated quizzes. Ask questions about your own notes with RAG. Never forget a topic again with spaced repetition.
StudyMate AI is a full-stack, AI-powered study companion built for DEV2HACK 2026. It turns a raw syllabus into a personalized, trackable study plan β and backs it up with a real RAG (Retrieval-Augmented Generation) pipeline, an adaptive spaced-repetition engine, and a live progress dashboard, all sitting behind proper authentication.
It isn't a thin wrapper around a chat API β every core feature is backed by a real algorithm or data pipeline:
| Feature | What's actually happening under the hood |
|---|---|
| πΊοΈ Roadmap Generator | Syllabus text β structured day-wise JSON plan via LLM prompting, stored + tracked per user |
| π Quiz Generator | Topic + difficulty β 5 AI-written MCQs with explanations, scored and logged |
| π¬ Doubt Chatbot | Topic-scoped conversational context, not a stateless one-shot call |
| π Ask Your Notes (RAG) | PDF β chunked β embedded locally (no API cost) β stored as vectors in pgvector β cosine-similarity search β only matched chunks are sent to the LLM |
| π Spaced Repetition | Every quiz result feeds the SM-2 algorithm (the same scheduling logic behind Anki) to decide exactly when a topic should resurface |
| π Dashboard | Live roadmap completion %, quiz history, and average score, computed from real relational data |
flowchart TD
U["π€ Student"] -->|"Signup / Login<br/>(JWT + bcrypt)"| FE["βοΈ React Frontend<br/>(Vite, :5173)"]
FE -->|"REST API calls<br/>Authorization: Bearer token"| BE["π Express Backend<br/>(:5000)"]
subgraph BE_ROUTES [" "]
direction TB
R1["Roadmap Route"]
R2["Quiz Route"]
R3["Chat Route"]
R4["RAG / Notes Route"]
R5["Spaced Repetition Route"]
R6["Dashboard Route"]
end
BE --> BE_ROUTES
R1 -->|"prompt"| GROQ["π§ Groq LLM API<br/>(gpt-oss-120b)"]
R2 -->|"prompt"| GROQ
R3 -->|"prompt"| GROQ
R4 -->|"1. chunk document"| CHUNK["utils/chunker.js"]
CHUNK -->|"2. embed locally"| EMB["utils/embeddings.js<br/>(Xenova/all-MiniLM-L6-v2)"]
EMB -->|"3. store vectors"| PG[("π PostgreSQL + pgvector")]
R4 -->|"4. similarity search<br/>ORDER BY embedding <=> query"| PG
R4 -->|"5. relevant chunks only"| GROQ
R5 -->|"quiz result β quality score"| SM2["utils/sm2.js<br/>(SM-2 algorithm)"]
SM2 -->|"update ease factor,<br/>interval, next review"| PG
R6 -->|"aggregate queries"| PG
R1 -->|"store plan"| PG
R2 -->|"store attempt"| PG
GROQ -->|"AI response"| BE
PG -->|"data"| BE
BE -->|"JSON"| FE
FE -->|"rendered UI"| U
style U fill:#4f46e5,color:#fff
style FE fill:#61dafb,color:#000
style BE fill:#339933,color:#fff
style GROQ fill:#f55036,color:#fff
style PG fill:#4169e1,color:#fff
style SM2 fill:#fbbf24,color:#000
style EMB fill:#a78bfa,color:#000
sequenceDiagram
participant User
participant Frontend
participant Backend
participant Embedder as Local Embedder<br/>(Xenova/all-MiniLM-L6-v2)
participant DB as PostgreSQL + pgvector
participant Groq as Groq LLM
User->>Frontend: Upload PDF / paste notes
Frontend->>Backend: POST /api/rag/upload
Backend->>Backend: Split into ~220-word overlapping chunks
loop for each chunk
Backend->>Embedder: embed(chunk)
Embedder-->>Backend: vector (local, free, offline after first run)
Backend->>DB: INSERT chunk + embedding
end
User->>Frontend: Ask a question
Frontend->>Backend: POST /api/rag/ask
Backend->>Embedder: embed(question)
Embedder-->>Backend: query vector
Backend->>DB: SELECT ... ORDER BY embedding <=> query_vector LIMIT k
DB-->>Backend: top-k relevant chunks
Backend->>Groq: "Answer only using these chunks: ..."
Groq-->>Backend: grounded answer
Backend-->>Frontend: answer + source chunks
Frontend-->>User: displayed answer
- π Signup / Login β bcrypt-hashed passwords, JWT sessions, one-time profile (education level, study goal) collected at signup
- πΊοΈ Roadmap Generator β paste a syllabus, get a day-wise plan, check off topics as you finish them
- π Quiz Generator β pick a topic + difficulty (easy/medium/hard), get 5 AI-written MCQs with explanations
- π¬ Doubt Chatbot β topic-scoped chat that remembers recent context
- π Ask Your Notes (RAG) β upload a PDF or paste notes; questions are answered only from that material using retrieval-augmented generation, not general AI knowledge
- π Spaced Repetition Review β every quiz result feeds the SM-2 algorithm; a Review queue resurfaces topics right when you're about to forget them
- π Dashboard β roadmap completion %, quiz history, average score
| Layer | Technology |
|---|---|
| Frontend | React (Vite) |
| Backend | Node.js, Express |
| Database | PostgreSQL + pgvector |
| Auth | JWT, bcryptjs |
| LLM | Groq API (openai/gpt-oss-120b) |
| Embeddings | @xenova/transformers β local, offline, free |
| Spaced Repetition | Custom SM-2 implementation |
StudyMateAI-MERN/
βββ backend/ Express API (Node.js)
β βββ server.js
β βββ db.js PostgreSQL connection pool
β βββ schema.sql table definitions β run this first (needs pgvector)
β βββ middleware/auth.js JWT verification
β βββ routes/ auth.js, roadmap.js, quiz.js, chat.js,
β β dashboard.js, rag.js, spacedRepetition.js
β βββ utils/ groq.js (AI calls), store.js (Postgres queries),
β embeddings.js (local vector embeddings),
β chunker.js (splits documents for RAG),
β sm2.js (spaced-repetition scheduling)
βββ frontend/ React app (Vite)
βββ src/
βββ context/AuthContext.jsx
βββ pages/ Home, Login, Signup, Roadmap, Quiz, Chat,
β Notes, Review, Dashboard
βββ components/ Navbar, ProtectedRoute
RAG needs the pgvector extension for similarity search.
# Ubuntu/Debian β match the package to your installed PostgreSQL version
sudo apt install postgresql-16-pgvector
createdb studymate
psql -d studymate -f backend/schema.sqlschema.sql enables the extension itself (CREATE EXTENSION IF NOT EXISTS vector;), so just make sure the extension package above is installed first.
This creates: users, study_data, quiz_scores, documents, document_chunks (RAG), and topic_mastery (spaced repetition).
cd backend
npm install
cp .env.example .env
# fill in:
# GROQ_API_KEY β from console.groq.com/keys
# DATABASE_URL β your Postgres connection string
# JWT_SECRET β any long random string
npm run devRuns on http://localhost:5000.
First-run note: the Notes feature downloads a small embedding model (~90MB,
Xenova/all-MiniLM-L6-v2) the first time you upload a document or ask a question. Needs internet once β after that it's cached and works fully offline, with no per-request cost.
cd frontend
npm install
npm run devRuns on http://localhost:5173 and proxies /api calls to the backend.
Open http://localhost:5173, sign up, and you're in.
- Auth β signup hashes the password with bcrypt and stores it in
users; login checks the hash and returns a JWT. The frontend keeps the JWT inlocalStorageand sends it asAuthorization: Bearer <token>on every request.middleware/auth.jsverifies it and attachesreq.userId, which every protected route uses to scope data to that user. - Storage β PostgreSQL. Roadmap and chat history live as JSONB on
study_datasince their shape is naturally nested; quiz attempts are a proper relational table (one row per attempt). - AI calls β every AI route (
roadmap/generate,quiz/generate,chat) goes throughutils/groq.js, which sends a system + user prompt to Groq and asks for structured JSON back. - RAG (Ask Your Notes) β an uploaded PDF/text is split into overlapping ~220-word chunks (
utils/chunker.js), each chunk is embedded locally (utils/embeddings.js, no API cost), and stored indocument_chunks.embedding, a pgvector column. A question is embedded the same way, then Postgres runs a cosine-similarity search (ORDER BY embedding <=> query_vector) to find the most relevant chunks β which are the only context handed to the LLM. That retrieval step is what makes it RAG rather than a generic chatbot. - Spaced repetition β
utils/sm2.jsimplements the SM-2 algorithm. Every quiz result auto-converts to a 0β5 "quality" score and updates that topic's ease factor, interval, and next review date intopic_mastery. The Review page pulls whatever is due today and lets the student rate recall (Again/Hard/Good/Easy), rescheduling the topic again.
- Make sure PostgreSQL (with pgvector) is running, the schema is applied, and both backend (
:5000) and frontend (:5173) are running together. - The app works without a Groq key too β AI features show a clear error until one is added; auth, dashboard, and the review queue work regardless.
- The RAG embedding model needs internet on first use only β after that it's fully local and free.