Generate smart Q&A flashcards from any text or PDF using Mistral AI, with built-in spaced repetition (SM-2 algorithm) powered by Supabase.
- AI Generation — Paste text or upload a PDF; Mistral Large generates focused Q&A flashcards
- Spaced Repetition — SM-2 algorithm schedules reviews at optimal intervals
- 4-Level Rating — Again / Hard / Good / Easy updates each card's schedule
- Session Stats — Track your performance at the end of each study session
- Keyboard Shortcuts — Space to flip, 1-4 to rate cards
- Dark Editorial UI — Built with Next.js 14, Tailwind CSS, and Framer Motion
| Layer | Tech |
|---|---|
| Frontend | Next.js 14 (App Router) |
| Styling | Tailwind CSS |
| AI | Mistral API (mistral-large-latest) |
| Database | Supabase (PostgreSQL) |
| Algorithm | SM-2 Spaced Repetition |
- Node.js v20+ — Download here or use
nvm:nvm install 20 nvm use 20
git clone <your-repo>
cd flashcard-ai
npm install- Go to supabase.com → create a new project
- Open the SQL Editor
- Run the contents of
supabase-schema.sql - Copy your project URL and keys from Settings → API
- Go to console.mistral.ai → create an API key
- Copy the key
cp .env.local.example .env.localEdit .env.local:
MISTRAL_API_KEY=your_mistral_api_key
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
npm run dev- Generate — Paste text or upload a PDF, choose card count (5/10/15/20), click Generate
- Browse — Click a deck to see all cards and their review schedule
- Review — Hit "Review N cards" to start a study session
- Rate — After flipping each card, rate it: Again / Hard / Good / Easy
- Repeat — Cards you struggle with appear sooner; easy cards are scheduled further out
flashcard-ai/
├── app/
│ ├── page.tsx # Home: input + deck list
│ ├── study/[deckId]/page.tsx # Study mode
│ ├── api/
│ │ ├── generate/route.ts # POST: generate cards via Mistral
│ │ ├── decks/route.ts # GET/DELETE decks
│ │ └── flashcards/route.ts # GET/PATCH flashcards + SM-2
│ ├── layout.tsx
│ └── globals.css
├── lib/
│ ├── mistral.ts # Mistral AI client + prompts
│ ├── supabase.ts # Supabase client + types
│ └── spacedRepetition.ts # SM-2 algorithm
├── supabase-schema.sql # Database schema
└── .env.local.example
Each card tracks:
- ease_factor — how easy/difficult the card is (default 2.5)
- interval — days until next review
- repetitions — consecutive correct answers
After rating a card:
- Again (0) → resets to day 1
- Hard (2) → resets to day 1, lowers ease factor
- Good (4) → interval × ease factor, slight ease adjustment
- Easy (5) → interval × ease factor, increases ease factor
# Vercel (recommended)
npx vercel
# Or build locally
npm run build
npm startAdd your environment variables in the Vercel dashboard under Project → Settings → Environment Variables.