A Node.js REST API backend for the TobeTon application, featuring AI-powered study tools including flashcard generation, quiz generation, summarization, RAG-based chatbot, and study suggestions.
- Authentication — JWT-based user registration and login with bcrypt password hashing
- Flashcard Generation — AI-generated flashcards organized into folders
- Quiz Generation — AI-generated multiple-choice quizzes with progress tracking
- Summarization — AI-powered document and note summarization
- RAG Chatbot — Retrieval-Augmented Generation chatbot using ingested notes
- Study Suggestions — Personalized AI study recommendations
- Achievements — User achievement tracking (e.g. folders created, study streaks)
- Statistics — Per-user quiz scores, study time, and daily activity tracking
- Runtime: Node.js
- Framework: Express.js v5
- Database: SQLite (
sqlite3)
- Auth: JSON Web Tokens (
jsonwebtoken) + bcryptjs
- AI Integration: RAG pipeline with local vector store
- Dev Tools:
nodemon, dotenv
- AI Tool: Ollama and LM Studio
TobeTon_Backend/
├── controllers/
│ ├── achievementController.js
│ ├── authController.js
│ ├── cardsController.js
│ ├── chatbotController.js
│ ├── flashcardsController.js
│ ├── flashcardsGenerator.js # AI flashcard generation
│ ├── folderController.js
│ ├── quizGenerator.js # AI quiz generation
│ ├── quizzesController.js
│ ├── statisticsController.js
│ ├── studySuggestionsController.js
│ └── summaryController.js
├── data/
│ └── statistics.json
├── db/
│ ├── database.js # Schema + SQLite connection
│ └── database.sqlite
├── middleware/
│ └── authMiddleware.js # JWT verification
├── rag/
│ ├── embed.js
│ ├── ingestTXT.js # Ingests notes.txt on server start
│ ├── retrieve.js
│ └── vectorStore.js
├── routes/
│ ├── achievement.js
│ ├── auth.js
│ ├── cards.js
│ ├── flashcards.js
│ ├── folder.js
│ ├── quiz.js
│ ├── statisticsRoutes.js
│ ├── studySuggestions.js
│ ├── summary.js
│ └── users.js
├── services/
│ ├── cardService.js
│ ├── chatbotService.js
│ ├── flashcardService.js
│ ├── quizSaveService.js
│ ├── ragService.js
│ ├── studySuggestionService.js
│ └── summaryService.js
├── uploads/
│ └── notes.txt # Ingested into RAG vector store on startup
├── utils/
│ ├── clean.js
│ ├── format.js
│ ├── jsonExtractor.js
│ └── jsonObjectExtractor.js
├── validators/
├── .gitignore
├── package.json
└── server.js
The SQLite database is initialized automatically on first run via db/database.js.
| Table |
Description |
users |
Stores user credentials (username, hashed password) |
folders |
Study folders per user, with subject, topic, and difficulty |
cards |
Flashcards belonging to a folder and user |
quizzes |
Multiple-choice quiz questions linked to folders and cards |
quiz_progress |
Tracks which cards have been quizzed per folder |
achievements |
Defines available achievements and unlock conditions |
user_achievements |
Records which achievements each user has earned |
statistics |
Aggregate study stats per user (scores, time, quiz counts) |
daily_statistics |
Daily breakdown of flashcard and quiz study time |
All routes are prefixed from the server root. Routes marked 🔒 require an Authorization: Bearer <token> header.
| Method |
Route |
Auth |
Description |
| POST |
/auth/register |
|
Register a new user |
| POST |
/auth/login |
|
Login and receive a JWT |
| Method |
Route |
Auth |
Description |
| GET |
/users/profile/:userId |
|
Get user profile |
| PUT |
/users/update-username |
|
Update username |
| PUT |
/users/update-password |
|
Update password |
| Method |
Route |
Auth |
Description |
| GET |
/folders/get |
🔒 |
Get all folders for the authenticated user |
| POST |
/folders/create |
🔒 |
Create a new folder |
| PUT |
/folders/:id |
🔒 |
Update a folder |
| DELETE |
/folders/:id |
🔒 |
Delete a folder |
| Method |
Route |
Auth |
Description |
| GET |
/cards/folder/:folder_id |
🔒 |
Get all cards in a folder |
| POST |
/cards/create |
🔒 |
Create a new card |
| PUT |
/cards/:id |
🔒 |
Update a card |
| DELETE |
/cards/:id |
🔒 |
Delete a card |
| Method |
Route |
Auth |
Description |
| GET |
/flashcards/folder/:folder_id |
🔒 |
Get all flashcards in a folder |
| GET |
/flashcards/:id |
🔒 |
Get a single flashcard |
| GET |
/flashcards/random/:folder_id |
🔒 |
Get random flashcards from a folder |
| GET |
/flashcards/search |
🔒 |
Search flashcards |
| POST |
/flashcards/study |
🔒 |
Mark a flashcard as studied / update study time |
| POST |
/flashcards/save-cards |
🔒 |
Bulk save AI-generated flashcards |
| POST |
/flashcardsAI |
|
Generate AI flashcards |
| Method |
Route |
Auth |
Description |
| GET |
/quiz/folder/:folder_id |
🔒 |
Get all quizzes in a folder |
| POST |
/quiz/create |
🔒 |
Create a quiz question |
| POST |
/quiz/:id/submit |
🔒 |
Submit an answer for a quiz question |
| POST |
/quiz/save-bulk |
🔒 |
Bulk save AI-generated quiz questions |
| DELETE |
/quiz/:id |
🔒 |
Delete a quiz question |
| POST |
/quizAI |
|
Generate AI quiz questions |
| Method |
Route |
Auth |
Description |
| POST |
/chatbot |
|
Chat with the RAG-powered chatbot |
| POST |
/summary/summary-sse |
|
Generate a summary (Server-Sent Events) |
| POST |
/suggestion/study-suggestions |
|
Get AI study suggestions |
| Method |
Route |
Auth |
Description |
| GET |
/achievements/:userId |
|
Get achievements for a user |
| Method |
Route |
Auth |
Description |
| GET |
/statistics |
🔒 |
Get aggregate statistics for the authenticated user |
| GET |
/statistics/weekly |
🔒 |
Get weekly study stats |
| PUT |
/statistics/quiz |
🔒 |
Update quiz score statistics |
| PUT |
/statistics/quiz-study-time |
🔒 |
Update quiz study time |
| PUT |
/statistics/study-time |
🔒 |
Update flashcard study time |
| PUT |
/statistics/app-usage |
🔒 |
Update total app usage time |
Developers: 4
Mission: Creating an intelligent study companion that makes learning engaging, efficient, and personalized.