A RAG-powered study assistant that answers questions exclusively from your uploaded materials. No hallucinations, no internet knowledge - just your textbooks, notes, and documents.
- Document-grounded answers - Responses come only from your uploaded materials
- Source citations - Every answer includes
[Source: filename]references - Context filtering - Select/deselect sources to focus your search
- Semantic search - Uses BGE embeddings for intelligent retrieval
- Supported formats: PDF, DOCX, TXT, Markdown, CSV
- URL scraping - Ingest content from any webpage (uses trafilatura + BeautifulSoup)
- Large file support - Up to 100MB per file
- Intelligent chunking - 1000-char chunks with 200-char overlap
- AI-generated flashcards from your study materials
- Cloze deletion support -
{{c1::term}}format - Source tagging - Auto-tagged with source filename
- Anki-ready export - Tab-separated format for direct import
Use your own API keys for different LLM providers:
| Provider | Models |
|---|---|
| Groq (default) | Llama 3.3 70B, Llama 3.1 8B, Mixtral 8x7B |
| OpenAI | GPT-4o, GPT-4o Mini, GPT-4 Turbo |
| Anthropic | Claude 3.5 Sonnet, Claude 3 Haiku |
API keys are stored locally in your browser and never logged server-side.
- Local accounts - Username/email/password registration
- OAuth - Google and Apple Sign-In
- Email verification - Optional verification flow
- JWT tokens - 7-day expiry, secure sessions
- Guest mode - Try without signing up
- Study AI (RAG) - Answers strictly from uploaded documents
- General AI - Unrestricted mode using full LLM knowledge
- History-only mode - Continue conversations after documents are removed
- LaTeX math rendering - Full KaTeX support for equations
- Streaming responses - Real-time token streaming via SSE
- Session management - Multiple study sessions per user
- Source management - Add/remove individual sources
- Chat export - Copy entire conversation to clipboard
- Memory indicator - Shows context window usage
- FastAPI - Async Python web framework
- fastembed - BAAI/bge-small-en-v1.5 embeddings (130MB)
- Groq/OpenAI/Anthropic - Multi-provider LLM support
- SQLite - User accounts and session metadata
- PyPDF2 / python-docx - Document parsing
- trafilatura / BeautifulSoup - Web scraping
- slowapi - Rate limiting
- bcrypt / PyJWT - Authentication
- React 18 - UI framework
- Vite - Build tooling
- TailwindCSS - Styling
- KaTeX - Math rendering via rehype-katex
- react-markdown - Markdown rendering
- lucide-react - Icons
# Clone the repository
git clone https://github.com/dreamlessx/Generic_RAG.git
cd Generic_RAG
# Create environment file
cat > backend/.env << EOF
GROQ_API_KEY=your_groq_api_key
JWT_SECRET=$(openssl rand -hex 32)
EOF
# Start services
docker compose up --buildAccess the app at http://localhost:3000
For production deployments (Railway, Oracle Cloud, etc.):
# Build unified image
docker build -t medstudy-ai .
# Run
docker run -p 8000:8000 \
-e GROQ_API_KEY=your_key \
-e JWT_SECRET=$(openssl rand -hex 32) \
-v medstudy_data:/app/data \
medstudy-aiBackend:
cd backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# Create .env file
echo "GROQ_API_KEY=your_key" > .env
echo "JWT_SECRET=dev-secret" >> .env
# Run
uvicorn app.main:app --reload --port 8000Frontend:
cd frontend
npm install
npm run devFrontend runs at http://localhost:5173, proxied to backend at :8000
| Variable | Required | Default | Description |
|---|---|---|---|
GROQ_API_KEY |
Yes | - | Default LLM provider API key |
JWT_SECRET |
Yes* | dev-secret... |
JWT signing secret (set in production!) |
PORT |
No | 8000 |
Server port |
GOOGLE_CLIENT_ID |
No | - | For Google OAuth |
APPLE_CLIENT_ID |
No | com.medstudy.app |
For Apple OAuth |
GET /api/Returns {"status": "ok", "service": "MedStudy AI API"}
POST /api/auth/register
Content-Type: application/json
{
"username": "student",
"email": "student@example.com",
"password": "SecurePass123"
}POST /api/auth/login
Content-Type: application/json
{
"username": "student",
"password": "SecurePass123"
}POST /api/auth/oauth
Content-Type: application/json
{
"provider": "google",
"id_token": "..."
}POST /api/sessions
Authorization: Bearer <token>Creates a new study session.
GET /api/sessions
Authorization: Bearer <token>Lists user's sessions.
POST /api/upload
Content-Type: multipart/form-data
file: <binary>
session_id: <string>POST /api/ingest-url
Content-Type: application/json
{
"session_id": "abc123",
"url": "https://example.com/article"
}POST /api/chat
Content-Type: application/json
{
"session_id": "abc123",
"question": "What is the mechanism of metformin?",
"mode": "rag",
"history": [...],
"source_filter": ["lecture1.pdf"],
"model": "openai-gpt4o",
"api_key": "sk-...",
"provider": "openai"
}Returns SSE stream:
data: {"token": "Metformin"}
data: {"token": " works by..."}
data: {"done": true, "sources": ["lecture1.pdf"]}
POST /api/sessions/{session_id}/anki
Content-Type: application/json
{
"num_cards": 20
}Returns tab-separated CSV file for Anki import.
DELETE /api/sessions/{session_id}/sources/{source_name}| Endpoint | Limit |
|---|---|
/api/auth/register |
5/minute |
/api/auth/login |
10/minute |
/api/upload |
20/minute |
/api/chat |
30/minute |
- 5 failed attempts triggers 5-minute lockout
- Per-username tracking
- Username: 3-30 chars, alphanumeric + underscore
- Password: 8+ chars, uppercase, lowercase, number required
- Question: Max 10,000 chars, HTML-escaped
- URL: Must start with
http://orhttps://, max 2048 chars - File size: Max 100MB
- Minimum 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one number
- Connect your GitHub repository
- Set environment variables:
GROQ_API_KEYJWT_SECRET
- Deploy using the root
Dockerfile - Add persistent volume mounted at
/app/data
# On your Oracle VM
docker run -d --restart=always \
-p 80:8000 \
-e GROQ_API_KEY=your_key \
-e JWT_SECRET=your_secret \
-v /home/ubuntu/medstudy:/app/data \
medstudy-aiservices:
backend:
build: ./backend
ports:
- "8000:8000"
env_file:
- ./backend/.env
volumes:
- uploads:/app/uploads
- vectorstores:/app/vectorstores
frontend:
build: ./frontend
ports:
- "3000:80"
depends_on:
- backendRAG_med/
├── backend/
│ └── app/
│ ├── main.py # FastAPI routes
│ ├── llm.py # Multi-provider LLM streaming
│ ├── document_processor.py # Text extraction, chunking, embeddings
│ ├── anki.py # Flashcard generation
│ ├── auth.py # JWT authentication
│ ├── database.py # SQLite user/session storage
│ └── config.py # Environment configuration
├── frontend/
│ └── src/
│ ├── App.jsx # Main React app
│ └── api.js # Backend API client
├── Dockerfile # Unified production image
└── docker-compose.yml # Development setup
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests (if applicable)
- Submit a pull request
MIT License - see LICENSE for details.