Cranium is a production-ready Next.js + Supabase application that turns uploaded documents into AI-generated mind maps, then layers on summaries, explanations, flashcards, MCQs, and subjective evaluation.
- Next.js 15 App Router
- TypeScript
- Tailwind CSS
- React Flow (
@xyflow/react) - Supabase Auth, Postgres, Storage
- xAI Grok API via the OpenAI-compatible SDK
pdf-parse,mammoth,jszipfor file parsing
- Install dependencies:
npm install- Copy environment variables:
cp .env.example .env.local- Fill these values in
.env.local:
NEXT_PUBLIC_SUPABASE_URL=https://your-project-ref.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
GROK_API_KEY=your-grok-key
GROK_MODEL=grok-4-0709
GROK_BASE_URL=https://api.x.ai/v1
NEXT_PUBLIC_SITE_URL=http://localhost:3000-
In Supabase SQL editor, run
supabase/schema.sql. -
Start the app:
npm run dev- Open
http://localhost:3000.
- Create a new Supabase project.
- Enable Email/Password auth in Authentication > Providers.
- Run the schema SQL.
- Confirm the
documentsstorage bucket exists. - Add the site URL and redirect URL:
- Site URL:
http://localhost:3000 - Redirect URL:
http://localhost:3000/api/auth/callback
- Site URL:
- Push this repo to GitHub.
- Import the repo in Vercel.
- Add the same environment variables from
.env.local. - Set
NEXT_PUBLIC_SITE_URLto your Vercel production URL. - Deploy.
- Update Supabase redirect URLs to include:
https://your-domain.vercel.app/api/auth/callback
app/: pages and route handlerscomponents/: reusable UI and interactive workspace moduleslib/: auth, Supabase clients, Grok integration, parsers, persistence logicsupabase/: SQL schema and database setupstyles/: shared CSS tokensutils/: lightweight shared fetch utility
- Upload a document from the dashboard
- Parse source text on the server
- Generate structured topics with Grok
- Convert topics into persisted map nodes
- Render the graph with React Flow
- Generate revision sets on demand from map scope
- Evaluate subjective answers with grounded AI feedback