Back to Projects

IntellectA

GenAI + Full Stack7 min read

AI study companion v2 — eight subject experts, LangGraph routing, pgvector RAG, adaptive quizzes, Google Sign-In, cloud-synced chat history, and KaTeX-rich answers. Next.js 14 + FastAPI on Groq, PostgreSQL, Redis & Mem0.

IntellectA - Image 1
GenAI + Full Stack
1 / 3

←Use arrow keys or swipe to navigate→

The Problem

Millions of students already use ChatGPT for homework, but generic chat UIs fail where learning actually happens. Calculus integrals render as broken plain text. Chemistry needs mhchem notation, not paragraphs of words. A single assistant cannot switch tone between Newton's laws, redox balancing, and WWI causes without mixing units, formulas, and historical context. The second most common workflow — snapping a photo from a notebook — requires vision, classification, and a subject specialist in one pipeline, not a copy-paste into a general bot.

v1 proved the routing idea with four Flask agents and browser-only chat history — but it broke across devices, had no syllabus grounding, and could not reject off-topic questions (coding, movies, casual chat). Students preparing for board exams, JEE, and college coursework need a scoped study product: eight academic experts only, exam-focused answers via RAG, adaptive quizzes, cloud-synced sessions, and Google Sign-In — not another general-purpose AI wrapper.

My Role & Constraints

Solo Full-Stack Engineer, Architect & Product Owner — I designed and shipped IntellectA v2 end-to-end.

**Frontend:** Dockit-style marketing landing (hero search bar, features, 3-step how-it-works tabs, subject curriculum cards, testimonials marquee, FAQ, CTA), split login page (marketing left + auth card right), Google Sign-In + email/password flows, and the /chat workspace (resizable sidebar, server-synced sessions, agent badges, image attach, regenerate/stop, KaTeX + mhchem rendering, light/dark theme, mobile drawer).

**Backend v2:** FastAPI + LangGraph orchestration (backend-v2), eight subject specialist nodes, Scope Guard, Evaluator for adaptive quizzes, pgvector RAG pipeline, hybrid memory (Redis + Mem0 + PostgreSQL concept_mastery), Groq vision for image doubts, JWT + Google OAuth auth, async SQLAlchemy with Neon PostgreSQL, and Gunicorn/Uvicorn deploy on Render.

**Ops:** Migrated from legacy Flask/SQLite v1 to production v2 stack; schema migrations, RAG curriculum seeding, CORS/env separation, and split Vercel + Render deployment.

System Design / Architecture

IntellectA v2 is a **monorepo with two deployable services** — Next.js 14 on Vercel and FastAPI backend-v2 on Render.

