How dhyanshah22/researchgpt works
Project Type & Purpose
• ResearchGPT is a full-stack application. Its core functionality allows users to upload PDFs, extract text, generate embeddings, and interact with the content via an AI-driven conversational interface.
Key Parts from the File Structure
• At the root, you have key files such as app.py (and app1.py) which likely serve as the entry point for the interactive UI built with Streamlit.
• The “backend” directory is subdivided into two main sections:
– backend/api: Contains the core API logic such as models, views, serializers, URL configurations, and migrations. This indicates a well-structured backend likely following an MVC or Django REST Framework pattern.
– backend/backend: Contains configuration-related files like settings, asgi, wsgi, and URL routing for the backend. This further confirms the use of a framework (likely Django) for managing the server-side functionality.
• Supporting files such as requirements.txt, config.toml, and the .devcontainer folder suggest that the project is containerized and dependencies are clearly specified.
Main Components
a. Frontend (UI):
• Streamlit-based interface (app.py) where users interact with the system.
• Handles PDF upload and chat interactions.
b. Backend API:
• API layer (backend/api) managing endpoints, including uploading documents, processing PDF data, and handling user queries.
• Controllers/views, serializers, and models forming the business logic.
c. Data Processing & Storage:
• PDF Extraction Component: Utilizes PyPDFLoader to extract text from uploaded PDFs.
• Embeddings & Vector Store: Uses Google Gemini AI to generate embeddings and FAISS for efficient vector-based search.
d. External Services:
• Google Gemini AI – for generating intelligent, context-aware responses.
e. Dependencies & Services:
• LangChain for managing conversational flows.
• Additional middleware/configurations for asynchronous communications, as seen in asgi.py and wsgi.py.
f. Development & Deployment:
• DevContainer and configuration files indicate containerized development and deployment practices (e.g., using Streamlit Cloud or other cloud providers as mentioned in the README).
Relationships and Data Flow
• The UI sends the document to the backend API (via endpoints defined in backend/api/urls.py and handled by backend/api/views.py).
• The backend extracts text from the PDF, generates vector embeddings (through PyPDFLoader and the Google Gemini integration), and stores these in FAISS.
• When users input queries, these are forwarded to the backend which, possibly with the help of LangChain, retrieves contextual information from FAISS and uses Gemini AI to generate responses.
• The final answer, complete with source references, is sent back to the UI for display.
Architectural Patterns & Design Principles
• Separation of Concerns: Clear division between the interactive frontend (Streamlit) and the backend API (likely Django), ensuring maintainability and scalability.
• Modular Design: The “backend/api” and “backend/backend” directories separate API concerns from overall configuration and deployment logic.
• Containerized Environment: Presence of the .devcontainer folder indicates an environment conducive to container-based development.
• External Service Integration: Integrates external AI hardware/services (Google Gemini AI) and external database (FAISS) in a loosely coupled manner.
Detailed Component Elements
• Clear labels for each component (e.g., “Streamlit UI App,” “Django API Backend,” “PDF Processor/Embedding Generator,” “FAISS Vector Store,” “Google Gemini AI Service”).
• Optionally, split the API layer into subcomponents if needed (e.g., authentication, document management, query handling) to capture more granularity.