An AI-powered study companion that transforms PDFs into interactive learning experiences. Built with FastAPI backend and React frontend, powered by LangChain and OpenRouter.
- Upload PDFs - Drag and drop your study materials
- Smart Q&A - Ask questions and get accurate, context-aware answers
- Auto Summaries - Generate concise summaries of any document
- Practice Quizzes - Create interactive quizzes to test your understanding
- Clear Doubts - Get explanations of complex topics
- Upload Course Material - Upload PDFs containing topic content
- Configure Question Papers - Set topic, difficulty, and number of questions
- Multiple Question Types - MCQs, short answer, and long answer questions
- Download as PDF - Generate and download professional question papers
- FastAPI - High-performance Python web framework
- LangChain - LLM application framework
- OpenRouter - Cloud LLM API (supports various models including LLaMA, Gemma, etc.)
- FAISS - Vector similarity search
- Sentence Transformers - Text embeddings
- PyPDF2 - PDF text extraction
- React - UI library
- Vite - Build tool
- React Router - Client-side routing
- jsPDF - PDF generation
- Axios - HTTP client
EL_project/
├── backend/ # FastAPI Backend
│ ├── app/
│ │ ├── main.py # FastAPI app entry point
│ │ ├── config.py # Configuration settings
│ │ ├── services/
│ │ │ ├── pdf_service.py # PDF processing
│ │ │ ├── vector_store.py # FAISS vector store
│ │ │ └── llm_service.py # LangChain + OpenRouter
│ │ ├── routers/
│ │ │ ├── student.py # Student API endpoints
│ │ │ └── teacher.py # Teacher API endpoints
│ │ └── models/
│ │ └── schemas.py # Pydantic models
│ ├── requirements.txt
│ └── .env.example
│
├── frontend/ # React Frontend
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API service
│ │ └── index.css # Global styles
│ ├── index.html
│ └── package.json
│
└── Chat-With-PDF-Using-LangChain-Gemini/ # Original Streamlit app (reference)
- Python 3.9+
- Node.js 18+
- OpenRouter API Key - Get your free API key from OpenRouter
-
Navigate to the backend directory:
cd backend -
Create a virtual environment:
python -m venv venv venv\Scripts\activate # Windows # or source venv/bin/activate # Linux/Mac
-
Install dependencies:
pip install -r requirements.txt
-
Copy environment file and configure your API key:
copy .env.example .env # Windows # or cp .env.example .env # Linux/Mac
-
Edit the
.envfile and add your OpenRouter API key:OPENROUTER_API_KEY=your_actual_api_key_here
-
Start the backend server:
uvicorn app.main:app --reload
The API will be available at
http://localhost:8000
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
The app will be available at
http://localhost:5173
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| POST | /student/upload |
Upload PDF for student |
| POST | /student/ask |
Ask any question (queries, summaries, quizzes, etc.) |
| POST | /teacher/upload |
Upload topic material |
| POST | /teacher/generate-paper |
Generate question paper |
The application features a modern dark theme with:
- Glassmorphism effects
- Animated backgrounds
- Smooth micro-animations
- Responsive layout
- Color-coded themes for Student (blue) and Teacher (green)
- Click "For Students" on the home page
- Upload a PDF document
- Once processed, ask questions in the chat interface
- Use quick actions for summaries or quizzes
- Click "For Teachers" on the home page
- Upload course material PDF
- Configure question paper settings (topic, difficulty, number of questions)
- Click "Generate Question Paper"
- Preview and download as PDF
Edit .env in the backend directory:
# Server settings
HOST=0.0.0.0
PORT=8000
DEBUG=True
# OpenRouter settings (REQUIRED)
OPENROUTER_API_KEY=your_openrouter_api_key_here
OPENROUTER_MODEL=meta-llama/llama-3.1-8b-instruct:free
# Vector store path
VECTOR_STORE_PATH=./vector_storesYou can change OPENROUTER_MODEL to use different models:
meta-llama/llama-3.1-8b-instruct:free(default)google/gemma-3-27b-it:freemistralai/mistral-7b-instruct:free
Check OpenRouter Models for more options.
This project is for educational purposes.
Feel free to open issues or submit pull requests!