This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend
What I Built
My friend is cramming for mid-term exams and has been spending hours re-reading notes without actually retaining anything. I built StudyBuddy CLI — a terminal-based AI study companion that turns messy notes into smart flashcards and quizzes you using spaced repetition, so you actually learn instead of just memorizing.
The killer feature? It runs 100% locally on their laptop using Ollama. No accounts, no cloud uploads, no subscriptions. Their study data — including potentially sensitive class notes — never leaves their machine.
Here's what it does:
- 📚 Paste notes, import a PDF, or speak into your mic → AI generates Q&A flashcards instantly
- 🧠 SM-2 Spaced Repetition — the same algorithm SuperMemo uses. Cards you struggle with appear more often
- 💡 AI Explanations — get a question wrong and the AI explains why the answer is correct
- 📊 Progress Tracking — streaks, accuracy, weekly activity charts, per-deck mastery breakdowns
- 🎤 Voice Input — speak your notes via a browser companion page (Web Speech API)
- 🔄 Swap Models — switch between Llama, Mistral, Phi, or any Ollama model
When I showed it to my friend, they said: "Wait, this runs offline? I can use this during study sessions at the library where the WiFi is terrible." That's exactly the point.
Demo
Here's what the CLI looks like when you launch it:
___ _ _ ___ _ _
/ __| |_ _ _ __| |_ _| _ )_ _ __| |__| |_ _
\__ \ _| || / _` | || | _ \ || / _` / _` | || |
|___/\__|\_, \__,_|\_, |___/\_,_\__,_\__,_|\_, |
|__/ |__/
AI-Powered Study Companion • Ollama • 100% Local
✔ Connected to Ollama • llama3.2:latest
🔥 5-day streak │ 📚 3 decks │ 🃏 42 cards │ 🎯 85% accuracy
The quiz flow works like this:
- See a question
- Type your answer
- Self-assess (correct / wrong / partial)
- If wrong → get an AI-powered explanation
- SM-2 schedules when you'll see that card next
The progress dashboard tracks everything:
🔥 Current Streak: 5 days | 🏆 Longest: 12 days
┌───────────────┬──────┐
│ Cards Studied │ 150 │
│ Correct │ 120 │
│ Incorrect │ 30 │
│ Accuracy │ 80% │
│ Decks Created │ 5 │
└───────────────┴──────┘
📊 Last 7 Days
Mon ███████████ 11
Tue ████████████████ 16
Wed ██████████ 10
Thu ░ 0
Fri ████████ 8
Sat █████████████ 13
Sun ███████████████ 15
Code
🎓 StudyBuddy CLI
AI-powered study companion with spaced repetition — runs 100% locally with Ollama.
Built for a friend who's cramming for exams and deserves a study tool that respects their privacy, works offline, and actually helps them learn — not just memorize.
✨ Features
- 📚 Smart Flashcard Generation — Paste notes, import a PDF, or speak into your mic. The AI generates high-quality Q&A flashcards instantly.
- 🧠 Spaced Repetition (SM-2) — The same algorithm SuperMemo uses. Cards you struggle with appear more often; cards you've mastered fade back.
- 💡 AI Explanations — Get it wrong? The AI explains why the answer is correct, in a way that helps you actually understand.
- 📊 Progress Tracking — Streaks, accuracy, daily activity charts, and per-deck mastery breakdowns.
- 📄 PDF Import — Drop in a textbook chapter PDF and get flashcards in seconds.
- 🎤 Voice Input — Speak your notes through a browser…
Architecture
studybuddy-cli/
├── bin/studybuddy.js # CLI entry point
├── src/
│ ├── index.js # Interactive menus
│ ├── ai/ollama.js # Ollama REST API client
│ ├── cards/
│ │ ├── generator.js # AI flashcard generation
│ │ ├── importer.js # PDF/text extraction
│ │ └── manager.js # Deck & card CRUD
│ ├── quiz/
│ │ ├── engine.js # Quiz runner
│ │ └── sm2.js # SM-2 algorithm
│ ├── progress/tracker.js # Streaks & stats
│ ├── ui/
│ │ ├── display.js # Banner, dashboard
│ │ └── theme.js # Color palette
│ └── voice/
│ ├── page.html # Web Speech API page
│ └── server.js # Local HTTP server
├── LICENSE # MIT
└── README.md
All data is stored locally in ~/.studybuddy/ as JSON files — one per deck, plus a global progress file.
How I Built It
Open-source AI stack:
- Ollama — runs open-weight models locally (Llama 3.2, Mistral, Phi, Gemma)
- Node.js ESM — cross-platform CLI runtime
- SM-2 Algorithm — the proven spaced repetition algorithm from SuperMemo
- Web Speech API — browser-based voice recognition for hands-free note input
- pdf-parse — extract text from PDF textbooks
The AI is used in two key places:
1. Flashcard generation — a carefully crafted system prompt tells Ollama to produce Q&A pairs as a JSON array from raw text. The parser handles markdown fences, leading prose, and other LLM quirks gracefully.
2. Wrong-answer explanations — when you get a card wrong, a second prompt asks the model to explain why the correct answer is right, given what you said. It's encouraging, not condescending. Here's a real example:
Q: What is the primary pigment in photosynthesis?
Your answer: Carotene
AI: You were close! Carotene is indeed an important pigment in plants, but it's not the primary one. Chlorophyll is the superstar of photosynthesis — it's the pigment that absorbs light mainly in the red and blue wavelengths, which is why plants appear green.
The interactive terminal UI uses chalk for colors, figlet for the ASCII banner, gradient-string for gradient effects, ora for spinners, and @inquirer/prompts for the menu system.
Why Does Open Innovation Matter?
| Concern | How StudyBuddy handles it |
|---|---|
| Privacy | Study notes never leave the machine. No API keys, no cloud. My friend studies medical terminology — that data shouldn't be on someone else's server. |
| Offline | Works in a library with no WiFi. Once the model is downloaded, zero internet needed. |
| Cost | Free forever. No per-token charges. A broke college student shouldn't have to pay to study. |
| Flexibility | Swap models instantly. Llama 3.2 for quality, Phi for speed on an older laptop. |
| Transparency | Every prompt is in the source code. No black-box behavior — you can see exactly what the AI is told to do. |
A closed API couldn't do this. It would require internet, cost money per question, and send study notes to a server my friend doesn't control. Open-source AI made it possible to build a tool that's genuinely theirs.
Top comments (0)