bash
1$ Next.js 14 (Vercel)
2$ │ JWT · /api/v2/*
3$ ▼
4$ FastAPI backend-v2 (Render)
5$ │
6$ ▼
7$ ┌──────────────── LangGraph pipeline ─────────────────┐
8$ │ Router ──▶ Scope Guard ──┬──▶ Subject Agent ×8 │
9$ │ (intent + (reject │ RAG + specialist│
10$ │ subject) off-topic) │ prompt │
11$ │ └──▶ Evaluator │
12$ │ (adaptive quiz) │
13$ │ ──▶ Memory Writer │
14$ └───────────────────────────┬─────────────────────────┘
15$ ▼
16$ Groq (llama-3.3-70b) · pgvector RAG · Redis + Mem0
17$ ▼
18$ Neon PostgreSQL — chats · messages · concept_mastery

**Frontend** (frontend/): Next.js 14 App Router, React 18, TypeScript, Tailwind CSS, Framer Motion, Radix UI, KaTeX, react-markdown, @react-oauth/google. Routes: / (Dockit landing), /login (Google + email tabs), /chat (authenticated workspace). Landing sections built from components/dockit/ — purple → coral → gold gradient on #0d0d0d dark theme. Chat UI loads sessions via GET /api/v2/sessions and messages via GET /api/v2/sessions/:id/messages; JWT stored in localStorage (intellecta-token). Image upload supports JPEG/PNG/WebP up to ~4 MB inline in the composer.

**Backend** (backend-v2/): FastAPI entry intellecta.main:app, Pydantic settings, async SQLAlchemy 2 + asyncpg, Gunicorn with Uvicorn workers on Render. Public: GET /api/v2/health (agent list + RAG chunk count). Auth: POST /api/v2/auth/register, /login, /google (id_token), GET /api/v2/auth/me. Chat: POST /api/v2/chat, /chat/image. Sessions: list, fetch messages, delete.

**LangGraph pipeline:** User message → Router (intent + subject) → Scope Guard (reject off-topic) → quiz/evaluate path goes to Evaluator (adaptive difficulty 1–5); learn/clarify path goes to Subject Agent (RAG + specialist prompt) → Memory Writer.

Router uses llama-3.1-8b-instant; answers use llama-3.3-70b-versatile. Eight specialists: Mathematics, Physics, Chemistry, Biology, History, Politics, Geography, Economics — each with dedicated LangGraph node, system prompt, and pgvector filter on documents.subject.

**RAG:** FastEmbed BAAI/bge-small-en-v1.5 (384-dim) embeddings stored in PostgreSQL document_chunks with pgvector cosine search. Curriculum seeded via python -m intellecta.scripts.seed_rag (32 chunks: 8 subjects × 4 concepts). Weak topics from concept_mastery boost retrieval relevance.

**Hybrid memory:** Redis/Upstash (24h TTL session cache) + Mem0 (optional long-term semantic insights) + PostgreSQL (users, chat_sessions, messages, concept_mastery, quiz_results).

**Vision pipeline:** Groq vision model analyzes uploaded images before the same Router → Agent flow runs on extracted description + optional user text.

Key Engineering Decisions

  • •Rebuilt backend from Flask/SQLite v1 to FastAPI + LangGraph v2 — stateful multi-node graph (Router → Scope Guard → 8 agents → Evaluator → Memory Writer) replaces a single TutorAgent classifier; enables quiz mode, off-topic rejection, and per-subject RAG in one orchestration layer.
  • •Expanded from 4 to 8 subject specialists (added Biology, Politics, Geography, Economics) with a Scope Guard that politely declines non-academic queries — product is scoped to school/university study only, not a general chatbot.
  • •Moved chat history from browser `localStorage` to PostgreSQL with Redis short-term cache — cross-device sync when logged in; clearing browser data no longer wipes revision threads.
  • •Added pgvector RAG instead of prompt-only answers — syllabus chunks per subject keep responses exam-focused; health endpoint exposes `embedded_chunks` count for deploy verification.
  • •Split Next.js (Vercel) and FastAPI (Render) with `NEXT_PUBLIC_BACKEND_V2_URL` — Groq keys, JWT secrets, and database URLs never reach the client bundle.
  • •Google Sign-In + email/password dual auth — one-click OAuth from landing header and login card reduces friction for students who already use Google Workspace.
  • •Adaptive quiz engine via Evaluator node — students say *quiz me on photosynthesis* and difficulty scales 1–5 per concept based on `concept_mastery` and answer quality, turning Q&A into a retention loop.
  • •Dockit-style landing + split login layout — hero with popular subject chips seeds intent before auth; marketing left / form right on `/login` matches modern ed-tech conversion patterns.
  • •Chose Groq (`llama-3.3-70b-versatile` + fast router model) for sub-2s responses on free-tier infra — speed matters when students are stuck on homework at midnight.
  • •KaTeX + mhchem in chat bubbles — STEM credibility lives on whether $\frac{d}{dx}\tan x$ and ionic bonds render readable, not escaped ASCII.

Business / Product Thinking

IntellectA sits in the **exam-prep and daily-homework wedge** — students who need clarity, syllabus alignment, and speed, not another feature-heavy LMS. Positioning: *AI Study Partner with eight visible subject experts* — a concrete differentiator from generic ChatGPT.

**Product-led hook:** landing hero search bar + popular subject chips (Mathematics, Physics, Chemistry, Biology, History, Politics, Geography, Economics) → sign in → ask or upload → see which specialist answered with formatted LaTeX in seconds.

**Go-to-market:** live app at intellect-a.vercel.app → open-source GitHub → JEE/board prep communities, university study groups, LinkedIn posts with chat screenshots. MIT license encourages forks.

**Monetization paths (documented, not shipped):** daily message caps on free tier, unlimited + mock-test modes paid, institution workspaces with shared analytics.

**Trust signals:** JWT + Google OAuth, no API keys in client, Scope Guard for off-topic rejection, server-synced history, CORS locked to Vercel domain in production.

Results & Impact

Live at intellect-a.vercel.app — frontend on Vercel, backend-v2 API on Render.

**v2 shipped (product):** 8 subject experts with smart routing · Scope Guard (off-topic rejection) · text + image doubts (Groq vision) · KaTeX + mhchem rich answers · adaptive quizzes (*quiz me on [topic]*) · Google Sign-In + email auth · cloud-synced chat sessions (PostgreSQL) · cross-device continuity · agent badges in UI (e.g. Mathematics) · Dockit landing (features, 3-step flow, FAQ, testimonials) · split login page · resizable sidebar · regenerate / stop · light/dark theme · mobile drawer.

**v2 shipped (platform):** LangGraph orchestration (Router → Scope Guard → 8 agents → Evaluator → Memory Writer) · pgvector RAG (FastEmbed 384-dim, 32 seeded curriculum chunks) · hybrid memory (Redis 24h TTL + Mem0 optional + concept_mastery) · async SQLAlchemy + Neon PostgreSQL · JWT HS256 (7-day) · GET /api/v2/health with agent list + RAG count · Gunicorn/Uvicorn on Render.

Open source (MIT) at github.com/subhm2004/IntellectA with full README, backend-v2/ARCHITECTURE.md, schema migrations, RAG seed script, and Vercel + Render deployment checklist.

What I'd Do Differently

Add streaming token delivery so long calculus derivations feel live instead of waiting for the full block. Expand RAG beyond 32 seeded chunks — let students upload syllabus PDFs per board (CBSE, ICSE, state boards). Institution admin dashboards with class-level weak-topic analytics. Rate limiting per user tier on the API layer. PWA shell for offline access to pinned threads. v1 Flask backend is deprecated in-repo; a clean removal PR would reduce onboarding confusion for contributors.

Tech Stack

Next.js
React
TypeScript
Tailwind CSS
FastAPI
LangGraph
Groq API
PostgreSQL
pgvector
Redis
JWT
KaTeX
Vercel
Render
GitHub

Want to see more?

View All Projects