AI-powered learning platform with RAG, Quiz, Flashcards, Explain, Resume β and local n8n AI Agent automation.
π Hugging Face Space: [https://huggingface.co/spaces/ApyHTML19/PaperBrainAI]
---| Feature | Description |
|---|---|
| π¬ General Chat | AI-powered study assistant (Qwen 2.5-72B) |
| π RAG Mode | Ask questions based on your uploaded documents |
| π§ͺ Quiz | Auto-generated MCQ quizzes on any topic |
| π Flashcards | Smart flashcards for memorization |
| π‘ Explain | Concept explanations at beginner / intermediate / advanced level |
| π Resume | Auto-summarize any text or document |
| π Document Manager | Upload PDF, TXT, DOCX β indexed per user |
| π€ Auth | JWT-based register/login with user isolation |
| π Profile & Stats | Quiz history, streaks, progression tracking |
| π n8n AI Agent | Local AI Agent with Ollama llama3.1/Qwen 2.5 (Locally/Pre-trained Model on HuggingFace + 5 tools |
PaperBrain/
βββ backend/ # FastAPI Python backend
β βββ app/
β β βββ auth/
β β β βββ jwt_handler.py # JWT token creation/decoding
β β β βββ middleware.py # get_current_user dependency
β β βββ db/
β β β βββ database.py # SQLite + SQLAlchemy setup
β β β βββ models.py # User, QuizResult, StudySession models
β β β βββ crud.py # DB operations
β β βββ tools/ # AI tool modules
β β βββ agent.py # Main AI dispatcher
β β βββ ingest.py # Document ingestion + chunking
β β βββ rag.py # ChromaDB vector store
β β βββ router_service.py # All API routes
β β βββ schemas.py # Pydantic request models
β β βββ main.py # FastAPI app entry point
β βββ Dockerfile
β βββ requirements.txt
βββ frontend/ # React frontend
β βββ src/
β βββ pages/
β βββ Chat.jsx
β βββ Quiz.jsx
β βββ Flashcards.jsx
β βββ Documents.jsx
β βββ Profile.jsx
βββ n8n/ # Local n8n AI Agent workflows
β βββ workflows/
β βββ PaperBrain.json
βββ docs/
βββ logo.png
βββ n8n-workflow.png
PaperBrain includes a local n8n AI Agent powered by Ollama llama3.1 that orchestrates all learning tools automatically.
[Input Postman / Frontend]
β
[AI Agent For RAG] ββ [Ollama - llama3.1]
β
βββββββ΄βββββββββββββββββββββββββββββββ
β β
[Flashcards Tool] [Explain Tool] [RAG Tool] [Resume Tool] [Quiz Tool]
β
[Output Frontend]
| Tool | Description |
|---|---|
| π Flashcards Tool | Generate flashcards on any topic |
| π‘ Explain Tool | Explain a concept at any level |
| π RAG Tool | Search course documents for answers |
| π Resume Tool | Summarize topics automatically |
| π§ͺ Quiz Tool | Generate MCQ quiz questions |
# Install n8n
npm install -g n8n
# Start n8n
n8n start
# β Access at http://localhost:5678
# Install Ollama
# https://ollama.com/download
# Pull llama3.1
ollama pull llama3.1- Open n8n at
http://localhost:5678 - Go to Workflows β Import
- Import
n8n/workflows/PaperBrain.json - Configure the Ollama node with your local URL:
http://localhost:11434 - Publish the workflow
Backend
- FastAPI β REST API
- SQLite + SQLAlchemy β Database
- ChromaDB β Vector store for RAG
- HuggingFace InferenceClient β Cloud AI (Qwen2.5-72B)
- python-jose β JWT authentication
- pdfplumber + python-docx β Document parsing
Frontend
Local AI Automation
Deployment
- Hugging Face Spaces β Docker deployment
- Python 3.10+
- Node.js 18+
- Ollama (for n8n local AI)
git clone https://github.com/ApyHtml20/PaperBrain.git
cd PaperBraincd backend
pip install -r requirements.txtCreate .env:
HF_TOKEN=your_huggingface_token
HF_MODEL=Qwen/Qwen2.5-72B-Instruct
SECRET_KEY=your_secret_key_hereuvicorn app.main:app --reload --port 8000cd frontend
npm install
npm run devollama pull llama3.1
n8n start| Method | Route | Description |
|---|---|---|
| POST | /api/auth/register |
Create new account |
| POST | /api/auth/login |
Login and get JWT token |
| Method | Route | Description |
|---|---|---|
| POST | /api/chat |
General AI chat |
| POST | /api/rag-qa |
Chat with your documents |
| POST | /api/quiz |
Generate MCQ quiz |
| POST | /api/flashcards |
Generate flashcards |
| POST | /api/explain |
Explain a concept |
| POST | /api/resume |
Summarize text |
| Method | Route | Description |
|---|---|---|
| GET | /api/documents |
List your documents |
| POST | /api/upload |
Upload PDF/TXT/DOCX |
| DELETE | /api/documents/{filename} |
Delete a document |
FROM python:3.11-slim
WORKDIR /code
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]HF Spaces secrets (Settings β Variables and secrets):
HF_TOKEN=...
HF_MODEL=Qwen/Qwen2.5-72B-Instruct
SECRET_KEY=...
- Passwords hashed with SHA-256 + random salt
- JWT tokens expire after 24 hours
- All routes protected by auth middleware
- Documents isolated by
user_idin ChromaDB - Files stored in
documents/{user_id}/


