A comprehensive research assistance application built with React.js frontend and FastAPI/Django backends, featuring AI-powered academic paper search, document processing, and intelligent Q&A with tool calling capabilities.
- Modern UI/UX: Beautiful, responsive design with dark/light mode support
- Real-time Chat Interface: Interactive research Q&A with typing indicators and message history
- Authentication: JWT-based authentication with protected routes
- Document Upload: Support for research papers (PDF, TXT, MD)
- Modular Architecture: Clean component structure following DRY and SOLID principles
- Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
- π€ AI Research Assistant: Integration with Google Gemini AI and Qdrant vector database
- π Academic Search: Google Scholar integration for paper discovery
- π Web Search: SerpAPI integration for current information
- π οΈ Tool Calling: LangChain agent orchestration for multi-tool queries
- π Document Processing: RAG (Retrieval-Augmented Generation) with vector embeddings
- π€ User Management: JWT authentication with refresh token support
- πΎ Chat History: Persistent storage with source attribution
- π Dual Backend: Django (legacy) + FastAPI (modern, production-ready)
- Research Q&A: Context-aware answers from academic papers and web sources
- Smart Tool Selection: Automatic routing to Google Scholar, web search, or local documents
- Vector Search: Efficient similarity search with Qdrant
- Source Attribution: Transparent citations for all responses
- Scalable Architecture: Microservices-ready with Docker Compose
- React.js: Modern React with hooks and functional components
- Vite: Fast build tool and development server
- Tailwind CSS: Utility-first CSS framework
- React Router: Client-side routing
- React Hot Toast: User-friendly notifications
- Axios: HTTP client for API calls
- JWT Authentication: Secure token-based authentication
- FastAPI 0.115.0: High-performance async API framework
- Django REST Framework: Legacy API (fully functional)
- PostgreSQL: Primary database with SQLAlchemy 2.0 ORM
- Qdrant: Vector database for semantic search and RAG
- LangChain 0.3.26: AI agent framework with tool calling
- Google Generative AI: Gemini 2.0 Flash Exp model
- Scholarly 1.7.11: Google Scholar API wrapper
- SerpAPI: Web search integration
- Node.js 16+ and npm
- Python 3.11+
- Docker & Docker Compose
- Google AI API key
- SerpAPI key (optional, for web search)
-
Clone the repository
git clone <repository-url> cd Medical-Chatbot
-
Configure environment variables
# FastAPI Backend cd serverfapi cp .env.example .env.dev # Edit .env.dev with your API credentials
-
Start all services
# Development mode docker compose -f docker-compose.dev.yml up # Production mode docker compose -f docker-compose.prod.yml up
Services:
- Client: http://localhost:3001
- FastAPI: http://localhost:8001
- Django: http://localhost:8000
- Qdrant Dashboard: http://localhost:6333/dashboard
-
Set up Python environment
cd serverfapi python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Run Qdrant locally
docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant:latest
-
Run database migrations
# Will be created automatically on first run python manage.py createsuperuser -
Start the Django server
python manage.py runserver
-
Install dependencies
cd client npm install -
Configure environment variables
cp .env.local.example .env.local # Edit .env.local with your backend URL -
Start the development server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
-
Install dependencies
cd client npm install -
Configure environment variables
cp .env.local.example .env.local # Edit .env.local with your backend URL -
Start the development server
npm run dev
# App
APP_NAME=Research Helper API
DEBUG=True
SECRET_KEY=your-secret-key-change-in-production
# Database
DATABASE_URL=postgresql://postgres:postgres@db:5432/research_helper
# AI & Search
GOOGLE_API_KEY=your-google-gemini-api-key
SERPAPI_API_KEY=your-serpapi-key
# Qdrant Vector Database
QDRANT_HOST=qdrant
QDRANT_PORT=6333
QDRANT_COLLECTION_NAME=research_papers
# JWT
ACCESS_TOKEN_EXPIRE_MINUTES=60
REFRESH_TOKEN_EXPIRE_DAYS=7VITE_BACKEND_BASE_URL=http://localhost:8001
VITE_LOGIN_URL=/api/v1/auth/login
VITE_REFRESH_TOKEN_URL=/api/v1/auth/refresh- Register/Login: Create an account or sign in
- Upload Documents (Optional):
- Navigate to Documents/Knowledge Base
- Upload research papers (PDF, TXT, MD)
- Papers are automatically processed and embedded
- Ask Questions:
- Go to Research Assistant chat
- Type research questions
- Enable "Use Tools" for internet/academic search
- Get AI Responses:
- Receive context-aware answers
- View source attributions
- See which tools were used (Scholar/Web/Database)
- Search Papers:
- Use dedicated search endpoint
- Find papers on Google Scholar
- Get structured results with citations
FastAPI (http://localhost:8001/docs):
POST /api/v1/auth/register- User registrationPOST /api/v1/auth/login- LoginPOST /api/v1/research/ask- Ask research questionPOST /api/v1/documents/upload- Upload documentGET /api/v1/search/papers- Search academic papersGET /api/v1/search/web- Web search
- Google Scholar Tool: Searches academic papers by query
- Web Search Tool: Uses SerpAPI for current information
- Research Database Tool: Queries local Qdrant vector store
- Automatic Tool Selection: LLM chooses appropriate tools based on query
- Source Attribution: Tracks which tools provided information
- Document Ingestion: Automatic chunking with RecursiveCharacterTextSplitter
- Embedding Generation: Google Generative AI embeddings
- Vector Storage: Qdrant for fast similarity search
- Context Retrieval: Relevant document chunks added to prompts
- Multi-format Support: PDF, TXT, MD files up to 50MB
- Context-Aware: Responses based on uploaded documents and web sources
- Academic Accuracy: Information from peer-reviewed papers
- Current Information: Web search for latest developments
- Citation Tracking: Transparent source attribution
- Multi-source Synthesis: Combines local docs + Scholar + Web
- JWT Authentication: Secure token-based authentication with refresh tokens
- Protected Routes: Authentication required for all research endpoints
- CORS Configuration: Proper cross-origin resource sharing
- Input Validation: Pydantic models for request/response validation
- Password Hashing: bcrypt for secure password storage
- SQL Injection Prevention: SQLAlchemy ORM
- File Upload Limits: 50MB max with type validation
- Error Handling: Comprehensive error handling and user feedback
cd serverfapi
pytestcd client
npm test| Feature | Django (Legacy) | FastAPI (Modern) |
|---|---|---|
| Framework | Django REST Framework | FastAPI |
| Performance | Synchronous | Async/Await |
| Docs | Manual | Auto-generated (OpenAPI) |
| Type Safety | Limited | Full (Pydantic) |
| Vector DB | Pinecone | Qdrant |
| Tool Calling | No | Yes (LangChain) |
| Academic Search | No | Yes (Scholarly) |
| Web Search | No | Yes (SerpAPI) |
Medical-Chatbot/
βββ client/ # React frontend
β βββ src/
β β βββ Components/ # React components
β β βββ Pages/ # Page components
β β βββ services/ # API services
β β βββ utility/ # Utilities
β βββ Dockerfile
βββ server/ # Django backend (legacy)
β βββ auth_app/
β βββ chatbot_app/
β βββ requirements.txt
βββ serverfapi/ # FastAPI backend (modern)
β βββ app/
β β βββ api/v1/ # API endpoints
β β βββ core/ # Configuration
β β βββ models/ # Database models
β β βββ schemas/ # Pydantic schemas
β β βββ services/ # Business logic
β β βββ main.py
β βββ requirements.txt
β βββ Dockerfile.dev
β βββ Dockerfile.prod
βββ docker-compose.dev.yml
βββ docker-compose.prod.yml
βββ README.md
docker compose -f docker-compose.prod.yml up -d --build- Client (Nginx): Port 80 (production) / 3001 (dev)
- FastAPI: Port 8001
- Django: Port 8000
- PostgreSQL: Port 5432 (internal)
- Qdrant: Port 6333 (API), 6334 (gRPC)
This project is licensed under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
For questions or support, please open an issue on GitHub.
Note: This Research Helper is for educational and research purposes. For production use, ensure proper API keys, security measures, and compliance with academic search APIs' terms of service.