How scodive/researchgpt works
Project Type and Purpose
• ResearchGPT is an intelligent research assistant designed to help researchers explore literature, generate innovative research directions, design experiments, and even generate academic papers with LaTeX output.
• The README clarifies that the system supports research exploration, detailed research plan generation, and multi-lingual paper generation using technologies like the Google Gemini API (with plans for local model deployment).
File Structure
• The project is split into multiple layers/components:
• A "frontend" directory: Implements the user interface using Next.js 13 (app router), React, and Tailwind CSS.
• A "backend" directory: Contains Python code (with folders for models and services) that likely handle business logic, research plan generation, and interactions with language models.
• An "app" directory: Likely integrates API endpoints (in TypeScript), such as “compile-latex” and “generate-paper-gemini”, which provide hooks between the front-end and back-end.
• A mix of API endpoints in a “pages/api” directory in Next.js: These provide additional API routing for chat, paper generation, search, etc.
• There are configuration files, like vercel.json for deployment, and package files for front-end dependencies, along with environment variable samples.
Key Components
a. Frontend:
• Next.js 13 application with attribute pages for home, about, plan, paper, search, privacy, etc.
• Uses routing (app router and traditional pages API endpoints) to handle user interactions.
• Responsible for responsive UI and local data storage.
b. Backend:
• A Python-based backend (directory “backend”) containing modules for research models and services (e.g., llm_service.py, paper_service.py).
• Contains “main.py” and an environment configuration for deploying the service.
• Handles communication with external APIs (such as Google Gemini API) and possibly local models (as indicated in the README).
c. API Integration Layer:
• The “app/api” folder (with its route.ts files) and “pages/api” endpoints integrate the frontend with backend and third-party services.
• These layers manage the transformation of user requests to the corresponding processor (e.g., paper generation or LaTeX compiling).
d. Data Storage:
• Primarily localStorage as of the current version, with planned support for database storage.
e. External Services and Dependencies:
• Google Gemini API for intelligent generation and possibly local models in the future.
• Communication protocols between frontend and backend components.
Relationships and Interactions
• User interactions on the frontend are translated into API calls (via Next.js API endpoints, both in “app/api” and “pages/api”) which trigger backend processing.
• The backend processes these requests (using its services and models) to generate research plans or LaTeX code for papers.
• The system design should capture the data flow: from user input to API gateway, then to backend service invocation, and finally back to the user UI for display or file download.
• The integration with external APIs (like Google Gemini) should be noted as an interaction channel.
Architectural Patterns and Key Principles
• Separation of concerns between UI (frontend) and business logic/data processing (backend).
• The use of API gateways (Next.js API routes) to securely decouple the frontend and backend.
• Emphasis on scalable, modular design: independent modules for research exploration, paper generation, and LaTeX compiling.
• The system leverages modern full-stack patterns typical in Next.js applications (server components, API routes) along with traditional RESTful service design for the Python backend.
Instructing the Principal Software Engineer
• That capturing as many components as possible — from detailed API endpoints to service modules — is crucial for understanding the entire architecture.