File size: 7,780 Bytes
9af8807
441f415
a5ce938
441f415
 
a5ce938
 
9af8807
441f415
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
---
title: LearnCraft
emoji: πŸŽ“
colorFrom: blue
colorTo: purple
sdk: streamlit
sdk_version: 1.32.0
app_file: app.py
pinned: true
license: mit
short_description: Personalized AI Learning Platform
tags:
  - education
  - learning
  - ai-tutor
  - quiz
  - flashcards
  - groq
  - llama
  - streamlit
  - gamification
  - study-tools
---

# πŸŽ“ LearnCraft β€” Personalized AI Learning Platform

> Generate personalized study material, flashcards & quizzes tailored exactly to your level and learning goals β€” powered by **Groq LLaMA-3.3-70b**.

![Python](https://img.shields.io/badge/Python-3.9+-6C47FF?style=flat-square&logo=python&logoColor=white)
![Streamlit](https://img.shields.io/badge/Streamlit-1.32+-FF4B4B?style=flat-square&logo=streamlit&logoColor=white)
![Groq](https://img.shields.io/badge/Groq-LLaMA--3.3--70b-F97316?style=flat-square&logoColor=white)
![License](https://img.shields.io/badge/License-MIT-10B981?style=flat-square)

---

## 🌟 What is LearnCraft?

LearnCraft is a fully AI-powered learning platform that generates **customized study content** based on your chosen topic and difficulty level. Whether you're a beginner learning Python or an advanced student studying Quantum Mechanics β€” LearnCraft adapts everything to you.

### How it works:
1. **Pick a topic** β€” anything from Calculus to Climate Change
2. **Choose your level** β€” Beginner, Intermediate, or Advanced
3. **Get personalized content** β€” notes, quizzes, flashcards and an AI tutor instantly
4. **Track your progress** β€” earn XP, unlock badges and monitor your scores

---

## ✨ Features

| Feature | Description |
|---|---|
| πŸ“š **Study Content Generator** | AI-generated notes in 4 styles: Summary Notes, Detailed Explanation, Bullet Points, Concept Map |
| πŸƒ **Flashcard Studio** | Auto-generated flip-card decks (up to 20 cards) for any topic |
| 🧩 **Quiz Engine** | MCQ, True/False, Fill-in-the-Blank, Short Answer β€” with optional timed mode |
| πŸ€– **AI Tutor Chat** | Multi-turn conversational AI tutor with topic context and full conversation memory |
| πŸ… **Gamification** | XP points, 7 levels (Seedling β†’ Genius), 15 badges, daily streak tracking |
| πŸ“„ **PDF Export** | Download study notes and quiz results as branded A4 PDFs |
| πŸ“Š **Progress Dashboard** | Score history chart, per-topic best scores, weak topic detection |
| πŸ“ **Notes** | Save, search and delete personal notes during study sessions |

---

## πŸš€ Running on Hugging Face Spaces

This app runs directly on Hugging Face Spaces using the **Streamlit SDK**.

### βš™οΈ Required Secret

You must add your **Groq API key** as a Space secret for the app to work:

1. Go to your Space β†’ **Settings** β†’ **Repository secrets**
2. Add a new secret:
   - **Name:** `GROQ_API_KEY`
   - **Value:** your Groq API key from [console.groq.com](https://console.groq.com)

> Get a free Groq API key at **https://console.groq.com** β€” it takes under a minute.

### πŸ“‚ Files required in your Space

```
app.py
content_generator.py
quiz_generator.py
flashcard_generator.py
tutor.py
evaluation.py
gamification.py
pdf_export.py
utils.py
requirements.txt
README.md
```

---

## πŸ”‘ API Key Configuration

The app reads the Groq API key from the environment. Make sure each module uses:

```python
import os
GROQ_API_KEY = os.environ.get("GROQ_API_KEY", "")
```

> If you're running **locally**, set the variable in your terminal:
> ```bash
> export GROQ_API_KEY="gsk_your_key_here"   # macOS/Linux
> set GROQ_API_KEY=gsk_your_key_here         # Windows
> ```

---

## πŸ“¦ Requirements

```
streamlit>=1.32.0
pandas>=2.0.0
groq>=0.4.0
reportlab>=4.0.0
plotly>=5.18.0
```

---

## πŸ—ΊοΈ App Pages

| Page | Description |
|---|---|
| 🏠 **Home** | Hero banner, feature overview, quick-start buttons, recent activity feed |
| πŸ“š **Study Content** | Generate AI study notes with key terms, summary and PDF export |
| πŸƒ **Flashcards** | Navigate AI-generated flip cards with progress bar and deck overview |
| 🧩 **Take Quiz** | Timed quiz with instant results, XP awards and PDF download |
| πŸ€– **AI Tutor** | Chat with an AI tutor β€” quick-start prompts and topic context |
| πŸ… **Achievements** | XP level hero card, badge gallery, streak and stats |
| πŸ“Š **My Progress** | Score history, per-topic performance table, weak topic alerts |
| πŸ“ **My Notes** | Searchable saved notes from study sessions |

---

## πŸ… Gamification

### Earn XP for every learning action:

| Action | XP |
|---|---|
| Study session | +10 XP |
| Flashcard deck | +10 XP |
| Complete a quiz | +20 XP |
| Score β‰₯ 60% | +15 XP |
| Score β‰₯ 80% | +30 XP |
| Perfect score (100%) | +50 XP |

### 7 Levels:
```
🌱 Seedling (0 XP)  β†’  πŸ“– Reader (50)  β†’  πŸŽ“ Student (150)  β†’  πŸ”¬ Scholar (300)
β†’  πŸ† Expert (500)  β†’  🌟 Master (800)  β†’  πŸš€ Genius (1200)
```

### 15 Badges to unlock:
| Badge | How to Earn |
|---|---|
| 🎯 First Quiz | Complete your first quiz |
| πŸ’― Perfect Score | Score 100% on a quiz |
| πŸ”₯ 3-Day Streak | Study 3 days in a row |
| ⚑ Week Warrior | Study 7 days in a row |
| πŸ—“οΈ Fortnight Hero | Study 14 days in a row |
| πŸ—ΊοΈ Explorer | Study 5 different topics |
| 🧠 Polymath | Study 10 different topics |
| 🧩 Quiz Master | Complete 10 quizzes |
| πŸ… Quiz Champion | Complete 25 quizzes |
| πŸŽ‰ High Achiever | Score above 80% |
| πŸƒ Card Shark | Complete a flashcard deck |
| πŸ”¬ Scholar | Reach Scholar level (300 XP) |
| πŸ† Expert | Reach Expert level (500 XP) |
| 🌟 Master | Reach Master level (800 XP) |
| πŸ“ Note Taker | Save your first note |

---

## πŸ“ Architecture

```
User (Browser)
      β”‚
      β–Ό
app.py  (Streamlit β€” routing, session state, UI)
      β”‚
      β”œβ”€β”€ content_generator.py  ──┐
      β”œβ”€β”€ quiz_generator.py       β”œβ”€β”€β–Ί Groq API (LLaMA-3.3-70b)
      β”œβ”€β”€ flashcard_generator.py  β”‚
      β”œβ”€β”€ tutor.py             β”€β”€β”€β”˜
      β”‚
      β”œβ”€β”€ evaluation.py        ── Quiz answer scoring
      β”œβ”€β”€ gamification.py      ── XP / badges / streak
      β”œβ”€β”€ pdf_export.py        ── ReportLab PDF generation
      └── utils.py             ── JSON persistence
                                   (learning_progress.json,
                                    notes.json,
                                    gamification.json)
```

---

## πŸ’‘ Topics You Can Study

LearnCraft works with **any topic you type**, plus these built-in suggestions:

`Photosynthesis` Β· `Machine Learning` Β· `World War II` Β· `Python Functions` Β· `Calculus` Β· `Climate Change` Β· `The French Revolution` Β· `DNA Replication` Β· `Object-Oriented Programming` Β· `The Solar System` Β· `Economics Supply & Demand` Β· `Quantum Mechanics`

---

## πŸ”’ Data & Privacy

- All progress, notes and gamification data are stored in **local JSON files** within the Space
- No user data is sent anywhere except to the **Groq API** for content generation
- The Groq API is used solely for generating educational content
- On Hugging Face Spaces, persistent storage resets when the Space restarts β€” data is session-local

---

## πŸ› οΈ Local Development

```bash
# 1. Clone the Space
git clone https://huggingface.co/spaces/YOUR_USERNAME/learncraft
cd learncraft

# 2. Install dependencies
pip install -r requirements.txt

# 3. Set your API key
export GROQ_API_KEY="gsk_your_key_here"

# 4. Run
streamlit run app.py
```

---

## πŸ“„ License

MIT License β€” free to use, modify and distribute.

---

<div align="center">
  Built with ❀️ using <strong>Streamlit</strong> · <strong>Groq</strong> · <strong>ReportLab</strong> · <strong>Python</strong>
  <br><br>
  <em>πŸŽ“ LearnCraft β€” Learn smarter, not harder.</em>
</div>