Skip to content

sethj34/second-prof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Second Prof

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.


Overview

  • 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.

Technologies

Frontend

  • React (Vite): Responsive UI containing a split-screen PDF viewer and chat interface.
  • State Management: Utilizes useState and useRef for 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.

Backend

  • Node.js & Express: The core engine handling API routing and file orchestration.
  • Multer & PDF Extraction: Manages file uploads and uses pdftotext CLI integration to parse raw text from documents.
  • Gemini Integration: Orchestrates prompts by injecting PDF context and chat history into the Google Generative AI SDK.

Setup & Installation

  1. Clone the Repository:
git clone https://github.com/sethj34/second-prof.git
cd second-prof
  1. Environment Variables: Create a .env file 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
  1. Database Setup: Ensure you have a MySQL table named files with columns for session_id, original_name, stored_name, and size:
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)
);
  1. Install Dependencies & Run:
npm install
node server.js

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors