Skip to content

muskiteer/SubRevision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽ“ SubRevision - AI-Powered PDF Study Assistant

Transform your PDF documents into interactive study materials with AI-powered tools!

FastAPI Next.js Groq Python TypeScript


๐Ÿ“– Table of Contents


๐ŸŒŸ Overview

SubRevision is an intelligent study companion that leverages AI to help students learn more effectively. Upload any PDF document and instantly generate:

  • โ“ Q&A System - Ask questions and get context-aware answers
  • ๐Ÿ” Smart Search - Find relevant content quickly
  • ๐Ÿ“ Auto Summaries - Get comprehensive document summaries
  • ๐ŸŽฏ Interactive Quizzes - Test your knowledge with auto-generated questions
  • ๐Ÿƒ 3D Flashcards - Flip-to-learn with beautiful card animations
  • ๐Ÿง  Mind Maps - Visualize concepts hierarchically
  • ๐Ÿ“… Study Plans - Get personalized day-by-day study schedules

โœจ Features

๐ŸŽฏ Core Features

Feature Description Status
PDF Upload Process and store PDF documents up to 50MB โœ… Active
AI Q&A Ask questions about your document content โœ… Active
Semantic Search Find relevant sections with vector search โœ… Active
Auto Summary Generate concise summaries of entire documents โœ… Active
Quiz Generation Create multiple-choice questions with answers โœ… Active
Flashcards Generate interactive flip cards for memorization โœ… Active
Mind Mapping Build hierarchical concept maps โœ… Active
Study Plans Get structured multi-day learning schedules โœ… Active

๐ŸŽจ UI Features

  • ๐ŸŽฎ Pixel Art Theme - Retro-inspired, midnight study aesthetic
  • ๐ŸŒ™ Dark Mode - Easy on the eyes for late-night studying
  • ๐Ÿ“ฑ Responsive Design - Works on desktop, tablet, and mobile
  • โšก Real-time Loading States - Visual feedback for all operations
  • ๐ŸŽญ Interactive Components - Click-to-reveal answers, flip cards
  • ๐ŸŽจ Color-coded Content - Different colors for different content types

๐Ÿ›  Tech Stack

Backend

  • FastAPI - High-performance Python web framework
  • Groq API - Ultra-fast AI inference with Llama 3.3 70B
  • PyPDF2 - PDF text extraction
  • Python 3.12 - Modern Python runtime
  • Uvicorn - ASGI server for production

Frontend

  • Next.js 16 - React framework with App Router
  • React 19 - Latest React with concurrent features
  • TypeScript 5 - Type-safe JavaScript
  • Tailwind CSS 4 - Utility-first CSS framework
  • Turbopack - Next-gen bundler (dev mode)

AI & ML

  • Groq Cloud - Free AI API with 30 req/min, 14,400 req/day
  • Llama 3.3 70B Versatile - State-of-the-art LLM
  • JSON Vector Storage - Lightweight document storage

๐Ÿ“‹ Prerequisites

Before you begin, ensure you have:


๐Ÿš€ Installation

1๏ธโƒฃ Clone the Repository

git clone https://github.com/muskiteer/SubRevision.git
cd SubRevision

2๏ธโƒฃ Backend Setup

# Navigate to backend directory
cd backend

# Create virtual environment
python3 -m venv .venv

# Activate virtual environment
# On Linux/Mac:
source .venv/bin/activate
# On Windows:
# .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

3๏ธโƒฃ Frontend Setup

# Navigate to frontend directory (from project root)
cd frontend

# Install dependencies
npm install

โš™๏ธ Configuration

Backend Configuration

Create a .env file in the backend/ directory:

cd backend
touch .env

Add your Groq API key:

GROQ_API_KEY=your_groq_api_key_here

Get Your Free Groq API Key:

  1. Visit console.groq.com
  2. Sign up/Login
  3. Navigate to API Keys
  4. Create new key
  5. Copy and paste into .env

Frontend Configuration

The frontend is pre-configured to connect to http://localhost:8000 (backend).

If you need to change the API URL, edit frontend/app/page.tsx:

const API_BASE = 'http://localhost:8000'; // Change if needed

๐ŸŽฎ Usage

Starting the Application

Option 1: Run Both Servers Separately

Terminal 1 - Backend:

cd backend
source .venv/bin/activate  # Activate virtual environment
uvicorn main:app --reload --host 0.0.0.0 --port 8000

Terminal 2 - Frontend:

cd frontend
npm run dev

Option 2: Background Mode

# Start backend in background
cd backend && source .venv/bin/activate && uvicorn main:app --reload &

# Start frontend in background
cd frontend && npm run dev &

Accessing the Application


๐Ÿ“š API Documentation

Endpoints

Endpoint Method Description
/pdf/upload POST Upload and process PDF file
/query/ask POST Ask questions about the document
/query/search POST Search for relevant sections
/generate/summary POST Generate document summary
/generate/quiz POST Generate quiz questions
/generate/flashcards POST Generate flashcards
/generate/mindmap POST Generate mind map structure
/generate/studyplan POST Generate study plan

Full API Documentation: Visit http://localhost:8000/docs for interactive Swagger UI.


๐Ÿ“ Project Structure

SubRevision/
โ”œโ”€โ”€ backend/                    # Python FastAPI backend
โ”‚   โ”œโ”€โ”€ db/                     # Database layer
โ”‚   โ”‚   โ”œโ”€โ”€ db.py              # Vector storage implementation
โ”‚   โ”‚   โ””โ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ handlers/              # Business logic
โ”‚   โ”‚   โ”œโ”€โ”€ handler.py         # API request handlers
โ”‚   โ”‚   โ””โ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ routes/                # API routes
โ”‚   โ”‚   โ”œโ”€โ”€ routes.py          # Endpoint definitions
โ”‚   โ”‚   โ””โ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ utils/                 # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ pdf_processor.py  # PDF extraction logic
โ”‚   โ”‚   โ””โ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ main.py                # FastAPI application entry
โ”‚   โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”‚   โ”œโ”€โ”€ .env                   # Environment variables (create this)
โ”‚   โ””โ”€โ”€ GROQ_SETUP.md         # Groq API setup guide
โ”‚
โ”œโ”€โ”€ frontend/                  # Next.js frontend
โ”‚   โ”œโ”€โ”€ app/                   # Next.js App Router
โ”‚   โ”‚   โ”œโ”€โ”€ layout.tsx        # Root layout
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx          # Main page component
โ”‚   โ”‚   โ””โ”€โ”€ globals.css       # Global styles (pixel theme)
โ”‚   โ”œโ”€โ”€ public/               # Static assets
โ”‚   โ”œโ”€โ”€ package.json          # Node dependencies
โ”‚   โ”œโ”€โ”€ tsconfig.json         # TypeScript config
โ”‚   โ”œโ”€โ”€ next.config.ts        # Next.js config
โ”‚   โ”œโ”€โ”€ tailwind.config.ts    # Tailwind config
โ”‚   โ””โ”€โ”€ postcss.config.mjs    # PostCSS config
โ”‚
โ””โ”€โ”€ README.md                  # This file

๐ŸŽจ UI Components

Tab Navigation

8 tabs for different features:

  • ๐Ÿ“„ Upload PDF
  • โ“ Ask Query
  • ๐Ÿ” Search
  • ๐Ÿ“ Summary
  • ๐ŸŽฏ Quiz
  • ๐Ÿƒ Flashcards
  • ๐Ÿง  Mind Map
  • ๐Ÿ“… Study Plan

Interactive Elements

Quiz Questions:

  • Click "Show Answer" to reveal
  • Color-coded: Question (cyan) โ†’ Answer (green)
  • Smooth fade-in animations

Flashcards:

  • 3D flip animation on click
  • Front: Cyan border (question)
  • Back: Green border (answer)
  • Responsive grid layout

Mind Map:

  • Hierarchical tree structure
  • Color-coded by depth level
  • Expandable/collapsible nodes

Study Plan:

  • Day-by-day cards
  • Topics with cyan bullets
  • Tasks with yellow checkboxes
  • Duration indicators

๐Ÿ”ง Development

Running Tests

# Backend tests (if available)
cd backend
pytest

# Frontend tests (if available)
cd frontend
npm test

Building for Production

Backend:

cd backend
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000

Frontend:

cd frontend
npm run build
npm start

Docker Deployment (Optional)

Create Dockerfile in backend:

FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

Create Dockerfile in frontend:

FROM node:20-alpine
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
RUN npm run build
CMD ["npm", "start"]

๐Ÿ› Troubleshooting

Common Issues

1. "No PDF uploaded yet" error

  • Make sure to upload a PDF before using other features
  • Check if upload was successful (status message)

2. Backend connection refused

  • Verify backend is running on port 8000
  • Check CORS settings in backend/main.py
  • Ensure firewall allows port 8000

3. Groq API errors

  • Verify API key in .env file
  • Check API quota (30 req/min, 14,400 req/day)
  • Ensure no extra spaces in API key

4. Frontend not connecting to backend

  • Check API_BASE URL in frontend/app/page.tsx
  • Verify backend is accessible at that URL
  • Check browser console for CORS errors

5. PDF upload fails

  • Ensure file is under 50MB
  • Check file is valid PDF format
  • Verify backend has write permissions

๐Ÿ“Š Performance

Groq API Limits

  • Rate Limit: 30 requests/minute
  • Daily Limit: 14,400 requests/day
  • Model: llama-3.3-70b-versatile
  • Speed: ~1000 tokens/second
  • Cost: FREE โœจ

Backend Performance

  • Handles PDFs up to 50MB
  • Chunks text into 500-char segments
  • Stores vectors in JSON (lightweight)
  • CORS enabled for localhost:3000

Frontend Performance

  • Next.js 16 with Turbopack (dev)
  • React 19 concurrent rendering
  • Client-side state management
  • No external API calls except backend

๐Ÿค Contributing

We welcome contributions! Here's how:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 for Python code
  • Use ESLint/Prettier for TypeScript
  • Add comments for complex logic
  • Update README for new features
  • Test before submitting PR

๐ŸŒŸ Acknowledgments

  • Groq for providing free, ultra-fast AI inference
  • Meta for the Llama 3.3 model
  • FastAPI for the excellent Python framework
  • Vercel for Next.js and amazing developer experience
  • Tailwind CSS for the utility-first CSS framework

Made with ๐Ÿ’œ for Students

Star โญ this repo if you find it helpful!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published