Full-stack Gemini-powered study assistant that allows users to upload PDF documents and engage in a contextual conversation with them. By combining the power of Google's Gemini API with a robust React/Node.js architecture, it transforms static notes into an interactive learning experience.
- AI-Driven Contextual Chat: Leverages the Gemini 2.5 Flash API to provide rapid, intelligent responses. It utilizes the extracted text from your PDFs alongside your chat history to ensure your Second Prof always has the full context of your study material.
- Relational Data Management: Uses MySQL to persistently store file metadata, allowing users to track their upload history across sessions.
- Smart Session Handling: Implements a hybrid session strategy using Server-side memory for active chat history and Client-side LocalStorage to ensure the chat interface remains consistent even after page refreshes.
- React (Vite): Responsive UI containing a split-screen PDF viewer and chat interface.
- State Management: Utilizes
useStateanduseReffor real-time message updates and MySQL for session persistence. - File Processing: Handles multi-part form data for PDF uploads and manages local object URLs for instant document previewing.
- Node.js & Express: The core engine handling API routing and file orchestration.
- Multer & PDF Extraction: Manages file uploads and uses
pdftotextCLI integration to parse raw text from documents. - Gemini Integration: Orchestrates prompts by injecting PDF context and chat history into the Google Generative AI SDK.
- Clone the Repository:
git clone https://github.com/sethj34/second-prof.git
cd second-prof
- Environment Variables:
Create a
.envfile in the root directory:
GOOGLE_API_KEY=your_gemini_api_key_here
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=your_database_name
- Database Setup:
Ensure you have a MySQL table named
fileswith columns forsession_id,original_name,stored_name, andsize:
CREATE DATABASE IF NOT EXISTS second_prof_db;
USE second_prof_db;
CREATE TABLE IF NOT EXISTS files (
id INT AUTO_INCREMENT PRIMARY KEY,
session_id VARCHAR(255) NOT NULL,
original_name VARCHAR(255) NOT NULL,
stored_name VARCHAR(255) NOT NULL,
size INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX (session_id)
);
- Install Dependencies & Run:
npm install
node server.js